Makefile 2.75 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)
Leonardo Solis's avatar
Leonardo Solis committed
36
37
38
39
40
41

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

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

TARGET := ocladock
BIN := $(wildcard $(TARGET)*)

61
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
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
# Number of work-items (wi)
# Valid values: 16, 32, 64, 128
NWI=

ifeq ($(NWI), 16)
	NWI=-DN16WI
	TARGET:=$(TARGET)_16wi
else ifeq ($(NWI), 32)
	NWI=-DN32WI
	TARGET:=$(TARGET)_32wi
else ifeq ($(NWI), 64)
	NWI=-DN64WI
	TARGET:=$(TARGET)_64wi
else ifeq ($(NWI), 128)
	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

101
# ------------------------------------------------------
Leonardo Solis's avatar
Leonardo Solis committed
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
# 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)
	g++ $(SRC) $(CFLAGS) -lOpenCL -o$(TARGET) $(DEV) $(NWI) $(OPT) $(DD) $(REP) $(KFLAGS)

clean:
	rm -f $(BIN) initpop.txt