Makefile 3.28 KB
Newer Older
1
# OCLADock Makefile
2
3

# CPU config
4
5
INTEL_INCLUDE_PATH=$(INTELOCLSDKROOT)/include
INTEL_LIBRARY_PATH=$(INTELOCLSDKROOT)
6

7
# AMD GPU config
8
9
AMD_INCLUDE_PATH=$(AMDAPPSDKROOT)/include
AMD_LIBRARY_PATH=$(shell cat /etc/ld.so.conf.d/amdgpu-pro-x86_64.conf)
Leonardo Solis's avatar
Leonardo Solis committed
10

11
12
13
14
# NVIDIA GPU config
NV_INCLUDE_PATH=$(CUDAROOT)/include
NV_INCLUDE_PATH=$(CUDAROOT)/lib64

15
16
# ------------------------------------------------------
# Choose OpenCL device
17
# Valid values: CPU, AMDGPU, NVGPU
18
DEVICE=GPU
19
20
21
22
23

ifeq ($(DEVICE), CPU)
	DEV =-DCPU_DEVICE
	OCLA_INC_PATH=$(INTEL_INCLUDE_PATH)
	OCLA_LIB_PATH=$(INTEL_LIBRARY_PATH)
24
else ifeq ($(DEVICE), AMDGPU)
25
26
27
	DEV =-DGPU_DEVICE
	OCLA_INC_PATH=$(AMD_INCLUDE_PATH)
	OCLA_LIB_PATH=$(AMD_LIBRARY_PATH)
28
29
30
31
else ifeq ($(DEVICE), NVGPU)
	DEV =-DGPU_DEVICE
	OCLA_INC_PATH=$(NV_INCLUDE_PATH)
	OCLA_LIB_PATH=$(NV_LIBRARY_PATH)
32
33
34
endif

# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
35
36
37
# Project directories
# opencl_lvs: wrapper for OpenCL APIs
COMMON_DIR=./common
Leonardo Solis's avatar
Leonardo Solis committed
38
39
OCL_INC_DIR=./wrapcl/inc
OCL_SRC_DIR=./wrapcl/src
Leonardo Solis's avatar
Leonardo Solis committed
40
41
42
HOST_INC_DIR=./host/inc
HOST_SRC_DIR=./host/src
KRNL_DIR=./device
43
KCMN_DIR=$(COMMON_DIR)
44
BIN_DIR=./bin
Leonardo Solis's avatar
Leonardo Solis committed
45
46
47
48
49
50

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

51
52
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
53
54
55
56
57
58
59
60
61
62
63
64
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"
K_NAMES=-DK1=$(K1_NAME) -DK2=$(K2_NAME) -DK3=$(K3_NAME) -DK4=$(K4_NAME)
# Kernel flags
65
KFLAGS=-DKRNL_SOURCE=$(KRNL_DIR)/$(KRNL_MAIN) -DKRNL_DIRECTORY=$(KRNL_DIR) -DKCMN_DIRECTORY=$(KCMN_DIR) $(K_NAMES)
Leonardo Solis's avatar
Leonardo Solis committed
66
67

TARGET := ocladock
68
69
ifeq ($(DEVICE), CPU)
	TARGET:=$(TARGET)_cpu
70
else ifeq ($(DEVICE), AMDGPU)
71
	NWI=-DN64WI
72
73
74
75
	TARGET:=$(TARGET)_amdgpu
else ifeq ($(DEVICE), NVGPU)
	NWI=-DN32WI
	TARGET:=$(TARGET)_nvgpu
76
77
endif

Leonardo Solis's avatar
Leonardo Solis committed
78
79
BIN := $(wildcard $(TARGET)*)

80
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
81
82
# Number of work-items (wi)
# Valid values: 16, 32, 64, 128
83
NUMWI=
Leonardo Solis's avatar
Leonardo Solis committed
84

85
ifeq ($(NUMWI), 16)
Leonardo Solis's avatar
Leonardo Solis committed
86
87
	NWI=-DN16WI
	TARGET:=$(TARGET)_16wi
88
else ifeq ($(NUMWI), 32)
Leonardo Solis's avatar
Leonardo Solis committed
89
90
	NWI=-DN32WI
	TARGET:=$(TARGET)_32wi
91
else ifeq ($(NUMWI), 64)
Leonardo Solis's avatar
Leonardo Solis committed
92
93
	NWI=-DN64WI
	TARGET:=$(TARGET)_64wi
94
else ifeq ($(NUMWI), 128)
Leonardo Solis's avatar
Leonardo Solis committed
95
96
97
98
99
100
	NWI=-DN128WI
	TARGET:=$(TARGET)_128wi
else
	ifeq ($(DEVICE), CPU)
		NWI=-DN16WI
		TARGET:=$(TARGET)_16wi
101
	else ifeq ($(DEVICE), AMDGPU)
Leonardo Solis's avatar
Leonardo Solis committed
102
103
		NWI=-DN64WI
		TARGET:=$(TARGET)_64wi
104
105
106
	else ifeq ($(DEVICE), NVGPU)
		NWI=-DN32WI
		TARGET:=$(TARGET)_32wi
Leonardo Solis's avatar
Leonardo Solis committed
107
108
109
110
111
	endif
endif

# ------------------------------------------------------
# Configuration (Host)
Leonardo Solis's avatar
Leonardo Solis committed
112
113
# Valid values: RELEASE, DEBUG
CONFIG=RELEASE
Leonardo Solis's avatar
Leonardo Solis committed
114

Leonardo Solis's avatar
Leonardo Solis committed
115
ifeq ($(CONFIG),DEBUG)
Leonardo Solis's avatar
Leonardo Solis committed
116
	OPT =-O0 -g3 -Wall
Leonardo Solis's avatar
Leonardo Solis committed
117
else ifeq ($(CONFIG),RELEASE)
Leonardo Solis's avatar
Leonardo Solis committed
118
119
120
121
122
	OPT =-O3
else
	OPT =
endif

123
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Host and Device Debug
DOCK_DEBUG=NO

# Reproduce results (remove randomness)
REPRO=NO

ifeq ($(DOCK_DEBUG),YES)
	DD =-DDOCK_DEBUG
else
	DD =
endif

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

all: odock

145
146
147
148
stringify:
	./stringify_ocl_krnls.sh

odock: stringify $(SRC)
149
	g++ $(SRC) $(CFLAGS) -lOpenCL -o$(BIN_DIR)/$(TARGET) $(DEV) $(NWI) $(OPT) $(DD) $(REP) $(KFLAGS)
Leonardo Solis's avatar
Leonardo Solis committed
150
151

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