-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
245 lines (197 loc) · 6.03 KB
/
Makefile
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Detect OS
ifeq ($(shell uname -a|grep Linux|wc -l), 1)
OS = linux
endif
ifeq ($(shell uname -a|grep titan|wc -l), 1)
OS = titan
endif
ifeq ($(shell uname -a|grep Darwin|wc -l), 1)
OS = osx
endif
YES := $(shell which make | wc -l 2> /dev/null)
NO := $(shell which pikaboo | wc -l 2> /dev/null)
# Set optimization level
#OPTLEV = -g
OPTLEV = -O3
# Detect CUDA, Intel compiler, and MPI
ifeq ($(OS),titan)
MPI_FOUND := $(YES)
else
MPI_FOUND := $(shell which mpicc | wc -l 2> /dev/null)
endif
CUDA_COMPILER := $(shell which nvcc | wc -l 2> /dev/null)
INTEL_COMPILER := $(shell which icc | wc -l 2> /dev/null)
XLC_COMPILER := $(shell which xlc++ | wc -l 2> /dev/null)
ifeq ($(XLC_COMPILER), $(YES))
MPI_FOUND := $(shell which mpcc | wc -l 2> /dev/null)
endif
ifeq ($(MPI_FOUND), $(YES))
DEFS = -D USE_MPI
#-D USE_FBFFT
ifeq ($(OS),titan)
CC = CC
CL = CC
else # ifeq ($(OS),titan)
ifeq ($(INTEL_COMPILER), $(YES))
CC = mpicc
CL = mpicc
DEFS += -D MPICH_IGNORE_CXX_SEEK
else
ifeq ($(XLC_COMPILER), $(YES))
CC = mpCC -compiler xlc++
CL = mpCC -compiler xlc++
else
CC = mpic++
CL = mpic++
endif
endif
endif # ifeq ($(OS),titan)
else # MPI_FOUND
DEFS = -D DONT_USE_MPI
ifeq ($(INTEL_COMPILER), $(YES))
CC = icc
CL = icc
DEFS += -D MPICH_IGNORE_CXX_SEEK
else
ifeq ($(XLC_COMPILER), $(YES))
CC = xlc++
CL = xlc++
else
CC = g++
CL = g++
endif
endif
endif # MPI_FOUND
# NOTE: CUDA texture objects require Kepler GPU + CUDA 5.0
DEFS += -D USE_TEXTURE_OBJECTS
OBJS_RECIP = CudaPMERecip.o Bspline.o XYZQ.o Matrix3d.o Force.o reduce.o cuda_utils.o gpu_recip.o \
EnergyVirial.o CudaEnergyVirial.o
OBJS_DIRECT = XYZQ.o Force.o reduce.o cuda_utils.o CudaPMEDirectForce.o \
CudaNeighborList.o CudaNeighborListSort.o CudaNeighborListBuild.o \
CudaTopExcl.o gpu_direct.o CudaPMEDirectForceBlock.o CudaBlock.o \
CudaDirectForceKernels.o EnergyVirial.o CudaEnergyVirial.o
OBJS_BONDED = XYZQ.o Force.o reduce.o cuda_utils.o CudaBondedForce.o gpu_bonded.o EnergyVirial.o CudaEnergyVirial.o
OBJS_CONST = cuda_utils.o gpu_const.o HoloConst.o
OBJS_DYNA = cuda_utils.o gpu_dyna.o Force.o reduce.o CudaLeapfrogIntegrator.o CudaPMEForcefield.o \
CudaNeighborList.o CudaNeighborListSort.o CudaNeighborListBuild.o CudaTopExcl.o \
CudaPMEDirectForce.o CudaBondedForce.o CudaPMERecip.o Matrix3d.o XYZQ.o CudaDomdec.o \
CudaDomdecGroups.o HoloConst.o CudaDomdecHomezone.o CudaMPI.o mpi_utils.o CudaDomdecD2DComm.o \
DomdecD2DComm.o DomdecRecipComm.o CudaDomdecRecipComm.o CudaDomdecRecipLooper.o Domdec.o \
CudaDomdecConstComm.o CudaDirectForceKernels.o EnergyVirial.o CudaEnergyVirial.o
OBJS_PAIR = gpu_pair.o CudaPMERecip.o Force.o XYZQ.o cuda_utils.o reduce.o Matrix3d.o EnergyVirial.o CudaEnergyVirial.o
OBJS_FBFFT = test_fbfft.o cuda_utils.o
OBJS_TRANSPOSE = cpu_transpose.o mpi_utils.o CpuMultiNodeMatrix3d.o CpuMatrix3d.o
ifeq ($(CUDA_COMPILER), $(YES))
OBJS = $(OBJS_RECIP)
OBJS += $(OBJS_DIRECT)
OBJS += $(OBJS_BONDED)
OBJS += $(OBJS_CONST)
OBJS += $(OBJS_DYNA)
OBJS += $(OBJS_PAIR)
OBJS += $(OBJS_FBFFT)
endif
ifeq ($(MPI_FOUND), $(YES))
OBJS += $(OBJS_TRANSPOSE)
endif
ifeq ($(CUDA_COMPILER), $(YES))
CUDAROOT = $(subst /bin/,,$(dir $(shell which nvcc)))
endif
ifeq ($(MPI_FOUND), $(YES))
ifeq ($(OS),titan)
# NOTE: Assumes we're using Intel compiler
#MPIROOT = $(subst /bin/,,$(dir $(shell which icc)))
MPIROOT = /opt/cray/mpt/6.3.0/gni/mpich2-intel/130
else
MPIROOT = $(subst /bin/,,$(dir $(shell which mpicc)))
endif
endif
ifeq ($(INTEL_COMPILER), $(YES))
OPENMP_OPT = -openmp
else
ifeq ($(XLC_COMPILER), $(YES))
OPENMP_OPT = -qsmp=omp
else
OPENMP_OPT = -fopenmp
endif
endif
ifeq ($(CUDA_COMPILER), $(YES))
GENCODE_SM20 := -gencode arch=compute_20,code=sm_20
GENCODE_SM30 := -gencode arch=compute_30,code=sm_30
GENCODE_SM35 := -gencode arch=compute_35,code=sm_35
GENCODE_SM50 := -gencode arch=compute_50,code=sm_50
# See if CUDA compiler supports compute 5.0, also disable 5.0 for Titan
ifeq ($(OS),titan)
# Titan, K20x GPUs
GENCODE_FLAGS := $(GENCODE_SM35)
else
# Some other system
GENCODE_FLAGS := $(GENCODE_SM30) $(GENCODE_SM35)
ifneq ($(shell nvcc --help|grep compute_50|wc -l), 0)
GENCODE_FLAGS += $(GENCODE_SM50)
endif
endif
endif
# CUDA_CFLAGS = flags for compiling CUDA API calls using c compiler
# NVCC_CFLAGS = flags for nvcc compiler
# CUDA_LFLAGS = flags for linking with CUDA
CUDA_CFLAGS = -I${CUDAROOT}/include $(OPTLEV) $(OPENMP_OPT)
ifeq ($(XLC_COMPILER), $(NO))
CUDA_FLAGS += -std=c++0x
endif
NVCC_CFLAGS = $(OPTLEV) -lineinfo -fmad=true -use_fast_math $(GENCODE_FLAGS) --disable-warnings
ifeq ($(XLC_COMPILER), $(YES))
MPI_CFLAGS = -I/opt/ibmhpc/pecurrent/mpich/gnu/include64
else
MPI_CFLAGS = -I${MPIROOT}/include
endif
ifeq ($(OS),linux)
CUDA_LFLAGS = -L$(CUDAROOT)/lib64
else
ifeq ($(OS),titan)
CUDA_LFLAGS = -L$(CUDAROOT)/lib64
else
CUDA_LFLAGS = -L$(CUDAROOT)/lib
endif
endif
CUDA_LFLAGS += -lcudart -lcufft -lnvToolsExt
ifeq ($(CUDA_COMPILER), $(YES))
BINARIES = gpu_bonded gpu_recip gpu_const gpu_dyna gpu_direct gpu_pair test_fbfft
endif
ifeq ($(MPI_FOUND), $(YES))
BINARIES += cpu_transpose
endif
all: $(BINARIES)
gpu_recip : $(OBJS_RECIP)
$(CL) $(CUDA_LFLAGS) -o gpu_recip $(OBJS_RECIP)
gpu_direct : $(OBJS_DIRECT)
$(CL) $(CUDA_LFLAGS) -o gpu_direct $(OBJS_DIRECT)
gpu_bonded : $(OBJS_BONDED)
$(CL) $(CUDA_LFLAGS) -o gpu_bonded $(OBJS_BONDED)
gpu_const : $(OBJS_CONST)
$(CL) $(CUDA_LFLAGS) -o gpu_const $(OBJS_CONST)
gpu_dyna : $(OBJS_DYNA)
$(CL) $(OPTLEV) $(CUDA_LFLAGS) -o gpu_dyna $(OBJS_DYNA)
gpu_pair : $(OBJS_PAIR)
$(CL) $(OPTLEV) $(CUDA_LFLAGS) -o gpu_pair $(OBJS_PAIR)
test_fbfft : $(OBJS_FBFFT)
$(CL) $(OPTLEV) $(CUDA_LFLAGS) -o test_fbfft $(OBJS_FBFFT)
cpu_transpose : $(OBJS_TRANSPOSE)
$(CL) $(CUDA_LFLAGS) $(OPENMP_OPT) -o cpu_transpose $(OBJS_TRANSPOSE)
clean:
rm -f *.o
rm -f *.d
rm -f *~
rm -f $(BINARIES)
# Pull in dependencies that already exist
-include $(OBJS:.o=.d)
%.o : %.cu
nvcc -c $(MPI_CFLAGS) $(NVCC_CFLAGS) $(DEFS) $<
nvcc -M $(MPI_CFLAGS) $(NVCC_CFLAGS) $(DEFS) $*.cu > $*.d
ifeq ($(XLC_COMPILER), $(YES))
%.o : %.cpp
$(CC) -Mc $(CUDA_CFLAGS) $(DEFS) $<
else
%.o : %.cpp
$(CC) -c $(CUDA_CFLAGS) $(DEFS) $<
$(CC) -MM $(CUDA_CFLAGS) $(DEFS) $*.cpp > $*.d
endif