-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (98 loc) · 4.18 KB
/
Makefile
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
CXX = clang++-3.5
CXXCFLAGS = -std=c++11 -stdlib=libc++ -Wall -Ofast \
-nostdinc++ -I/usr/local/lib/llvm-3.5/include/c++/v1
CXXLDFLAGS = -L lib/libc++/ -stdlib=libc++ \
-lsfml-system-s -lsfml-graphics-s -lboost_program_options-s -ljpeg-s \
-L/usr/local/lib/llvm-3.5/usr/lib
GXX = g++-4.9
GXXCFLAGS = -std=c++11 -Wall -Ofast
GXXLDFLAGS = -L lib/stdlibc++/ \
-lsfml-system-s -lsfml-graphics-s -lboost_program_options-s -ljpeg-s
NVCC = nvcc
NVCCCFLAGS = -Xcompiler -stdlib=libstdc++ -O3
NVCCLDFLAGS = -L lib/stdlibc++/ -Xcompiler -stdlib=libstdc++ \
-lsfml-system-s -lsfml-graphics-s -lboost_program_options-s -ljpeg-s
SERIALCFLAGS =
SERIALLDFLAGS =
CUDACFLAGS = -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA
CUDALDFLAGS =
TBBCFLAGS = -x c++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB \
-I /Developer/NVIDIA/CUDA-6.5/include
TBBLDFLAGS = -ltbb
OMPCFLAGS = -x c++ -fopenmp -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP \
-I /Developer/NVIDIA/CUDA-6.5/include
OMPLDFLAGS = -lgomp
BUILD_DIR = build/
BIN_DIR = bin/
COMMON_DIR = src/common/
SERIAL_DIR = src/serial/
PAR_DIR = src/parallel/
SOURCES_COMMON = main.cpp
SOURCES_SERIAL = Image.cpp Skeleton.cpp
SOURCES_PAR = Image.cu Skeleton.cu
EXECUTABLE_SERIAL = skeleton_serial
EXECUTABLE_CUDA = skeleton_cuda
EXECUTABLE_TBB = skeleton_tbb
EXECUTABLE_OMP = skeleton_omp
SOURCES_COMMON := $(addprefix $(COMMON_DIR)/, $(SOURCES_COMMON))
SOURCES_SERIAL := $(addprefix $(SERIAL_DIR)/, $(SOURCES_SERIAL)) $(SOURCES_COMMON)
SOURCES_PAR := $(addprefix $(PAR_DIR)/, $(SOURCES_PAR)) $(SOURCES_COMMON)
OBJECTS_SERIAL := $(addsuffix .serial.o, $(notdir $(SOURCES_SERIAL)))
OBJECTS_PAR := $(addsuffix .cuda.o, $(notdir $(SOURCES_PAR)))
OBJECTS_TBB := $(addsuffix .tbb.o, $(notdir $(SOURCES_PAR)))
OBJECTS_OMP := $(addsuffix .omp.o, $(notdir $(SOURCES_PAR)))
OBJECTS_SERIAL := $(addprefix $(BUILD_DIR)/, $(OBJECTS_SERIAL))
OBJECTS_PAR := $(addprefix $(BUILD_DIR)/, $(OBJECTS_PAR))
OBJECTS_TBB := $(addprefix $(BUILD_DIR)/, $(OBJECTS_TBB))
OBJECTS_OMP := $(addprefix $(BUILD_DIR)/, $(OBJECTS_OMP))
EXECUTABLES = $(EXECUTABLE_SERIAL) $(EXECUTABLE_CUDA) $(EXECUTABLE_TBB) $(EXECUTABLE_OMP)
## This hack fixes foreach commands below
define \n
endef
all: $(EXECUTABLES)
serial: $(EXECUTABLE_SERIAL)
cuda: $(EXECUTABLE_CUDA)
tbb: $(EXECUTABLE_TBB)
omp: $(EXECUTABLE_OMP)
$(EXECUTABLE_SERIAL): $(OBJECTS_SERIAL)
$(CXX) $(CXXLDFLAGS) $(SERIALLDFLAGS) $(OBJECTS_SERIAL) -o $(BIN_DIR)/$@
$(EXECUTABLE_CUDA): $(OBJECTS_PAR)
$(NVCC) $(NVCCLDFLAGS) $(CUDALDFLAGS) $(OBJECTS_PAR) -o $(BIN_DIR)/$@
$(EXECUTABLE_TBB): $(OBJECTS_TBB)
$(CXX) $(CXXLDFLAGS) $(TBBLDFLAGS) $(OBJECTS_TBB) -o $(BIN_DIR)/$@
$(EXECUTABLE_OMP): $(OBJECTS_OMP)
$(GXX) $(GXXLDFLAGS) $(OMPLDFLAGS) $(OBJECTS_OMP) -o $(BIN_DIR)/$@
$(OBJECTS_SERIAL): $(SOURCES_SERIAL) | dirs
$(foreach file, $?, \
$(CXX) $(CXXCFLAGS) $(SERIALCFLAGS) -I $(COMMON_DIR) -I $(SERIAL_DIR) \
-c $(file) \
-o $(BUILD_DIR)/$(notdir $(addsuffix .serial.o, $(file))) \
${\n} \
)
$(OBJECTS_PAR): $(SOURCES_PAR) | dirs
$(foreach file, $?, \
$(NVCC) $(NVCCCFLAGS) $(CUDACFLAGS) -I $(COMMON_DIR) -I $(PAR_DIR) \
-c $(file) \
-o $(BUILD_DIR)/$(notdir $(addsuffix .cuda.o, $(file))) \
${\n} \
)
$(OBJECTS_TBB): $(SOURCES_PAR) | dirs
$(foreach file, $?, \
$(CXX) $(CXXCFLAGS) $(TBBCFLAGS) -I $(COMMON_DIR) -I $(SERIAL_DIR) \
-c $(file) \
-o $(BUILD_DIR)/$(notdir $(addsuffix .tbb.o, $(file))) \
${\n} \
)
$(OBJECTS_OMP): $(SOURCES_PAR) | dirs
$(foreach file, $?, \
$(GXX) $(GXXCFLAGS) $(OMPCFLAGS) -I $(COMMON_DIR) -I $(SERIAL_DIR) \
-c $(file) \
-o $(BUILD_DIR)/$(notdir $(addsuffix .omp.o, $(file))) \
${\n} \
)
dirs:
mkdir -p $(BUILD_DIR) $(BIN_DIR)
clean:
rm -f $(addprefix $(BIN_DIR)/, $(EXECUTABLES)) $(BUILD_DIR)/*.o
run: $(EXECUTABLES)
./scripts/run.sh