-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
223 lines (197 loc) · 5.65 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
CPX_BIN_DIR = bin
BIN_DIR = mg-cfd/bin
OBJ_DIR = obj
SRC_DIR = src
ifdef OP2_INSTALL_PATH
OP2_INC = -I$(OP2_INSTALL_PATH)/c/include
OP2_LIB = -L$(OP2_INSTALL_PATH)/c/lib
endif
ifdef CUDA_INSTALL_PATH
CUDA_INC = -I$(CUDA_INSTALL_PATH)/include
CUDA_LIB = -L$(CUDA_INSTALL_PATH)/lib64
endif
ifdef HDF5_INSTALL_PATH
HDF5_INC = -I$(HDF5_INSTALL_PATH)/include
HDF5_LIB = -L$(HDF5_INSTALL_PATH)/lib
endif
HDF5_LIB += -lhdf5 -lz
PARMETIS_VER=4
ifdef PARMETIS_INSTALL_PATH
PARMETIS_INC = -I$(PARMETIS_INSTALL_PATH)/include
PARMETIS_LIB = -L$(PARMETIS_INSTALL_PATH)/lib
endif
PARMETIS_INC += -DHAVE_PARMETIS
PARMETIS_LIB += -lparmetis -lmetis
ifeq ($(PARMETIS_VER),4)
PARMETIS_INC += -DPARMETIS_VER_4
endif
ifdef PTSCOTCH_INSTALL_PATH
PTSCOTCH_INC = -I$(PTSCOTCH_INSTALL_PATH)/include
PTSCOTCH_LIB = -L$(PTSCOTCH_INSTALL_PATH)/lib
endif
PTSCOTCH_INC += -DHAVE_PTSCOTCH
PTSCOTCH_LIB += -lptscotch -lscotch -lptscotcherr
ifdef PETSC_INSTALL_PATH
PETSC_INC = -I$(PETSC_INSTALL_PATH)/include
PETSC_LIB = -L$(PETSC_INSTALL_PATH)/lib
endif
ifdef DOLFINX_INSTALL_PATH
DOLFINX_INC = -I$(DOLFINX_INSTALL_PATH)/include
DOLFINX_LIB = -L$(DOLFINX_INSTALL_PATH)/lib64
endif
ifdef BOOST_INSTALL_PATH
BOOST_LIB = -L$(BOOST_INSTALL_PATH)/lib
endif
ifdef SQLITE_INSTALL_PATH
SQLITE_INC = -I$(SQLITE_INSTALL_PATH)/include
SQLITE_LIB = -L$(SQLITE_INSTALL_PATH)/lib
endif
ifdef TREETIMER_INSTALL_PATH
TREETIMER_INC = -I$(TREETIMER_INSTALL_PATH)/include/timing_library/interface
TREETIMER_LIB = -L$(TREETIMER_INSTALL_PATH) -ltt
endif
ifdef SIMPIC_INSTALL_PATH
SIMPIC_INC = -I$(SIMPIC_INSTALL_PATH)
SIMPIC_LIB = -L$(SIMPIC_INSTALL_PATH)/libsimpic.a
endif
ifdef FENICS
FENICS_DEF = -Ddeffenics
DOLFINX_LIB += -ldolfinx
FENICS_LIB = $(BIN_DIR)/libdolfinx_cpx.a
PETSC_INC += -DHAVE_PETSC
PETSC_LIB += -lpetsc
BOOST_LIB += -lboost_filesystem -lboost_program_options -lboost_timer
endif
ifdef MGCFD
MGCFD_DEF = -Ddefmgcfd
MG_LIB = $(BIN_DIR)/mgcfd_cpx.a
MG_CUDA_LIB = $(BIN_DIR)/mgcfd_cpx_cuda.a
endif
ifdef SIMPIC
SIMPIC_DEF = -Ddefsimpic
SIMPIC_LIB = $(SIMPIC_INSTALL_PATH)/libsimpic.a
endif
ifdef DEBUG
OPTIMISE := -pg -g -O0
else
OPTIMISE := -O3
endif
#
# Locate MPI compilers:
#
ifdef MPI_INSTALL_PATH
ifneq ("","$(wildcard $(MPI_INSTALL_PATH)/bin/mpicxx)")
MPICPP := $(MPI_INSTALL_PATH)/bin/mpicxx
else
ifneq ("","$(wildcard $(MPI_INSTALL_PATH)/intel64/bin/mpicxx)")
MPICPP := $(MPI_INSTALL_PATH)/intel64/bin/mpicxx
else
MPICPP := mpicxx
endif
endif
ifneq ("","$(wildcard $(MPI_INSTALL_PATH)/bin/mpicc)")
MPICC := $(MPI_INSTALL_PATH)/bin/mpicc
else
ifneq ("","$(wildcard $(MPI_INSTALL_PATH)/intel64/bin/mpicc)")
MPICC := $(MPI_INSTALL_PATH)/intel64/bin/mpicc
else
MPICC := mpicc
endif
endif
else
MPICPP := mpicxx
MPICC := mpicc
endif
ifdef OP2_COMPILER
ifeq ($(COMPILER),)
COMPILER=$(OP2_COMPILER)
endif
endif
ifeq ($(COMPILER),gnu)
CPP := CC
CFLAGS = -fPIC -DUNIX -Wall -Wextra
CPPFLAGS = $(CFLAGS)
OMPFLAGS = -fopenmp
MPIFLAGS = $(CPPFLAGS)
MPICPP = CC
else
ifeq ($(COMPILER),intel)
CPP = icpc
CFLAGS = -DMPICH_IGNORE_CXX_SEEK -inline-forceinline -DVECTORIZE -qopt-report=5
CFLAGS += -restrict
# CFLAGS += -parallel ## This flag intoduces a significant slowdown into 'vec' app
# CFLAGS += -fno-alias ## This flag causes 'vec' app to fail validation, do not enable
CFLAGS += -fmax-errors=1
CPPFLAGS = $(CFLAGS)
OMPFLAGS = -qopenmp
OMPOFFLOAD = -qopenmp
# NVCCFLAGS += -ccbin=$(MPICPP)
MPIFLAGS = $(CPPFLAGS)
ifdef ISET
OPTIMISE += -x$(ISET)
else
OPTIMISE += -xHost
endif
else
ifeq ($(COMPILER),xl)
CPP = xlc++
CFLAGS = -qarch=pwr8 -qtune=pwr8 -qhot
CPPFLAGS = $(CFLAGS)
OMPFLAGS = -qsmp=omp -qthreaded
OMPOFFLOAD = -qsmp=omp -qoffload -Xptxas -v -g1
MPIFLAGS = $(CPPFLAGS)
else
ifeq ($(COMPILER),pgi)
CPP = pgc++
CFLAGS =
CPPFLAGS = $(CFLAGS)
OMPFLAGS = -mp
MPIFLAGS = $(CPPFLAGS)
# NVCCFLAGS += -ccbin=$(MPICPP)
# ACCFLAGS = -acc -Minfo=acc -ta=tesla:cc35 -DOPENACC
# ACCFLAGS = -acc -DOPENACC -Minfo=acc
ACCFLAGS = -v -acc -DOPENACC -Minfo=acc
else
ifeq ($(COMPILER),cray)
CPP = CC
CFLAGS = -h fp3 -h ipa5
CPPFLAGS = $(CFLAGS)
OMPFLAGS = -h omp
MPICPP = CC
MPIFLAGS = $(CPPFLAGS)
else
$(error unrecognised value for COMPILER: $(COMPILER))
endif
endif
endif
endif
endif
ifdef CPP_WRAPPER
CPP := $(CPP_WRAPPER)
endif
ifdef MPICPP_WRAPPER
MPICPP := $(MPICPP_WRAPPER)
endif
all: cpx
parallel: N = $(shell nproc)
parallel:; @$(MAKE) -j$(N) -l$(N) all
## User-friendly wrappers around actual targets:
cpx: $(CPX_BIN_DIR)/cpx_runtime
cpx_cuda: $(CPX_BIN_DIR)/cpx_cuda_runtime
MPI_CPX_MAIN := $(SRC_DIR)/coupler.cpp
## CPX MPI EXECUTABLE
$(CPX_BIN_DIR)/cpx_runtime: $(MPI_CPX_MAIN) $(MG_LIB) $(FENICS_LIB) $(SIMPIC_LIB)
mkdir -p $(CPX_BIN_DIR)
$(MPICPP) $(CPPFLAGS) $(OPTIMISE) $^ $(MG_LIB) $(SIMPIC_LIB) $(MGCFD_LIBS) \
-lm $(OP2_LIB) -lop2_mpi $(PARMETIS_LIB) $(DOLFINX_LIB) $(PETSC_LIB) $(BOOST_LIB)\
$(SQLITE_LIB) $(TREETIMER_INC) $(TREETIMER_LIB) \
$(PTSCOTCH_LIB) $(HDF5_LIB) $(FENICS_DEF) $(SIMPIC_DEF) $(MGCFD_DEF) -o $@
## CPX MPI CUDA EXECUTABLE
$(CPX_BIN_DIR)/cpx_cuda_runtime: $(MPI_CPX_MAIN) $(MG_CUDA_LIB) $(FENICS_LIB) $(SIMPIC_LIB)
mkdir -p $(CPX_BIN_DIR)
$(MPICPP) $(CPPFLAGS) $(OPTIMISE) $^ $(MG_CUDA_LIB) $(SIMPIC_LIB) $(MGCFD_LIBS) \
$(CUDA_LIB) -lcudart $(OP2_LIB) -lop2_mpi_cuda $(PARMETIS_LIB) $(DOLFINX_LIB) $(PETSC_LIB) \
$(SQLITE_LIB) $(TREETIMER_INC) $(TREETIMER_LIB) \
$(PTSCOTCH_LIB) $(HDF5_LIB) $(FENICS_DEF) $(SIMPIC_DEF) -o $@
clean:
rm -f $(CPX_BIN_DIR)/* $(OBJ_DIR)/*