-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
231 lines (176 loc) · 5.88 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
##
# Project: HipRMC
#
# File: Makefile
# Created: January 27, 2013
# Modified: Oct 16, 2013
#
# Author: Abhinav Sarje <[email protected]>
##
USE_GPU = n
USE_MPI = y
## base directories
#BOOST_DIR = /usr/local/boost
TIFF_DIR = /lustre/atlas2/mat108/scratch/asarje/opt/tiff-4.0.2
#OPENCV_DIR = /usr
WOO_DIR = /home/asarje
ifeq ($(USE_MPI), y)
#MPI_DIR = /usr/local/openmpi
endif
ifeq ($(USE_GPU), y)
CUDA_DIR = $(CRAY_CUDATOOLKIT_DIR)
FFTW_DIR =
else
CUDA_DIR =
FFTW_DIR = $(CRAY_FFTW_DIR)/interlagos
endif
## compilers
ifeq ($(USE_MPI), y)
CXX = CC
else
CXX = CC
endif
ifeq ($(USE_GPU), y)
NVCC = nvcc
else
NVCC =
endif
## compiler flags
CXX_FLAGS = -std=c++0x -fopenmp -lgomp -lgsl -lgslcblas #-Wall -Wextra #-lgsl -lgslcblas -lm
## gnu c++ compilers >= 4.3 support -std=c++0x [requirement for hipgisaxs 4.3.x <= g++ <= 4.6.x]
## gnu c++ compilers >= 4.7 also support -std=c++11, but they are not supported by cuda
## boost
BOOST_INCL = -I $(BOOST_DIR)/include
BOOST_LIBS = -L $(BOOST_DIR)/lib -lboost_system -lboost_filesystem -lboost_timer -lboost_chrono
## mpi (openmpi)
ifeq ($(USE_MPI), y)
#MPI_INCL = -I $(MPI_DIR)/include
#MPI_LIBS = -L $(MPI_DIR)/lib -lmpi_cxx -lmpi
endif
## cuda
ifeq ($(USE_GPU), y)
CUDA_INCL = -I$(CUDA_DIR)/include
CUDA_LIBS = -L$(CUDA_DIR)/lib64 -lcudart -lcufft -lnvToolsExt
NVCC_FLAGS = -Xcompiler -fPIC -Xcompiler -fopenmp -m 64 #-dc
#NVCC_FLAGS += -gencode arch=compute_20,code=sm_20
#NVCC_FLAGS += -gencode arch=compute_20,code=compute_20
#NVCC_FLAGS += -gencode arch=compute_20,code=sm_21
#NVCC_FLAGS += -gencode arch=compute_30,code=sm_30
NVCC_FLAGS += -gencode arch=compute_35,code=sm_35
#NVCC_FLAGS += -Xptxas -v -Xcompiler -v -Xlinker -v --ptxas-options="-v"
NVLIB_FLAGS = -Xlinker -lgomp
NVLIB_FLAGS += -arch=sm_35 -Wl,-rpath -Wl,$(CUDA_DIR)/lib64
else
CUDA_INCL =
CUDA_LIBS =
NVCC_FLAGS =
endif
## libtiff
TIFF_LIBS = -L $(TIFF_DIR) -ltiff
## opencv
#OPENCV_INCL = -I $(OPENCV_DIR)/include
#OPENCV_LIBS = -L $(OPENCV_DIR)/lib -lopencv_core -lopencv_highgui -lopencv_imgproc
## woo
WOO_INCL = -I $(WOO_DIR)
## fftw
ifeq ($(USE_GPU), y)
FFTW_INCL =
FFTW_LIBS =
else
FFTW_INCL = -I $(FFTW_DIR)/include
FFTW_LIBS = -L $(FFTW_DIR)/lib -lfftw3
endif
## gsl
GSL_INCL = -I $(GSL_DIR)/include
GSL_LIBS = -L $(GSL_DIR)/lib -Wl,--no-as-needed -lgsl -lgslcblas -lm
## miscellaneous
MISC_INCL =
ifeq ($(USE_GPU), y)
MISC_FLAGS = -DUSE_GPU
else
MISC_FLAGS =
endif
MISC_FLAGS += -DUSE_DFT # enable use of quick DFT computation instead of full fft
#MISC_FLAGS += -DUSE_MODEL_INPUT # this enables input to be model and computes fft -- for debug/testing
## choose optimization levels, debug flags, gprof flag, etc
#OPT_FLAGS = -g -DDEBUG #-v #-pg
OPT_FLAGS += -O3 -DNDEBUG #-v
## choose single or double precision here
#PREC_FLAG = # leave empty for single precision
PREC_FLAG = -DDOUBLEP # define this for double precision
ifeq ($(USE_MPI), y)
MPI_FLAG = -DUSE_MPI
endif
## all includes
ALL_INCL = $(OPENCV_INCL) $(WOO_INCL) $(CUDA_INCL) $(FFTW_INCL) $(BOOST_INCL) $(GSL_INCL) $(MPI_INCL)
## all libraries
ALL_LIBS = $(OPENCV_LIBS) $(CUDA_LIBS) $(FFTW_LIBS) $(BOOST_LIBS) $(TIFF_LIBS) $(GSL_LIBS) $(MPI_LIBS)
## all flags
ALL_FLAGS = $(OPT_FLAGS) $(PREC_FLAG) $(MPI_FLAG) $(MISC_FLAGS)
PREFIX = $(PWD)
BINARY_SIM = hiprmc
BIN_DIR = $(PREFIX)/bin
OBJ_DIR = $(PREFIX)/obj
SRC_DIR = $(PREFIX)/src
## all objects
OBJECTS_SIM = hiprmc.o rmc.o tile.o image.o utilities.o tile_scale.o hiprmc_input.o read_oo_input.o \
tile_autotuner.o
ifeq ($(USE_GPU), y)
OBJECTS_SIM += cutile.o
else
OBJECTS_SIM += tile_autotuner.o
endif
## the main binary
OBJ_BIN_SIM = $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS_SIM))
$(BINARY_SIM): $(OBJ_BIN_SIM)
$(CXX) -o $(BIN_DIR)/$@ $^ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_LIBS)
BINARY_SCALE = hiprmc-scale
OBJECTS_SCALE = testscale.o tile.o tile_scale.o utilities.o image.o
OBJ_BIN_SCALE = $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS_SCALE))
$(BINARY_SCALE): $(OBJ_BIN_SCALE)
$(CXX) -o $(BIN_DIR)/$@ $^ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_LIBS)
$(OBJ_DIR)/tile_scale.o: $(SRC_DIR)/tile_scale.cpp $(SRC_DIR)/tile.hpp
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
$(OBJ_DIR)/testscale.o: $(SRC_DIR)/testscale.cpp $(SRC_DIR)/rmc.hpp
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
## c++ compilation
_DEPS_CXX = %.hpp
DEPS_CXX = $(patsubst %,$(SRC_DIR)/%,$(_DEPS_CXX))
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(DEPS_CXX)
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
_DEPS_WIL = wil/%.hpp
DEPS_WIL = $(patsubst %,$(SRC_DIR)/wil/%,$(_DEPS_CXX))
$(OBJ_DIR)/%.o: $(SRC_DIR)/wil/%.cpp $(DEPS_WIL)
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXXX_FLAGS) $(ALL_INCL)
$(OBJ_DIR)/hiprmc.o: $(SRC_DIR)/hiprmc.cpp $(SRC_DIR)/rmc.hpp
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
ifeq ($(USE_GPU), y)
$(OBJ_DIR)/cutile.o: $(SRC_DIR)/tile.cu
$(NVCC) -c $< -o $@ $(ALL_FLAGS) $(NVCC_FLAGS) $(ALL_INCL)
endif
all: $(BINARY_SIM)
## compute fft tool
BINARY_COMPUTE_FFT = compute-fft
OBJECTS_COMPUTE_FFT = generate.o utilities.o image.o
OBJ_BIN_COMPUTE_FFT = $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS_COMPUTE_FFT))
computefft: $(BINARY_COMPUTE_FFT)
$(BINARY_COMPUTE_FFT): $(OBJ_BIN_COMPUTE_FFT)
$(CXX) -o $(BIN_DIR)/$@ $^ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_LIBS)
$(OBJ_DIR)/generate.o: $(SRC_DIR)/generate.cpp
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
BINARY_LOADING = compute-loading
OBJECTS_LOADING = compute_loading.o utilities.o image.o
OBJ_BIN_LOADING = $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS_LOADING))
computeloading: $(BINARY_LOADING)
$(BINARY_LOADING): $(OBJ_BIN_LOADING)
$(CXX) -o $(BIN_DIR)/$@ $^ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_LIBS)
$(OBJ_DIR)/compute_loading.o: $(SRC_DIR)/compute_loading.cpp
$(CXX) -c $< -o $@ $(ALL_FLAGS) $(CXX_FLAGS) $(ALL_INCL)
.PHONY: clean
clean:
rm -f $(OBJ_BIN_SIM) $(BIN_DIR)/$(BINARY_SIM)
.PHONY: cleanall
cleanall:
rm -f $(OBJ_BIN_SIM) $(BIN_DIR)/$(BINARY_SIM) \
$(OBJ_BIN_COMPUTE_FFT) $(BIN_DIR)/$(BINARY_COMPUTE_FFT) \
$(OBJ_BIN_LOADING) $(BIN_DIR)/$(BINARY_LOADING)