-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathMakefile
286 lines (249 loc) · 6.7 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#===============================================================================
# User Options
#===============================================================================
COMPILER ?= mpi
OPENMP ?= yes
OPTIMIZE ?= yes
DEBUG ?= no
PROFILE ?= no
INFO ?= no
PRECISION ?= single
CMFD_PRECISION ?= single
#===============================================================================
# Source Code List
#===============================================================================
#case = models/load-geometry/load-full-core.cpp
#case = models/load-geometry/load-single-assembly.cpp
#case = models/load-geometry/load-tc-study.cpp
#case = models/load-geometry/load-few-assm.cpp
#case = models/load-geometry/load-2D-full-core.cpp
#case = models/load-geometry/trunc-core-2D.cpp
#case = models/load-geometry/load-corner.cpp
#case = models/load-geometry/load-assembly-lattice.cpp
#case = models/load-geometry/load-geometry.cpp
#case = models/simple-lattice/simple-lattice-3d.cpp
#case = models/homogeneous/homogeneous.cpp
case ?= models/run_time_standard/run_time_standard.cpp
#case ?= models/assembly_1/load-assembly.cpp
#case ?= models/core/load-core.cpp
source = \
Cell.cpp \
Cmfd.cpp \
CPULSSolver.cpp \
CPUSolver.cpp \
ExpEvaluator.cpp \
Geometry.cpp \
LocalCoords.cpp \
linalg.cpp \
log.cpp \
Material.cpp \
Matrix.cpp \
Mesh.cpp \
MOCKernel.cpp \
Point.cpp \
Progress.cpp \
Quadrature.cpp \
Region.cpp \
RunTime.cpp \
Solver.cpp \
Surface.cpp \
Timer.cpp \
Track.cpp \
Track3D.cpp \
TrackGenerator.cpp \
TrackGenerator3D.cpp \
TrackTraversingAlgorithms.cpp \
TraverseSegments.cpp \
Universe.cpp \
Vector.cpp
cases = \
Takeda/Takeda-unrodded.cpp \
pin-cell/pin-cell-3d.cpp \
fixed-source/pin-cell-fixed-3d.cpp \
simple-lattice/simple-lattice-3d.cpp \
gradients/one-directional/one-directional-gradient.cpp \
gradients/two-directional/two-directional-gradient.cpp \
c5g7/c5g7-3d.cpp \
c5g7/c5g7-3d-cmfd.cpp \
c5g7/c5g7-rodded-B.cpp \
c5g7/c5g7-rodded-B-2x2.cpp \
c5g7/c5g7-ws.cpp \
homogeneous/homogeneous.cpp \
single-assembly/quarter-c5g7-assembly.cpp \
single-assembly/single-c5g7-assembly.cpp \
load-geometry/load-geometry.cpp \
load-geometry/load-single-assembly.cpp \
load-geometry/load-2D-full-core.cpp \
load-geometry/load-full-core.cpp
#===============================================================================
# Sets Flags
#===============================================================================
CFLAGS = -std=gnu++0x
# Regular gcc Compiler
ifeq ($(COMPILER),gnu)
CC = gcc
CFLAGS += -DGNU
LDFLAGS += -lm
LDFLAGS += -lstdc++
endif
# MPI wrapped compiler
ifeq ($(COMPILER),mpi)
CC = mpic++
CFLAGS += -DMPIx
LDFLAGS += -lm
LDFLAGS += -lstdc++
endif
# intel Compiler
ifeq ($(COMPILER),intel)
CC = icpc
#source += VectorizedSolver.cpp
CFLAGS += -DINTEL
#CFLAGS += -I/your/path/to/mkl/include
#LDFLAGS += -mkl
endif
# MPI wrapped intel Compiler
ifeq ($(COMPILER),impi)
CC = mpiicpc
CFLAGS += -DINTEL
CFLAGS += -DMPIx
endif
# Clang Compiler
ifeq ($(COMPILER),clang)
CC = clang++
CFLAGS += -DCLANG
endif
# BG/Q gcc Cross-Compiler
# Note: make sure to set +mpiwrapper-gcc in your .soft file,
# as we only support the gcc cross-compiler wrapper
ifeq ($(COMPILER),bluegene)
CC = mpic++
CFLAGS += -DGNU
endif
# Debug Flags
ifeq ($(DEBUG),yes)
CFLAGS += -O0
CFLAGS += -g
CFLAGS += -fno-omit-frame-pointer
else
ifeq ($(COMPILER),gnu)
CFLAGS += -Wno-unused-result
endif
ifeq ($(COMPILER),mpi)
CFLAGS += -Wno-unused-result
endif
endif
# Profiling Flags
ifeq ($(PROFILE),yes)
# pprof flags
CFLAGS += -pg
CFLAGS += -O0
CFLAGS += -fno-omit-frame-pointer
# gprof and vtune flags
#CFLAGS += -g
endif
# Precision Flags
ifeq ($(PRECISION),single)
CFLAGS += -DFP_PRECISION=float
CFLAGS += -DSINGLE
endif
ifeq ($(PRECISION),double)
CFLAGS += -DFP_PRECISION=double
endif
ifeq ($(CMFD_PRECISION),single)
CFLAGS += -DCMFD_PRECISION=float -DLINALG_TOL=1E-7
endif
ifeq ($(CMFD_PRECISION),double)
CFLAGS += -DCMFD_PRECISION=double -DLINALG_TOL=1E-15
endif
# Vector Flags, take into account strip mining with VEC_LENGTH sized vectors
CFLAGS += -DVEC_ALIGNMENT=64
ifeq ($(PRECISION),single)
CFLAGS += -DVEC_LENGTH=8
endif
ifeq ($(PRECISION),double)
CFLAGS += -DVEC_LENGTH=4
endif
# Optimization Flags
ifeq ($(OPTIMIZE),yes)
ifeq ($(COMPILER),gnu)
CFLAGS += -O3 -ffast-math -fpic -march=native #-flto
endif
ifeq ($(COMPILER),mpi)
CFLAGS += -O3 -ffast-math -fpic -march=native #-flto
endif
ifeq ($(COMPILER),intel)
CFLAGS += -O3 -xhost -ansi-alias -no-prec-div #-ipo
endif
ifeq ($(COMPILER),impi)
CFLAGS += -O3 -xhost -ansi-alias -no-prec-div #-ipo
endif
ifeq ($(COMPILER),bluegene)
CFLAGS += -O3 -ffast-math -fpic
endif
ifeq ($(COMPILER),clang)
CFLAGS += -O3 -ffast-math -fvectorize -fpic
endif
# Set the number of groups at compile time
#CFLAGS += -DNGROUPS=70
# Set the source to linear source at compile time
#CFLAGS += -DLINEARSOURCE
# Set the dimension to 3D at compile time
#CFLAGS += -DTHREED
# Only vacuum boundary conditions, avoid double store of track fluxes
#CFLAGS += -DONLYVACUUMBC
endif
# Optimization report flags
ifeq ($(INFO),yes)
ifeq ($(COMPILER),intel)
CFLAGS += -qopt-report n=5 -qopt-report-phase=all
endif
ifeq ($(COMPILER),impi)
CFLAGS += -qopt-report n=5 -qopt-report-phase=all
endif
ifeq ($(COMPILER),gnu)
CFLAGS += -fopt-info-all
endif
ifeq ($(COMPILER),mpi)
CFLAGS += -fopt-info-all
endif
ifeq ($(OPENMP),yes)
CFLAGS += -openmp-report
endif
endif
# OpenMP flags
ifeq ($(OPENMP),yes)
CFLAGS += -fopenmp
CFLAGS += -DOPENMP
endif
CFLAGS += -I../src/
#===============================================================================
# Program Name and Object Files
#===============================================================================
obj := $(source:.cpp=.o)
source := $(addprefix ../src/, $(source))
headers = $(source:.cpp=.h)
obj := $(addprefix obj/, $(obj))
cases := $(addprefix models/, $(cases))
cases += $(case)
programs = $(cases:.cpp=)
program = $(case:.cpp=)
#===============================================================================
# Targets to Build
#===============================================================================
default: folder $(addsuffix .o, $(program)) $(program)
$(programs): $(obj) $(headers) $(addsuffix .o, $(program))
$(CC) $(CFLAGS) $(obj) $(addsuffix .o, $@) -o $@ $(LDFLAGS)
obj/%.o: ../src/%.cpp Makefile
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp Makefile
$(CC) $(CFLAGS) -c $< -o $@
folder:
mkdir -p obj
all: folder $(addsuffix .o, $(programs)) $(programs)
clean:
rm -rf $(program) $(obj) $(addsuffix .o, $(programs))
edit:
vim -p $(case) $(cases)
run:
./$(program)
#mpirun -np 2 ./$(program)