Makefile 2.9 KB
Newer Older
1
2
3
4
5
6
7
# ocladock Makefile

# CPU config
INTEL_INCLUDE_PATH=/opt/intel/opencl-1.2-sdk-6.0.0.1049/include
INTEL_LIBRARY_PATH=/opt/intel/opencl-1.2-sdk-6.0.0.1049/

# GPU config
Leonardo Solis's avatar
Leonardo Solis committed
8
9
10
AMD_INCLUDE_PATH=/opt/AMDAPPSDK-3.0/include
AMD_LIBRARY_PATH=/opt/amdgpu-pro/lib/x86_64-linux-gnu

11
12
13
# ------------------------------------------------------
# Choose OpenCL device
# Valid values: CPU, GPU
14
DEVICE=GPU
15
16
17
18
19
20
21
22
23
24
25
26

ifeq ($(DEVICE), CPU)
	DEV =-DCPU_DEVICE
	OCLA_INC_PATH=$(INTEL_INCLUDE_PATH)
	OCLA_LIB_PATH=$(INTEL_LIBRARY_PATH)
else ifeq ($(DEVICE), GPU)
	DEV =-DGPU_DEVICE
	OCLA_INC_PATH=$(AMD_INCLUDE_PATH)
	OCLA_LIB_PATH=$(AMD_LIBRARY_PATH)
endif

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

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

43
44
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
45
46
47
48
49
50
51
52
53
54
55
56
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
57
KFLAGS=-DKRNL_SOURCE=$(KRNL_DIR)/$(KRNL_MAIN) -DKRNL_DIRECTORY=$(KRNL_DIR) -DKCMN_DIRECTORY=$(KCMN_DIR) $(K_NAMES)
Leonardo Solis's avatar
Leonardo Solis committed
58
59

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

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

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

74
ifeq ($(NUMWI), 16)
Leonardo Solis's avatar
Leonardo Solis committed
75
76
	NWI=-DN16WI
	TARGET:=$(TARGET)_16wi
77
else ifeq ($(NUMWI), 32)
Leonardo Solis's avatar
Leonardo Solis committed
78
79
	NWI=-DN32WI
	TARGET:=$(TARGET)_32wi
80
else ifeq ($(NUMWI), 64)
Leonardo Solis's avatar
Leonardo Solis committed
81
82
	NWI=-DN64WI
	TARGET:=$(TARGET)_64wi
83
else ifeq ($(NUMWI), 128)
Leonardo Solis's avatar
Leonardo Solis committed
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
	NWI=-DN128WI
	TARGET:=$(TARGET)_128wi
else
	ifeq ($(DEVICE), CPU)
		NWI=-DN16WI
		TARGET:=$(TARGET)_16wi
	else ifeq ($(DEVICE), GPU)
		NWI=-DN64WI
		TARGET:=$(TARGET)_64wi
	endif
endif

# ------------------------------------------------------
# Configuration (Host)
# Valid values: release, debug
CONFIG=release

ifeq ($(CONFIG),debug)
	OPT =-O0 -g3 -Wall
else ifeq ($(CONFIG),release)
	OPT =-O3
else
	OPT =
endif

109
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# 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

odock: $(SRC)
132
	g++ $(SRC) $(CFLAGS) -lOpenCL -o$(BIN_DIR)/$(TARGET) $(DEV) $(NWI) $(OPT) $(DD) $(REP) $(KFLAGS)
Leonardo Solis's avatar
Leonardo Solis committed
133
134

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