forked from soamaven/S4
-
Notifications
You must be signed in to change notification settings - Fork 22
/
MakefileHPC
251 lines (215 loc) · 8.13 KB
/
MakefileHPC
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
# to find path to openmpi, type mpiexec --test , the error messege reveals path
MKL_HOME = /apps/cent7/intel/compilers_and_libraries_2017.1.132/linux/mkl
BROWN_MPI_HOME = /apps/brown/openmpi/2.1.0/gcc-5.2.0
SNYDER_MPI_HOME = /apps/snyder7/openmpi/2.1.0_gcc-5.2.0
MPI_HOME = $(SNYDER_MPI_HOME)
BLAS_LIB = -L$(MKL_HOME)/lib/intel64 -Wl,-rpath=$(MKL_HOME)/lib/intel64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp
LAPACK_LIB = -L$(MKL_HOME)/lib/intel64 -Wl,-rpath=$(MKL_HOME)/lib/intel64 -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core
EXTRA_FLAGS = '-Wl,-rpath=$(MKL_HOME)/lib/intel64' , '-Wl,-rpath=$(MPI_HOME)/lib'
EXTRA_DIRS = '$(MKL_HOME)/lib/intel64' , '$(MPI_HOME)/lib'
#BLAS_LIB = -lblas
#LAPACK_LIB = -llapack
# OPTIONAL
# Typically if installed,
# FFTW3_INC can be left empty
# FFTW3_LIB = -lfftw3
# or, if Fedora and/or fftw is version 3 but named fftw rather than fftw3
# FTW3_LIB = -lfftw
# May need to link libraries properly as with blas and lapack above
FFTW3_INC = -I$(MLK_HOME)/include/fftw/
FFTW3_LIB = $(BLAS_LIB)
# Typically,
# PTHREAD_INC = -DHAVE_UNISTD_H
# PTHREAD_LIB = -lpthread
PTHREAD_INC = -DHAVE_UNISTD_H
PTHREAD_LIB = -lpthread
# OPTIONAL
# If not installed:
# Fedora: dnf install libsuitsparse-devel
# Typically, if installed:
#CHOLMOD_INC = -I/usr/include/suitesparse
#CHOLMOD_LIB = -lcholmod -lamd -lcolamd -lcamd -lccolamd
#CHOLMOD_INC = -I/usr/include/suitesparse
#CHOLMOD_LIB = -lcholmod -lamd -lcolamd -lcamd -lccolamd
# Specify the MPI library
# For example, on Fedora: dnf install openmpi-devel
#MPI_INC = -I/usr/include/openmpi-x86_64/openmpi/ompi
#MPI_LIB = -lmpi
# or, explicitly link to the library with -L, example below
MPI_LIB = -L$(MPI_HOME)/lib -Wl,-rpath=$(MPI_HOME)/lib -lmpi
MPI_INC = -I$(MPI_HOME)/include
#MPI_LIB = -L/usr/lib64/openmpi/lib/libmpi.so
# Specify custom compilers if needed
CXX = $(MPI_HOME)/bin/mpic++
CC = $(MPI_HOME)/bin/mpicc
#CFLAGS += -O3 -fPIC
CFLAGS = -O3 -msse3 -msse2 -msse -fPIC
# options for Sampler module
OPTFLAGS = -O3
OBJDIR = ./build
S4_BINNAME = $(OBJDIR)/S4
S4_LIBNAME = $(OBJDIR)/libS4.a
S4r_LIBNAME = $(OBJDIR)/libS4r.a
##################### DO NOT EDIT BELOW THIS LINE #####################
#### Set the compilation flags
CPPFLAGS = -I. -IS4 -IS4/RNP -IS4/kiss_fft
ifdef BLAS_LIB
CPPFLAGS += -DHAVE_BLAS
endif
ifdef LAPACK_LIB
CPPFLAGS += -DHAVE_LAPACK
endif
ifdef FFTW3_LIB
CPPFLAGS += -DHAVE_FFTW3 $(FFTW3_INC)
endif
ifdef PTHREAD_LIB
CPPFLAGS += -DHAVE_LIBPTHREAD $(PTHREAD_INC)
endif
ifdef CHOLMOD_LIB
CPPFLAGS += -DHAVE_LIBCHOLMOD $(CHOLMOD_INC)
endif
ifdef MPI_LIB
CPPFLAGS += -DHAVE_MPI $(MPI_INC)
endif
LIBS = $(BLAS_LIB) $(LAPACK_LIB) $(FFTW3_LIB) $(PTHREAD_LIB) $(CHOLMOD_LIB) $(MPI_LIB)
#### Compilation targets
all: $(S4_LIBNAME)
objdir:
mkdir -p $(OBJDIR)
mkdir -p $(OBJDIR)/S4k
mkdir -p $(OBJDIR)/S4r
mkdir -p $(OBJDIR)/modules
S4_LIBOBJS = \
$(OBJDIR)/S4k/S4.o \
$(OBJDIR)/S4k/rcwa.o \
$(OBJDIR)/S4k/fmm_common.o \
$(OBJDIR)/S4k/fmm_FFT.o \
$(OBJDIR)/S4k/fmm_kottke.o \
$(OBJDIR)/S4k/fmm_closed.o \
$(OBJDIR)/S4k/fmm_PolBasisNV.o \
$(OBJDIR)/S4k/fmm_PolBasisVL.o \
$(OBJDIR)/S4k/fmm_PolBasisJones.o \
$(OBJDIR)/S4k/fmm_experimental.o \
$(OBJDIR)/S4k/fft_iface.o \
$(OBJDIR)/S4k/pattern.o \
$(OBJDIR)/S4k/intersection.o \
$(OBJDIR)/S4k/predicates.o \
$(OBJDIR)/S4k/numalloc.o \
$(OBJDIR)/S4k/gsel.o \
$(OBJDIR)/S4k/sort.o \
$(OBJDIR)/S4k/kiss_fft.o \
$(OBJDIR)/S4k/kiss_fftnd.o \
$(OBJDIR)/S4k/SpectrumSampler.o \
$(OBJDIR)/S4k/cubature.o \
$(OBJDIR)/S4k/Interpolator.o \
$(OBJDIR)/S4k/convert.o
S4r_LIBOBJS = \
$(OBJDIR)/S4r/Material.o \
$(OBJDIR)/S4r/LatticeGridRect.o \
$(OBJDIR)/S4r/LatticeGridArb.o \
$(OBJDIR)/S4r/POFF2Mesh.o \
$(OBJDIR)/S4r/PeriodicMesh.o \
$(OBJDIR)/S4r/Shape.o \
$(OBJDIR)/S4r/Simulation.o \
$(OBJDIR)/S4r/Layer.o \
$(OBJDIR)/S4r/Pseudoinverse.o \
$(OBJDIR)/S4r/Eigensystems.o \
$(OBJDIR)/S4r/IRA.o \
$(OBJDIR)/S4r/intersection.o \
$(OBJDIR)/S4r/predicates.o \
$(OBJDIR)/S4r/periodic_off2.o
ifndef LAPACK_LIB
S4_LIBOBJS += $(OBJDIR)/S4k/Eigensystems.o
endif
$(S4_LIBNAME): objdir $(S4_LIBOBJS)
$(AR) crvs $@ $(S4_LIBOBJS)
$(S4r_LIBNAME): objdir $(S4r_LIBOBJS)
$(AR) crvs $@ $(S4r_LIBOBJS)
$(OBJDIR)/S4k/S4.o: S4/S4.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/rcwa.o: S4/rcwa.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_common.o: S4/fmm/fmm_common.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_FFT.o: S4/fmm/fmm_FFT.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_kottke.o: S4/fmm/fmm_kottke.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_closed.o: S4/fmm/fmm_closed.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_PolBasisNV.o: S4/fmm/fmm_PolBasisNV.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_PolBasisVL.o: S4/fmm/fmm_PolBasisVL.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_PolBasisJones.o: S4/fmm/fmm_PolBasisJones.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fmm_experimental.o: S4/fmm/fmm_experimental.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/fft_iface.o: S4/fmm/fft_iface.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/pattern.o: S4/pattern/pattern.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/intersection.o: S4/pattern/intersection.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/predicates.o: S4/pattern/predicates.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/numalloc.o: S4/numalloc.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/gsel.o: S4/gsel.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/sort.o: S4/sort.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/kiss_fft.o: S4/kiss_fft/kiss_fft.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/kiss_fftnd.o: S4/kiss_fft/tools/kiss_fftnd.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/SpectrumSampler.o: S4/SpectrumSampler.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/cubature.o: S4/cubature.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/Interpolator.o: S4/Interpolator.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/convert.o: S4/convert.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4k/Eigensystems.o: S4/RNP/Eigensystems.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4r/Material.o: S4r/Material.cpp S4r/Material.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/LatticeGridRect.o: S4r/LatticeGridRect.cpp S4r/PeriodicMesh.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/LatticeGridArb.o: S4r/LatticeGridArb.cpp S4r/PeriodicMesh.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/POFF2Mesh.o: S4r/POFF2Mesh.cpp S4r/PeriodicMesh.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/PeriodicMesh.o: S4r/PeriodicMesh.cpp S4r/PeriodicMesh.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/Shape.o: S4r/Shape.cpp S4r/Shape.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/Simulation.o: S4r/Simulation.cpp S4r/Simulation.hpp S4r/StarProduct.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/Layer.o: S4r/Layer.cpp S4r/Layer.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/Pseudoinverse.o: S4r/Pseudoinverse.cpp S4r/Pseudoinverse.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/Eigensystems.o: S4r/Eigensystems.cpp S4r/Eigensystems.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/IRA.o: S4r/IRA.cpp S4r/IRA.hpp S4r/Types.hpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) -I. $< -o $@
$(OBJDIR)/S4r/intersection.o: S4r/intersection.c S4r/intersection.h
$(CC) -c -O3 $< -o $@
$(OBJDIR)/S4r/periodic_off2.o: S4r/periodic_off2.c S4r/periodic_off2.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR)/S4r/predicates.o: S4r/predicates.c
$(CC) -c -O3 $< -o $@
#### Python extension
check:
@echo $(LIBS)
S4_pyext: objdir $(S4_LIBNAME)
echo "Linking...."
echo $(EXTRA_FLAGS) $(EXTRA_DIRS)
sh gensetupHPC.py.sh $(OBJDIR) $(S4_LIBNAME) "$(LIBS)" "$(EXTRA_FLAGS)" "$(EXTRA_DIRS)"
python setup.py build
#pip3 install --upgrade ./
clean:
rm S4.so
rm -rf $(OBJDIR)