Makefile 6.21 KB
Newer Older
1
# OCLADock Makefile
2

3 4 5 6 7 8
# ------------------------------------------------------
# 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?
9

10 11
# ------------------------------------------------------
# Choose OpenCL device
12
# Valid values: CPU, GPU
13 14 15

ifeq ($(DEVICE), CPU)
	DEV =-DCPU_DEVICE
16 17 18
	OCLA_INC_PATH=$(CPU_INCLUDE_PATH)
	OCLA_LIB_PATH=$(CPU_LIBRARY_PATH)
else ifeq ($(DEVICE), GPU)
19
	DEV =-DGPU_DEVICE
20 21
	OCLA_INC_PATH=$(GPU_INCLUDE_PATH)
	OCLA_LIB_PATH=$(GPU_LIBRARY_PATH)
22 23 24
endif

# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
25 26 27
# Project directories
# opencl_lvs: wrapper for OpenCL APIs
COMMON_DIR=./common
28 29
OCL_INC_DIR=./wrapcl/inc
OCL_SRC_DIR=./wrapcl/src
Leonardo Solis's avatar
Leonardo Solis committed
30 31 32
HOST_INC_DIR=./host/inc
HOST_SRC_DIR=./host/src
KRNL_DIR=./device
33
KCMN_DIR=$(COMMON_DIR)
34
BIN_DIR=./bin
Leonardo Solis's avatar
Leonardo Solis committed
35 36 37 38 39 40

# Host sources
OCL_SRC=$(wildcard $(OCL_SRC_DIR)/*.cpp)
HOST_SRC=$(wildcard $(HOST_SRC_DIR)/*.cpp)
SRC=$(OCL_SRC) $(HOST_SRC)

41 42
IFLAGS=-I$(COMMON_DIR) -I$(OCL_INC_DIR) -I$(HOST_INC_DIR) -I$(OCLA_INC_PATH)
LFLAGS=-L$(OCLA_LIB_PATH)
Leonardo Solis's avatar
Leonardo Solis committed
43 44 45 46 47 48 49 50 51 52
CFLAGS=$(IFLAGS) $(LFLAGS)

# Device sources
KRNL_MAIN=calcenergy.cl
KRNL_SRC=$(KRNL_DIR)/$(KRNL_MAIN)
# Kernel names
K1_NAME="gpu_calc_initpop"
K2_NAME="gpu_sum_evals"
K3_NAME="perform_LS"
K4_NAME="gpu_gen_and_eval_newpops"
53
K5_NAME="gradient_minSD"
54
K6_NAME="gradient_minFire"
lvs's avatar
lvs committed
55 56
K7_NAME="gradient_minAD"
K_NAMES=-DK1=$(K1_NAME) -DK2=$(K2_NAME) -DK3=$(K3_NAME) -DK4=$(K4_NAME) -DK5=$(K5_NAME) -DK6=$(K6_NAME) -DK7=$(K7_NAME)
Leonardo Solis's avatar
Leonardo Solis committed
57
# Kernel flags
58
KFLAGS=-DKRNL_SOURCE=$(KRNL_DIR)/$(KRNL_MAIN) -DKRNL_DIRECTORY=$(KRNL_DIR) -DKCMN_DIRECTORY=$(KCMN_DIR) $(K_NAMES)
Leonardo Solis's avatar
Leonardo Solis committed
59 60

TARGET := ocladock
61 62
ifeq ($(DEVICE), CPU)
	TARGET:=$(TARGET)_cpu
63
else ifeq ($(DEVICE), GPU)
64
	NWI=-DN64WI
65
	TARGET:=$(TARGET)_gpu
66 67
endif

Leonardo Solis's avatar
Leonardo Solis committed
68 69
BIN := $(wildcard $(TARGET)*)

70
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
71 72
# Number of work-items (wi)
# Valid values: 16, 32, 64, 128
73
NUMWI=
Leonardo Solis's avatar
Leonardo Solis committed
74

75
ifeq ($(NUMWI), 16)
Leonardo Solis's avatar
Leonardo Solis committed
76 77
	NWI=-DN16WI
	TARGET:=$(TARGET)_16wi
78
else ifeq ($(NUMWI), 32)
Leonardo Solis's avatar
Leonardo Solis committed
79 80
	NWI=-DN32WI
	TARGET:=$(TARGET)_32wi
81
else ifeq ($(NUMWI), 64)
Leonardo Solis's avatar
Leonardo Solis committed
82 83
	NWI=-DN64WI
	TARGET:=$(TARGET)_64wi
84
else ifeq ($(NUMWI), 128)
Leonardo Solis's avatar
Leonardo Solis committed
85 86
	NWI=-DN128WI
	TARGET:=$(TARGET)_128wi
lvs's avatar
lvs committed
87 88 89
else ifeq ($(NUMWI), 256)
		NWI=-DN256WI
		TARGET:=$(TARGET)_256wi
Leonardo Solis's avatar
Leonardo Solis committed
90 91 92 93
else
	ifeq ($(DEVICE), CPU)
		NWI=-DN16WI
		TARGET:=$(TARGET)_16wi
94
	else ifeq ($(DEVICE), GPU)
Leonardo Solis's avatar
Leonardo Solis committed
95 96 97 98 99 100
		NWI=-DN64WI
		TARGET:=$(TARGET)_64wi
	endif
endif

# ------------------------------------------------------
101 102 103 104
# Configuration
# FDEBUG (full) : enables debugging on both host + device
# LDEBUG (light): enables debugging on host
# RELEASE
105
CONFIG=RELEASE
Leonardo Solis's avatar
Leonardo Solis committed
106

107 108 109 110 111 112 113 114 115 116 117 118 119 120
OCL_DEBUG_BASIC=-DPLATFORM_ATTRIBUTES_DISPLAY\
	        -DDEVICE_ATTRIBUTES_DISPLAY

OCL_DEBUG_ALL=$(OCL_DEBUG_BASIC) \
	      -DCONTEXT_INFO_DISPLAY \
	      -DCMD_QUEUE_INFO_DISPLAY \
	      -DCMD_QUEUE_PROFILING_ENABLE \
	      -DCMD_QUEUE_OUTORDER_ENABLE \
	      -DPROGRAM_INFO_DISPLAY \
	      -DPROGRAM_BUILD_INFO_DISPLAY \
	      -DKERNEL_INFO_DISPLAY \
	      -DKERNEL_WORK_GROUP_INFO_DISPLAY \
	      -DBUFFER_OBJECT_INFO_DISPLAY

121 122 123
ifeq ($(CONFIG),FDEBUG)
	OPT =-O0 -g3 -Wall $(OCL_DEBUG_ALL) -DDOCK_DEBUG
else ifeq ($(CONFIG),LDEBUG)
124
	OPT =-O0 -g3 -Wall $(OCL_DEBUG_BASIC)
125
else ifeq ($(CONFIG),RELEASE)
Leonardo Solis's avatar
Leonardo Solis committed
126 127 128 129 130
	OPT =-O3
else
	OPT =
endif

131
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
132 133 134 135 136 137 138 139 140 141 142 143
# Reproduce results (remove randomness)
REPRO=NO

ifeq ($(REPRO),YES)
	REP =-DREPRO
else
	REP =
endif
# ------------------------------------------------------

all: odock

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
check-env-dev:
	@if test -z "$$DEVICE"; then \
		echo "DEVICE is undefined"; \
		exit 1; \
	else \
		if [ "$$DEVICE" = "CPU" ]; then \
			echo "DEVICE is set to $$DEVICE"; \
		else \
			if [ "$$DEVICE" = "GPU" ]; then \
				echo "DEVICE is set to $$DEVICE"; \
			else \
				echo "DEVICE value is invalid. Set DEVICE to either CPU or GPU"; \
			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

Leonardo Solis's avatar
Leonardo Solis committed
189 190 191
# ------------------------------------------------------
# Priting out its git version hash

192
GIT_VERSION := $(shell git describe --abbrev=40 --dirty --always --tags)
Leonardo Solis's avatar
Leonardo Solis committed
193 194 195 196 197

CFLAGS+=-DVERSION=\"$(GIT_VERSION)\"

# ------------------------------------------------------

198 199 200
stringify:
	./stringify_ocl_krnls.sh

201
odock: check-env-all stringify $(SRC)
Leonardo Solis's avatar
Leonardo Solis committed
202 203 204 205 206 207
	g++ \
	$(SRC) \
	$(CFLAGS) \
	-lOpenCL \
	-o$(BIN_DIR)/$(TARGET) \
	$(DEV) $(NWI) $(OPT) $(DD) $(REP) $(KFLAGS)
208 209

# Example
210 211 212 213
# 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)

lvs's avatar
lvs committed
214
PDB      := 3ce3
215
NRUN     := 100
216
NGEN     := 27000
217
POPSIZE  := 150
lvs's avatar
lvs committed
218
TESTNAME := test
lvs's avatar
lvs committed
219
TESTLS   := sw
lvs's avatar
lvs committed
220

221
test: odock
Leonardo Solis's avatar
Leonardo Solis committed
222 223 224 225
	$(BIN_DIR)/$(TARGET) \
	-ffile ./input/$(PDB)/derived/$(PDB)_protein.maps.fld \
	-lfile ./input/$(PDB)/derived/$(PDB)_ligand.pdbqt \
	-nrun $(NRUN) \
226
	-ngen $(NGEN) \
Leonardo Solis's avatar
Leonardo Solis committed
227 228 229 230
	-psize $(POPSIZE) \
	-resnam $(TESTNAME) \
	-gfpop 0 \
	-lsmet $(TESTLS)
231

232
ASTEX_PDB := 2bsm
233 234
ASTEX_NRUN:= 10
ASTEX_POPSIZE := 10
235
ASTEX_TESTNAME := test_astex
236
ASTEX_LS := sw
237 238

astex: odock
Leonardo Solis's avatar
Leonardo Solis committed
239 240 241 242 243 244 245 246
	$(BIN_DIR)/$(TARGET) \
	-ffile ./input_tsri/search-set-astex/$(ASTEX_PDB)/protein.maps.fld \
	-lfile ./input_tsri/search-set-astex/$(ASTEX_PDB)/flex-xray.pdbqt \
	-nrun $(ASTEX_NRUN) \
	-psize $(ASTEX_POPSIZE) \
	-resnam $(ASTEX_TESTNAME) \
	-gfpop 1 \
	-lsmet $(ASTEX_LS)
247 248

#	$(BIN_DIR)/$(TARGET) -ffile ./input_tsri/search-set-astex/$(ASTEX_PDB)/protein.maps.fld -lfile ./input_tsri/search-set-astex/$(ASTEX_PDB)/flex-xray.pdbqt -nrun $(ASTEX_NRUN) -psize $(ASTEX_POPSIZE) -resnam $(ASTEX_TESTNAME) -gfpop 1 | tee ./input_tsri/search-set-astex/intrapairs/$(ASTEX_PDB)_intrapair.txt
Leonardo Solis's avatar
Leonardo Solis committed
249 250

clean:
251
	rm -f $(BIN_DIR)/* initpop.txt