forked from SPECFEM/specfem3d_globe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
371 lines (303 loc) · 9.14 KB
/
Makefile.in
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#=====================================================================
#
# S p e c f e m 3 D G l o b e V e r s i o n 7 . 0
# --------------------------------------------------
#
# Main historical authors: Dimitri Komatitsch and Jeroen Tromp
# Princeton University, USA
# and CNRS / University of Marseille, France
# (there are currently many more authors!)
# (c) Princeton University and CNRS / University of Marseille, April 2014
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#=====================================================================
# @configure_input@
#######################################
FC = @FC@
FCFLAGS = @FCFLAGS@
FC_DEFINE = @FC_DEFINE@
MPIFC = @MPIFC@
MPILIBS = @MPILIBS@
FLAGS_CHECK = @FLAGS_CHECK@
FCFLAGS_f90 = @FCFLAGS_f90@ -I@top_builddir@ -I${SETUP}
FC_MODEXT = @FC_MODEXT@
FC_MODDIR = @FC_MODDIR@
FCCOMPILE_CHECK =@FCENV@ ${FC} ${FCFLAGS} $(FLAGS_CHECK)
MPIFCCOMPILE_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(FLAGS_CHECK)
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = -I${SETUP} @CPPFLAGS@
FCLINK = $(MPIFCCOMPILE_CHECK)
#######################################
####
#### GPU
#### with configure: ./configure --with-cuda=cuda5 CUDA_FLAGS=.. CUDA_LIB=.. CUDA_INC=.. MPI_INC=.. ..
#### with configure: ./configure --with-opencl OCL_GPU_FLAGS=.. OCL_LIB=.. OCL_INC=.. MPI_INC=.. ..
####
#######################################
# Reduce GPU-register pressure by limited the number of thread spread
# (GPU for embedded devices are not powerful enough for big kernels)
# Must match mesh_constants_gpu.h::GPU_ELEM_PER_THREAD
GPU_ELEM_PER_THREAD := 1
##
## CUDA
##
@COND_CUDA_TRUE@CUDA = yes
@COND_CUDA_FALSE@CUDA = no
@COND_CUDA5_TRUE@CUDA5 = yes
@COND_CUDA5_FALSE@CUDA5 = no
CUDA_FLAGS = @CUDA_FLAGS@
CUDA_INC = @CUDA_CPPFLAGS@
CUDA_LINK = @CUDA_LDFLAGS@ @CUDA_LIBS@
CUDA_DEBUG = --cudart=shared
@COND_CUDA_TRUE@NVCC = nvcc
@COND_CUDA_FALSE@NVCC = @CC@
##
## GPU architecture
##
# CUDA architecture / code version
# Fermi: -gencode=arch=compute_10,code=sm_10 not supported
# Tesla (default): -gencode=arch=compute_20,code=sm_20
# Geforce GT 650m: -gencode=arch=compute_30,code=sm_30
# Kepler (cuda5) : -gencode=arch=compute_35,code=sm_35
GENCODE_20 = -gencode=arch=compute_20,code=\"sm_20,compute_20\"
GENCODE_30 = -gencode=arch=compute_30,code=\"sm_30,compute_30\"
GENCODE_35 = -gencode=arch=compute_35,code=\"sm_35,compute_35\"
# CUDA version 5.x
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@GENCODE = $(GENCODE_35)
# CUDA version 4.x
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@GENCODE = $(GENCODE_20)
# CUDA flags and linking
@COND_CUDA_TRUE@NVCC_FLAGS_BASE = $(CUDA_FLAGS) $(CUDA_INC) $(CUDA_DEBUG) $(MPI_INCLUDES)
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCC_FLAGS = $(NVCC_FLAGS_BASE) -dc $(GENCODE)
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@NVCC_FLAGS = $(NVCC_FLAGS_BASE) -DUSE_OLDER_CUDA4_GPU $(GENCODE)
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCCLINK_BASE = $(NVCC) $(CUDA_INC) $(MPI_INCLUDES)
@COND_CUDA_TRUE@@COND_CUDA5_TRUE@NVCCLINK = $(NVCCLINK_BASE) -dlink $(GENCODE)
@COND_CUDA_TRUE@@COND_CUDA5_FALSE@NVCCLINK = $(NVCCLINK_BASE) -DUSE_OLDER_CUDA4_GPU $(GENCODE)
@COND_CUDA_FALSE@NVCC_FLAGS =
@COND_CUDA_FALSE@NVCCLINK = $(NVCC) $(NVCC_FLAGS)
##
## OpenCL
##
@COND_OCL_TRUE@OCL = yes
@COND_OCL_FALSE@OCL = no
OCL_CPU_FLAGS = @OCL_CPU_FLAGS@
OCL_GPU_FLAGS = @OCL_GPU_FLAGS@
OCL_INC = @OCL_CFLAGS@
OCL_LINK = @OCL_LDFLAGS@ @OCL_LIBS@
ifeq ($(OCL), yes)
ifeq ($(CUDA), yes)
GPU_CUDA_AND_OCL = yes
endif
endif
ifeq ($(OCL), no)
ifeq ($(CUDA), no)
NO_GPU = yes
endif
endif
ifneq ($(NO_GPU), yes)
HAS_GPU = yes
endif
## MPI directories for CUDA / OpenCL
MPI_INCLUDES = @MPI_INCLUDES@
#######################################
####
#### VTK
#### with configure: ./configure --enable-vtk ..
####
#######################################
@COND_VTK_TRUE@VTK = yes
@COND_VTK_FALSE@VTK = no
CPPFLAGS += @VTK_INCLUDES@
LDFLAGS += @VTK_LDFLAGS@
MPILIBS += @VTK_LIBS@
#######################################
####
#### ADIOS
#### with configure: ./configure --with-adios ADIOS_CONFIG=..
####
#######################################
@COND_ADIOS_TRUE@ADIOS = yes
@COND_ADIOS_FALSE@ADIOS = no
FCFLAGS += @ADIOS_FCFLAGS@
MPILIBS += @ADIOS_LIBS@
#######################################
####
#### FORCE_VECTORIZATION
#### with configure: ./configure --with-vec ..
####
#######################################
@COND_VECTORIZATION_TRUE@FORCE_VECTORIZATION = yes
@COND_VECTORIZATION_FALSE@FORCE_VECTORIZATION = no
#######################################
####
#### CEM
#### with configure: ./configure --with-cem CEM_LIBS=.. CEM_FCFLAGS=..
####
#######################################
@COND_CEM_TRUE@CEM = yes
@COND_CEM_FALSE@CEM = no
FCFLAGS += @CEM_FCFLAGS@
MPILIBS += @CEM_LIBS@
#######################################
####
#### directories
####
#######################################
## compilation directories
# B : build directory
B = @top_builddir@
# E : executables directory
E = $B/bin
# O : objects directory
O = $B/obj
# S_TOP : source file root directory
S_TOP = @top_srcdir@
# setup file directory
SETUP = $B/setup
# output file directory
OUTPUT = $B/OUTPUT_FILES
#######################################
####
#### targets
####
#######################################
# code subdirectories
SUBDIRS = \
shared \
create_header_file \
meshfem3D \
specfem3D \
auxiliaries \
tomography/postprocess_sensitivity_kernels \
tomography \
$(EMPTY_MACRO)
ifeq ($(HAS_GPU),yes)
SUBDIRS := gpu $(SUBDIRS)
endif
# default targets
DEFAULT = \
xcreate_header_file \
xmeshfem3D \
xspecfem3D \
xcombine_AVS_DX \
xcombine_surf_data \
xcombine_vol_data \
xcombine_vol_data_vtk \
xconvolve_source_timefunction \
xcreate_movie_AVS_DX \
xcreate_movie_GMT_global \
$(EMPTY_MACRO)
ifeq ($(ADIOS), yes)
DEFAULT += \
xcombine_vol_data_adios \
xcombine_vol_data_vtk_adios \
$(EMPTY_MACRO)
endif
all: default aux movies postprocess tomography
default: $(DEFAULT)
ifdef CLEAN
clean:
@echo "cleaning by CLEAN"
-rm -f $(foreach dir, $(CLEAN), $($(dir)_OBJECTS) $($(dir)_MODULES) $($(dir)_SHARED_OBJECTS) $($(dir)_TARGETS))
else
clean:
@echo "cleaning all"
-rm -f $(foreach dir, $(SUBDIRS), $($(dir)_OBJECTS) $($(dir)_MODULES) $($(dir)_TARGETS)) $O/*
endif
realclean: clean
mrproper: clean
help:
@echo "usage: make [executable]"
@echo ""
@echo "supported main executables:"
@echo " xmeshfem3D"
@echo " xspecfem3D"
@echo ""
@echo "defaults:"
@echo " xcreate_header_file"
@echo " xmeshfem3D"
@echo " xspecfem3D"
@echo " xcombine_AVS_DX"
@echo " xcombine_surf_data"
@echo " xcombine_vol_data"
@echo " xcombine_vol_data_vtk"
@echo " xconvolve_source_timefunction"
@echo " xcreate_movie_AVS_DX"
@echo " xcreate_movie_GMT_global"
@echo ""
@echo "additional executables:"
@echo "- auxiliary executables: [make aux]"
@echo " xcombine_vol_data"
@echo " xcombine_vol_data_vtk"
ifeq ($(ADIOS), yes)
@echo " xcombine_vol_data_adios"
@echo " xcombine_vol_data_vtk_adios"
endif
@echo " xcombine_surf_data"
@echo " xcombine_AVS_DX"
@echo " xconvolve_source_timefunction"
@echo ""
@echo "- movie executables: [make movies]"
@echo " xcreate_movie_AVS_DX"
@echo " xcreate_movie_GMT_global"
@echo " xcombine_paraview_strain_data"
@echo ""
@echo "- sensitivity kernel postprocessing tools: [make postprocess]"
@echo " xaddition_sem"
@echo " xclip_sem"
@echo " xcombine_sem"
@echo " xdifference_sem"
@echo " xinterpolate_model"
@echo " xsmooth_sem"
ifeq ($(ADIOS), yes)
@echo " xconvert_model_file_adios"
endif
@echo ""
@echo "- tomography tools: [make tomography]"
@echo " xadd_model_iso"
@echo " xadd_model_tiso"
@echo " xadd_model_tiso_cg"
@echo " xadd_model_tiso_iso"
@echo " xsum_kernels"
@echo " xsum_preconditioned_kernels"
@echo ""
.PHONY: all default clean help
#######################################
# Get dependencies and rules for building stuff
include $(patsubst %, ${S_TOP}/src/%/rules.mk, $(SUBDIRS))
#######################################
##
## Shortcuts
##
# Shortcut for: <prog>/<xprog> -> bin/<xprog>
define target_shortcut
$(patsubst $E/%, %, $(1)): $(1)
.PHONY: $(patsubst $E/%, %, $(1))
$(patsubst $E/x%, %, $(1)): $(1)
.PHONY: $(patsubst $E/x%, %, $(1))
endef
# Shortcut for: dir -> src/dir/<targets in here>
define shortcut
$(1): $($(1)_TARGETS)
.PHONY: $(1)
$$(foreach target, $$(filter $E/%,$$($(1)_TARGETS)), $$(eval $$(call target_shortcut,$$(target))))
endef
$(foreach dir, $(SUBDIRS), $(eval $(call shortcut,$(dir))))
# Other old shortcuts
mesh: $E/xmeshfem3D
spec: $E/xspecfem3D
.PHONY: mesh spec