Makefile 2.25 KB
Newer Older
Leonardo Solis's avatar
Leonardo Solis committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
101
102
103
104
105
106
107
108
109
110
111
112
# odock Makefile
AMD_INCLUDE_PATH=/opt/AMDAPPSDK-3.0/include
AMD_LIBRARY_PATH=/opt/amdgpu-pro/lib/x86_64-linux-gnu

# 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

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

IFLAGS=-I$(COMMON_DIR) -I$(OCL_INC_DIR) -I$(HOST_INC_DIR) -I$(AMD_INCLUDE_PATH)
LFLAGS=-L$(AMD_LIBRARY_PATH)
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
KFLAGS=-DKRNL_SOURCE=$(KRNL_DIR)/$(KRNL_MAIN) -DKRNL_DIRECTORY=$(KRNL_DIR) $(K_NAMES)

TARGET := ocladock
BIN := $(wildcard $(TARGET)*)
# ------------------------------------------------------
# Choose OpenCL device
# Valid values: CPU, GPU
DEVICE=GPU

ifeq ($(DEVICE), CPU)
	DEV =-DCPU_DEVICE
else ifeq ($(DEVICE), GPU)
	DEV =-DGPU_DEVICE
endif

# 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

# 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