-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (120 loc) · 4.18 KB
/
Makefile
File metadata and controls
157 lines (120 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Makefile for src-openmp
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(mkfile_dir)../../Makefile.defs
SHELL = /bin/bash
host_debug_flag ?=
### CoMD can be built in either double or single precision and with or
### without MPI. Select desired precision and MPI here.
# double precision (ON/OFF)
DOUBLE_PRECISION = ON
# MPI for parallel (ON/OFF)
DO_MPI = OFF
AOMP_GPU ?= $(INSTALLED_GPU)
AOMP_GPUTARGET = amdgcn-amd-amdhsa
# Default is Radeon vega/gfx900, for nvidia "export AOMP_GPU=sm_35"
ifeq (sm_,$(findstring sm_,$(AOMP_GPU)))
AOMP_GPUTARGET = nvptx64-nvidia-cuda
endif
AOMP_CPUTARGET ?= x86_64-pc-linux-gnu
DEBUG_LEVEL ?= 0
### Set your desired C compiler and any necessary flags. Note that CoMD
### uses some c99 features. You can also set flags for optimization and
### specify paths to include files that the compiler can't find on its
### own. If you need any -L or -l switches to get C standard libraries
### (such as -lm for the math library) put them in C_LIB.
#CC = mpicc
CC = $(AOMP)/bin/clang
FLAGS = -O3 -target $(AOMP_CPUTARGET) -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -Xopenmp-target=$(AOMP_GPUTARGET) -march=$(AOMP_GPU) $(host_debug_flag)
CFLAGS = -O3 -std=c99
FLAGS += -D__GPU__
OPTFLAGS =
INCLUDES =
C_LIB = -lm
LFLAGS = -fopenmp -fopenmp-targets=$(AOMP_GPUTARGET) -target $(AOMP_CPUTARGET)
ifeq (nvptx,$(findstring nvptx,$(AOMP_GPUTARGET)))
CUDA ?= /usr/local/cuda
LFLAGS += -L$(CUDA)/lib64 -lcuda -lcudart -lelf -lffi
endif
### If you need to specify include paths, library paths, or link flags
### for MPI, put them here. Put both -L and -l switches into MPI_LIB.
MPI_LIB =
MPI_INCLUDE =
### A place to specify any other include or library switches your
### platform requires.
OTHER_LIB =
OTHER_INCLUDE =
ifeq ($(DEBUG_LEVEL),0)
SETDEBUGLIB =
SETDEBUGRUNENV =
else
# if DEBUG_LEVEL != 0, build with the debug libraries which are slow.
SETDEBUGLIB = LIBRARY_PATH=$(AOMP)/lib-debug
# Once you build with debug libs, you have different levels of debug
# by setting these environment variables.
# LIBOMPTARGET_DEBUG: Host device runtime debug messages
SETDEBUGRUNENV = LIBOMPTARGET_DEBUG=1
# LIBOMPTARGET_DEVICE_RTL_DEBUG: Device runtime debug messages.
#SETDEBUGRUNENV = LIBOMPTARGET_DEVICE_RTL_DEBUG=-1
# ATMI_DEBUG: Print ATMI debug messages
#SETDEBUGRUNENV = ATMI_DEBUG=1
endif
# NOTE: You do NOT need debug libs to turn kernel tracing on.
# Set LIBOMPTARGET_KERNEL_TRACE anytime to get kernel launch trace.
# Uncomment next line to activate kernel launch trace in this makefile.
#SETDEBUGRUNENV += LIBOMPTARGET_KERNEL_TRACE=1
#########################################
### Below here, it is pitch black.
### You are likely to be eaten by a grue.
##########################################
# clear all suffixes
.SUFFIXES:
# list only those that we use
.SUFFIXES: .c .o
.PHONY: DEFAULT clean distclean depend
BIN_DIR=../bin
# Check for double precision
ifeq ($(DOUBLE_PRECISION), ON)
CFLAGS += -DDOUBLE
else
CFLAGS += -DSINGLE
endif
# Set executable name and add includes & libraries for MPI if needed.
CoMD_VARIANT = CoMD-openmp
ifeq ($(DO_MPI), ON)
CoMD_VARIANT = CoMD-openmp-mpi
INCLUDES += ${MPI_INCLUDE}
CFLAGS += -DDO_MPI
LDFLAGS += ${MPI_LIB}
endif
CoMD_EXE = ${BIN_DIR}/${CoMD_VARIANT}
LDFLAGS += ${C_LIB} ${OTHER_LIB}
CFLAGS += ${OPTFLAGS} ${INCLUDES} ${OTHER_INCLUDE}
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
DEFAULT: ${CoMD_EXE}
%.o: %.c
${CC} ${CFLAGS} ${FLAGS} -c $< -o $@
ljForce.o: ljForce.c
${CC} ${CFLAGS} $(FLAGS) -c $< -o $@
${CoMD_EXE}: ${BIN_DIR} CoMD_info.h ${OBJECTS}
$(SETDEBUGLIB) ${CC} ${CFLAGS} $(FLAGS) -o ${CoMD_EXE} ${OBJECTS} $(LFLAGS) ${LDFLAGS}
run: ${CoMD_EXE}
$(SETDEBUGRUNENV) ${CoMD_EXE}
CoMD_info.h: Makefile
./generate_info_header ${CoMD_VARIANT} "$(CC)" "$(CFLAGS)" "$(LDFLAGS)"
${BIN_DIR}:
@if [ ! -d ${BIN_DIR} ]; then mkdir -p ${BIN_DIR} ; fi
clean:
rm -f ${CoMD_EXE} .depend.bak
rm -f *.o CoMD_info.h .depend
distclean: clean
rm -f ${CoMD_EXE} .depend.bak
rm -rf html latex
.depend: $(SOURCES)
@touch .depend
@$(MAKE) --no-print-directory depend
depend:
@echo "Rebuilding dependencies..."
@$(MAKE) CoMD_info.h
@makedepend -f .depend -Y. --$(CFLAGS)-- $(SOURCES) 2> /dev/null ; true
-include .depend