-
Notifications
You must be signed in to change notification settings - Fork 40
/
makefile.windows
386 lines (296 loc) · 12.1 KB
/
makefile.windows
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# Makefile for FMM3D
# # This is the only makefile; there are no makefiles in subdirectories.
# Users should not need to edit this makefile (doing so would make it
# hard to stay up to date with repo version). Rather in order to
# change OS\environment-specific compilers and flags, create
# the file make.inc, which overrides the defaults below (which are
# for ubunutu linux\gcc system).
# compiler, and linking from C, fortran
CC=gcc
CXX=g++
FC=gfortran
FFLAGS= -fPIC -O3 -funroll-loops -std=legacy
CFLAGS= -std=c99
CFLAGS+= $(FFLAGS)
CXXFLAGS= -std=c++11 -DSCTL_PROFILE=-1
CXXFLAGS+=$(FFLAGS)
CLIBS = -lgfortran -lquadmath -lm
LIBS = -lm
# extra flags for multithreaded: C\Fortran, MATLAB
OMPFLAGS =-fopenmp
OMPLIBS =-lgomp
# flags for MATLAB MEX compilation..
MFLAGS=-compatibleArrayDims -DMWF77_UNDERSCORE1
MWFLAGS=-c99complex
MOMPFLAGS = -D_OPENMP
# location of MATLAB's mex compiler
MEX=mex
# For experts, location of Mwrap executable
MWRAP=..\..\mwrap\mwrap
MINGW_LPATH=C:\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0
MEXLIBS = -lmex -lmat -lmx -lgfortran -lquadmath -L${MINGW_LPATH}
ifeq ($(FAST_KER),ON)
LIBS += -lstdc++
CLIBS += -lstdc++
OMP = ON
endif
# multi-threaded libs & flags needed
ifeq ($(OMP),ON)
CFLAGS += $(OMPFLAGS)
FFLAGS += $(OMPFLAGS)
MFLAGS += $(MOMPFLAGS)
LIBS += $(OMPLIBS)
MEXLIBS += $(OMPLIBS)
endif
LIBNAME=libfmm3d
DYNAMICLIB = $(LIBNAME).dll
LLIB = $(LIBNAME)_dll.lib
STATICLIB = $(LIBNAME).a
# vectorized kernel directory
SRCDIR = .\vec-kernels\src
INCDIR = .\vec-kernels\include
LIBDIR = lib-static
# objects to compile
#
# Common objects
COM = src\Common
COMOBJS = $(COM)\besseljs3d.o $(COM)\cdjseval3d.o $(COM)\dfft.o \
$(COM)\fmmcommon.o $(COM)\legeexps.o $(COM)\prini.o \
$(COM)\rotgen.o $(COM)\rotproj.o $(COM)\rotviarecur.o \
$(COM)\tree_lr_3d.o $(COM)\yrecursion.o
# Helmholtz objects
HELM = src\Helmholtz
HOBJS = $(HELM)\h3dcommon.o $(HELM)\h3dterms.o $(HELM)\h3dtrans.o \
$(HELM)\helmrouts3d.o $(HELM)\hfmm3d.o $(HELM)\hfmm3dwrap.o \
$(HELM)\hfmm3dwrap_legacy.o $(HELM)\hfmm3dwrap_vec.o $(HELM)\hpwrouts.o \
$(HELM)\hwts3e.o $(HELM)\hnumphys.o $(HELM)\hnumfour.o $(HELM)\projections.o \
$(HELM)\hfmm3d_mps.o
# Laplace objects
LAP = src\Laplace
LOBJS = $(LAP)\lwtsexp_sep1.o $(LAP)\l3dterms.o $(LAP)\l3dtrans.o \
$(LAP)\laprouts3d.o $(LAP)\lfmm3d.o $(LAP)\lfmm3dwrap.o \
$(LAP)\lfmm3dwrap_legacy.o $(LAP)\lfmm3dwrap_vec.o $(LAP)\lwtsexp_sep2.o \
$(LAP)\lpwrouts.o
ifneq ($(FAST_KER),ON)
LOBJS += $(LAP)\lapkernels.o
LOBJS += $(LAP)\lndiv.o
HOBJS += $(HELM)\helmkernels.o
HOBJS += $(HELM)\hndiv.o
endif
ifeq ($(FAST_KER),ON)
LOBJS += $(LAP)\lapkernels_fast.o
LOBJS += $(LAP)\lndiv_fast.o
HOBJS += $(HELM)\helmkernels_fast.o
HOBJS += $(HELM)\hndiv_fast.o
COMOBJS+= $(SRCDIR)\libkernels.o
endif
# Test objects
TOBJS = $(COM)\hkrand.o $(COM)\dlaran.o
# C Headers and objects
COBJS = c\cprini.o c\utils.o
CHEADERS = c\cprini.h c\utils.h c\hfmm3d_c.h c\lfmm3d_c.h
OBJS = $(COMOBJS) $(HOBJS) $(LOBJS)
.PHONY: usage lib examples test test-ext python all c c-examples matlab python3 big-test pw-test debug
default: usage
##all: cxxkernel lib examples test python python3 c c-examples matlab
cxxkernel: $(CXXOBJ)
$(SRCDIR)\libkernels.o: $(SRCDIR)\libkernels.cpp
$(CXX) $(CXXFLAGS) -I$(INCDIR) -c $^ -o $@
usage:
@echo "Makefile for FMM3D. Specify what to make:"
@echo " make lib - compile the main library (in lib\ and lib-static\)"
@echo " make examples - compile and run fortran examples in examples\"
@echo " make c-examples - compile and run c examples in c\"
@echo " make test - compile and run validation tests (will take around 30 secs)"
@echo " make matlab - compile matlab interfaces"
@echo " make mex - generate matlab interfaces (for expert users only, requires mwrap)"
@echo " make python - compile and test python interfaces"
@echo " make python3 - compile and test python interfaces using python3"
@echo " make objclean - removal all object files, preserving lib & MEX"
@echo " make clean - also remove lib, MEX, py, and demo executables"
@echo "For faster (multicore) making, append the flag -j"
@echo " 'make [task] OMP=ON' for multi-threaded"
@echo " 'make [task] FAST_KER=ON' for using vectorized kernel evaluation and multi-threaded (needs c++)"
# implicit rules for objects (note -o ensures writes to correct dir)
%.o: %.cpp %.h
$(CXX) -c $(CXXFLAGS) $< -o $@
%.o: %.c %.h
$(CC) -c $(CFLAGS) $< -o $@
%.o: %.f %.h
$(FC) -c $(FFLAGS) $< -o $@
%.o: %.f90
$(FC) -c $(FFLAGS) $< -o $@
# build the library...
lib: $(STATICLIB) $(DYNAMICLIB)
ifeq ($(OMP),ON)
@echo "$(STATICLIB) and $(DYNAMICLIB) built, multithread versions"
else
@echo "$(STATICLIB) and $(DYNAMICLIB) built, single-threaded versions"
endif
$(STATICLIB): $(OBJS)
ar rcs $(STATICLIB) $(OBJS)
move $(STATICLIB) lib-static/
$(DYNAMICLIB): $(OBJS)
$(FC) -shared -fPIC $(OMPFLAGS) $(OBJS) -o $(DYNAMICLIB) $(LIBS) -Wl,--out-implib,$(LLIB)
move $(DYNAMICLIB) lib/
move $(LLIB) lib/
# matlab..
MWRAPFILE = fmm3d
MWRAPFILE2 = fmm3d_legacy
GATEWAY = $(MWRAPFILE)
GATEWAY2 = $(MWRAPFILE2)
matlab: $(STATICLIB) matlab\$(GATEWAY).c matlab\$(GATEWAY2).c
$(MEX) matlab\$(GATEWAY).c $(STATICLIB) $(MFLAGS) -output matlab\fmm3d $(MEXLIBS)
$(MEX) matlab\$(GATEWAY2).c $(STATICLIB) $(MFLAGS) -output matlab\fmm3d_legacy $(MEXLIBS)
mex: $(STATICLIB)
cd matlab; $(MWRAP) $(MWFLAGS) -list -mex $(GATEWAY) -mb $(MWRAPFILE).mw;\
$(MWRAP) $(MWFLAGS) -mex $(GATEWAY) -c $(GATEWAY).c $(MWRAPFILE).mw;\
$(MEX) $(GATEWAY).c ..\$(STATICLIB) $(MFLAGS) -output $(MWRAPFILE) $(MEXLIBS); \
$(MWRAP) $(MWFLAGS) -list -mex $(GATEWAY2) -mb $(MWRAPFILE2).mw;\
$(MWRAP) $(MWFLAGS) -mex $(GATEWAY2) -c $(GATEWAY2).c $(MWRAPFILE2).mw;\
$(MEX) $(GATEWAY2).c ..\$(STATICLIB) $(MFLAGS) -output $(MWRAPFILE2) $(MEXLIBS);
#python
python: $(STATICLIB)
cd python && export FLIBS='$(LIBS)' && pip install -e . && cd test && pytest -s
#python
python3: $(STATICLIB)
cd python && export FLIBS='$(LIBS)' && pip3 install -e . && cd test && python3 -m pytest -s
# testing routines
#
THDIR = test\Helmholtz
TLDIR = test\Laplace
test: $(STATICLIB) $(TOBJS) test\helmrouts test\hfmm3d test\hfmm3d_vec test\hfmm3d_scale test\laprouts test\lfmm3d test\lfmm3d_vec test_hfmm3d_mps test\lfmm3d_scale
del -f print_testres.txt
$(THDIR)\int2-test-helmrouts3d
$(THDIR)\int2-test-hfmm3d
$(THDIR)\int2-test-hfmm3d-scale
$(THDIR)\int2-test-hfmm3d-vec
$(THDIR)\int2-test-hfmm3d-mps
move print_testres.txt print_testreshelm.txt
del -rf fort.13
del -rf print_testres.txt
$(TLDIR)\int2-test-laprouts3d
$(TLDIR)\int2-test-lfmm3d
$(TLDIR)\int2-test-lfmm3d-scale
$(TLDIR)\int2-test-lfmm3d-vec
move print_testres.txt print_testreslap.txt
del -rf fort.13
type print_testreshelm.txt
type print_testreslap.txt
del print_testreshelm.txt
del print_testreslap.txt
test-ext: $(STATICLIB) $(TOBJS) test\helmrouts test\hfmm3d test\hfmm3d_vec test\hfmm3d_zkbig test\hfmm3d_scale test\laprouts test\lfmm3d test\lfmm3d_vec test_hfmm3d_mps test\lfmm3d_scale
del -f print_testres.txt
$(THDIR)\int2-test-helmrouts3d
$(THDIR)\int2-test-hfmm3d
$(THDIR)\int2-test-hfmm3d-zkbig
$(THDIR)\int2-test-hfmm3d-scale
$(THDIR)\int2-test-hfmm3d-vec
$(THDIR)\int2-test-hfmm3d-mps
move print_testres.txt print_testreshelm.txt
del -rf fort.13
del -rf print_testres.txt
$(TLDIR)\int2-test-laprouts3d
$(TLDIR)\int2-test-lfmm3d
$(TLDIR)\int2-test-lfmm3d-scale
$(TLDIR)\int2-test-lfmm3d-vec
move print_testres.txt print_testreslap.txt
del -rf fort.13
type print_testreshelm.txt
type print_testreslap.txt
del print_testreshelm.txt
del print_testreslap.txt
test\helmrouts:
$(FC) $(FFLAGS) test\Helmholtz\test_helmrouts3d.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\int2-test-helmrouts3d $(LIBS)
test\hfmm3d:
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\int2-test-hfmm3d $(LIBS)
test\hfmm3d_zkbig:
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d_zkbig.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\int2-test-hfmm3d-zkbig $(LIBS)
test\hfmm3d_scale:
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d_scale.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\int2-test-hfmm3d-scale $(LIBS)
test\hfmm3d_vec:
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d_vec.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\int2-test-hfmm3d-vec $(LIBS)
test\laprouts:
$(FC) $(FFLAGS) test\Laplace\test_laprouts3d.f $(TOBJS) $(COMOBJS) $(LOBJS) -o test\Laplace\int2-test-laprouts3d $(LIBS)
test\lfmm3d:
$(FC) $(FFLAGS) test\Laplace\test_lfmm3d.f $(TOBJS) $(COMOBJS) $(LOBJS) -o test\Laplace\int2-test-lfmm3d $(LIBS)
test\lfmm3d_scale:
$(FC) $(FFLAGS) test\Laplace\test_lfmm3d_scale.f $(TOBJS) $(COMOBJS) $(LOBJS) -o test\Laplace\int2-test-lfmm3d-scale $(LIBS)
test\lfmm3d_vec:
$(FC) $(FFLAGS) test\Laplace\test_lfmm3d_vec.f $(TOBJS) $(COMOBJS) $(LOBJS) -o test\Laplace\int2-test-lfmm3d-vec $(LIBS)
test_hfmm3d_mps: $(STATICLIB) $(TOBJS)
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d_mps.f90 \
$(TOBJS) $(COMOBJS) $(HOBJS) \
-o test\Helmholtz\int2-test-hfmm3d-mps
#
## examples
#
examples: cxxkernel $(STATICLIB) $(TOBJS) examples\ex1_helm examples\ex2_helm examples\ex3_helm \
examples\ex1_lap examples\ex2_lap examples\ex3_lap
examples\int2-lfmm3d-example
examples\int2-lfmm3d-vec-example
examples\int2-lfmm3d-legacy-example
examples\int2-hfmm3d-example
examples\int2-hfmm3d-vec-example
examples\int2-hfmm3d-legacy-example
examples\ex1_lap:
$(FC) $(FFLAGS) examples\lfmm3d_example.f $(TOBJS) $(COMOBJS) $(LOBJS) -o examples\int2-lfmm3d-example $(LIBS)
examples\ex2_lap:
$(FC) $(FFLAGS) examples\lfmm3d_vec_example.f $(TOBJS) $(COMOBJS) $(LOBJS) -o examples\int2-lfmm3d-vec-example $(LIBS)
examples\ex3_lap:
$(FC) $(FFLAGS) examples\lfmm3d_legacy_example.f $(TOBJS) $(COMOBJS) $(LOBJS) -o examples\int2-lfmm3d-legacy-example $(LIBS)
examples\ex1_helm:
$(FC) $(FFLAGS) examples\hfmm3d_example.f $(TOBJS) $(COMOBJS) $(HOBJS) -o examples\int2-hfmm3d-example $(LIBS)
examples\ex2_helm:
$(FC) $(FFLAGS) examples\hfmm3d_vec_example.f $(TOBJS) $(COMOBJS) $(HOBJS) -o examples\int2-hfmm3d-vec-example $(LIBS)
examples\ex3_helm:
$(FC) $(FFLAGS) examples\hfmm3d_legacy_example.f $(TOBJS) $(COMOBJS) $(HOBJS) -o examples\int2-hfmm3d-legacy-example $(LIBS)
# C interface
c: $(COBJS) $(OBJS) $(CHEADERS) c\lfmm3d c\hfmm3d
c\lfmm3d:
$(CC) $(CFLAGS) c\test_lfmm3d.c $(COBJS) $(OBJS) -o c\int2-test-lfmm3d $(CLIBS)
c\int2-test-lfmm3d
c\hfmm3d:
$(CC) $(CFLAGS) c\test_hfmm3d.c $(COBJS) $(OBJS) -o c\int2-test-hfmm3d $(CLIBS)
c\int2-test-hfmm3d
# C examples
c-examples: $(COBJS) $(OBJS) $(CHEADERS) c\ex1_lap c\ex2_lap c\ex1_helm c\ex2_helm
c\int2-lfmm3d-example
c\int2-lfmm3d-vec-example
c\int2-hfmm3d-example
c\int2-hfmm3d-vec-example
del fort.13
c\ex1_lap:
$(CC) $(CFLAGS) c\lfmm3d_example.c $(COBJS) $(OBJS) -o c\int2-lfmm3d-example $(CLIBS)
c\ex2_lap:
$(CC) $(CFLAGS) c\lfmm3d_vec_example.c $(COBJS) $(OBJS) -o c\int2-lfmm3d-vec-example $(CLIBS)
c\ex1_helm:
$(CC) $(CFLAGS) c\hfmm3d_example.c $(COBJS) $(OBJS) -o c\int2-hfmm3d-example $(CLIBS)
c\ex2_helm:
$(CC) $(CFLAGS) c\hfmm3d_vec_example.c $(COBJS) $(OBJS) -o c\int2-hfmm3d-vec-example $(CLIBS)
clean: objclean
del /s lib-static\*.a lib\*.dll lib\*.lib 2>NUL
del /s python\*.so 2>NUL
del /s python\build 2>NUL
del /s python\fmm3dpy.egg-info 2>NUL
del /s examples\int2-* 2>NUL
del /s test\Laplace\int2-* 2>NUL
del /s test\Helmholtz\int2-* 2>NUL
del /s c\int2-* 2>NUL
del vec-kernels\src\libkernels.o 2>NUL
big-test: $(STATICLIB) $(TOBJS) test\test_lap_big test\test_helm_big
pw-test: $(STATICLIB) $(TOBJS) test\test_helm_pw
.\test\Helmholtz\test_hfmm3d_pw
test\test_helm_big:
$(FC) $(FFLAGS) test\Helmholtz\test_hfmm3d_big.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\test_hfmm3d_big $(LIBS)
test\test_lap_big:
$(FC) $(FFLAGS) test\Laplace\test_lfmm3d_big.f $(TOBJS) $(COMOBJS) $(LOBJS) -o test\Laplace\test_lfmm3d_big $(LIBS)
test\test_helm_pw:
$(FC) $(FFLAGS) test\Helmholtz\test_pwrep_hfmm3d.f $(TOBJS) $(COMOBJS) $(HOBJS) -o test\Helmholtz\test_hfmm3d_pw
debug: $(STATICLIB) $(TOBJS) examples\hfmm3d_deb
time -p examples\hfmm3d_debug
examples\hfmm3d_deb:
$(FC) $(FFLAGS) examples\hfmm3d_debug1.f $(TOBJS) $(COMOBJS) $(HOBJS) -o examples\hfmm3d_debug $(LIBS)
objclean:
del -f $(OBJS) $(COBJS) $(TOBJS) 2>NUL
del -f test\*.o examples\*.o c\*.o 2>NUL