-
Notifications
You must be signed in to change notification settings - Fork 112
/
Makefile.Cuda
231 lines (196 loc) · 5.6 KB
/
Makefile.Cuda
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
# AutoDock-GPU Cuda Makefile
# ------------------------------------------------------
# Note that environment variables must be defined
# before compiling
# DEVICE?
# if DEVICE=CPU: CPU_INCLUDE_PATH?, CPU_LIBRARY_PATH?
# if DEVICE=GPU: GPU_INCLUDE_PATH?, GPU_LIBRARY_PATH?
# ------------------------------------------------------
# Choose OpenCL device
# Valid values: CPU, GPU
NVCC = nvcc
CPP = g++
UNAME := $(shell uname)
TARGETS = 52 60 61 70 80
ifeq ($(TENSOR), ON)
NVTENSOR=-DUSE_NVTENSOR
NVTENSOR+=-I./wmma_extension/include
TARGETS = 80
endif
CUDA_TARGETS=$(foreach target,$(TARGETS),-gencode arch=compute_$(target),code=sm_$(target))
ifeq ($(DEVICE), CPU)
DEV =-DCPU_DEVICE
else ifeq ($(DEVICE), GPU)
DEV =-DGPU_DEVICE
endif
# ------------------------------------------------------
# Project directories
# opencl_lvs: wrapper for OpenCL APIs
COMMON_DIR=./common
HOST_INC_DIR=./host/inc
HOST_SRC_DIR=./host/src
KRNL_DIR=./cuda
KCMN_DIR=$(COMMON_DIR)
BIN_DIR=./bin
LIB_CUDA = kernels.o -lcurand -lcudart -DUSE_CUDA
TARGET := autodock
TOOL_TARGET := adgpu_analysis
IFLAGS=-I$(COMMON_DIR) -I$(HOST_INC_DIR) -I$(GPU_INCLUDE_PATH) -I$(KRNL_DIR)
LFLAGS=-L$(GPU_LIBRARY_PATH) -Wl,-rpath=$(GPU_LIBRARY_PATH):$(CPU_LIBRARY_PATH)
CFLAGS=-std=c++17 $(IFLAGS) $(LFLAGS)
TOOL_CFLAGS=-std=c++17 -I$(COMMON_DIR) -I$(HOST_INC_DIR)
ifeq ($(DEVICE), CPU)
TARGET:=$(TARGET)_cpu
else ifeq ($(DEVICE), GPU)
NWI=-DN64WI
TARGET:=$(TARGET)_gpu
endif
ifeq ($(OVERLAP), ON)
PIPELINE=-DUSE_PIPELINE -fopenmp
endif
BIN := $(wildcard $(TARGET)*)
# ------------------------------------------------------
# Number of work-items (wi)
# Valid values: 32, 64, 128, 256
NUMWI=
ifeq ($(NUMWI), 32)
ifeq ($(TENSOR), ON)
$(error NUMWI needs to be at least 64 with TENSOR=ON)
endif
NWI=-DN32WI
TARGET:=$(TARGET)_32wi
else ifeq ($(NUMWI), 64)
NWI=-DN64WI
TARGET:=$(TARGET)_64wi
else ifeq ($(NUMWI), 128)
NWI=-DN128WI
TARGET:=$(TARGET)_128wi
else ifeq ($(NUMWI), 256)
NWI=-DN256WI
TARGET:=$(TARGET)_256wi
else
ifeq ($(DEVICE), CPU)
NWI=-DN16WI
TARGET:=$(TARGET)_16wi
else ifeq ($(DEVICE), GPU)
NWI=-DN128WI
TARGET:=$(TARGET)_128wi
endif
endif
# ------------------------------------------------------
# Configuration
# FDEBUG (full) : enables debugging on both host + device
# LDEBUG (light): enables debugging on host
# RELEASE
CONFIG=RELEASE
#CONFIG=FDEBUG
ifeq ($(CONFIG),FDEBUG)
OPT =-O0 -g3 -Wall -DDOCK_DEBUG
CUDA_FLAGS = -G -use_fast_math --ptxas-options="-v" $(CUDA_TARGETS) -std=c++11
else ifeq ($(CONFIG),LDEBUG)
OPT =-O0 -g3 -Wall
CUDA_FLAGS = -use_fast_math --ptxas-options="-v" $(CUDA_TARGETS) -std=c++11
else ifeq ($(CONFIG),RELEASE)
OPT =-O3
CUDA_FLAGS = -use_fast_math --ptxas-options="-v" $(CUDA_TARGETS) -std=c++11
else
OPT =
CUDA_FLAGS = -use_fast_math --ptxas-options="-v" $(CUDA_TARGETS) -std=c++11
endif
# ------------------------------------------------------
# Reproduce results (remove randomness)
REPRO=NO
ifeq ($(REPRO),YES)
REP =-DREPRO
else
REP =
endif
# ------------------------------------------------------
all: otool odock
check-env-dev:
@if test -z "$$DEVICE"; then \
echo "Please set DEVICE to either CPU, GPU, CUDA, or OCLGPU to build docking software."; \
exit 1; \
else \
if [ "$$DEVICE" = "CPU" ]; then \
echo "DEVICE is set to $$DEVICE which is not a valid Cuda device."; \
exit 1; \
else \
if [ "$$DEVICE" = "GPU" ]; then \
echo "DEVICE is set to $$DEVICE"; \
else \
echo "DEVICE value is invalid. Please set DEVICE to either CPU, GPU, CUDA, or OCLGPU"; \
exit 1; \
fi; \
fi; \
fi; \
echo " "
check-env-cpu:
@if test -z "$$CPU_INCLUDE_PATH"; then \
echo "CPU_INCLUDE_PATH is undefined"; \
else \
echo "CPU_INCLUDE_PATH is set to $$CPU_INCLUDE_PATH"; \
fi; \
if test -z "$$CPU_LIBRARY_PATH"; then \
echo "CPU_LIBRARY_PATH is undefined"; \
else \
echo "CPU_LIBRARY_PATH is set to $$CPU_LIBRARY_PATH"; \
fi; \
echo " "
check-env-gpu:
@if test -z "$$GPU_INCLUDE_PATH"; then \
echo "GPU_INCLUDE_PATH is undefined"; \
else \
echo "GPU_INCLUDE_PATH is set to $$GPU_INCLUDE_PATH"; \
fi; \
if test -z "$$GPU_LIBRARY_PATH"; then \
echo "GPU_LIBRARY_PATH is undefined"; \
else \
echo "GPU_LIBRARY_PATH is set to $$GPU_LIBRARY_PATH"; \
fi; \
echo " "
check-env-all: check-env-dev check-env-cpu check-env-gpu
# ------------------------------------------------------
# Priting out its git version hash
GIT_VERSION := $(shell ./version_string.sh)
CFLAGS+=-DVERSION=\"$(GIT_VERSION)\"
TOOL_CFLAGS+=-DVERSION=\"$(GIT_VERSION)\"
# ------------------------------------------------------
kernels: $(KERNEL_SRC)
$(NVCC) $(NWI) $(REP) $(CUDA_FLAGS) $(IFLAGS) $(CUDA_INCLUDES) $(NVTENSOR) -c $(KRNL_DIR)/kernels.cu
otool:
@echo "Building" $(TOOL_TARGET) "..."
$(CPP) \
$(shell ls $(HOST_SRC_DIR)/*.cpp) \
$(TOOL_CFLAGS) \
-o$(BIN_DIR)/$(TOOL_TARGET) \
$(PIPELINE) $(NVTENSOR) $(OPT) -DTOOLMODE $(REP)
odock: check-env-all kernels
@echo "Building" $(TARGET) "..."
$(CPP) \
$(shell ls $(HOST_SRC_DIR)/*.cpp) \
$(CFLAGS) \
$(LIB_CUDA) \
-o$(BIN_DIR)/$(TARGET) \
$(DEV) $(NWI) $(PIPELINE) $(NVTENSOR) $(OPT) $(DD) $(REP) $(KFLAGS)
# Example
# 1ac8: for testing gradients of translation and rotation genes
# 7cpa: for testing gradients of torsion genes (15 torsions)
# 3tmn: for testing gradients of torsion genes (1 torsion)
PDB := 3ce3
NRUN := 100
NGEN := 27000
POPSIZE := 150
TESTNAME := test
TESTLS := ad
test: odock
$(BIN_DIR)/$(TARGET) \
-ffile ./input/$(PDB)/derived/$(PDB)_protein.maps.fld \
-lfile ./input/$(PDB)/derived/$(PDB)_ligand.pdbqt \
-nrun $(NRUN) \
-ngen $(NGEN) \
-psize $(POPSIZE) \
-resnam $(TESTNAME) \
-gfpop 0 \
-lsmet $(TESTLS)
.PHONY: clean