Makefile 2.88 KB
Newer Older
1
2
3
# ocladock Makefile

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

# 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
# ------------------------------------------------------
# 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
	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)
Leonardo Solis's avatar
Leonardo Solis committed
98
99
# Valid values: RELEASE, DEBUG
CONFIG=RELEASE
Leonardo Solis's avatar
Leonardo Solis committed
100

Leonardo Solis's avatar
Leonardo Solis committed
101
ifeq ($(CONFIG),DEBUG)
Leonardo Solis's avatar
Leonardo Solis committed
102
	OPT =-O0 -g3 -Wall
Leonardo Solis's avatar
Leonardo Solis committed
103
else ifeq ($(CONFIG),RELEASE)
Leonardo Solis's avatar
Leonardo Solis committed
104
105
106
107
108
	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