-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (51 loc) · 2.32 KB
/
Makefile
File metadata and controls
62 lines (51 loc) · 2.32 KB
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
# DIRECTORIES
maindir=fast_matched_filter
srcdir=$(maindir)/src
libdir=$(maindir)/lib
# NB. If using Matlab on Mac, you MUST configure your mexopts.sh file to use an OpenMP-friendly
# compiler (like gcc)! The default clang compiler is not OpenMP-friendly. To easily install gcc
# with OpenMP enalbed via homebrew, try $brew install gcc --without-multilib
CC=gcc
NVCC=nvcc
MEX=mex
# NB. If using Matlab on another platform than Mac, please change the file extensions for Matlab to
# the following MEX extension by platform:
# Mac: mexmaci64
# Linux: mexa64
# Windows: mexw64
mex_extension=mexa64
all: $(libdir)/matched_filter_GPU.so $(libdir)/matched_filter_CPU.so $(maindir)/matched_filter.$(mex_extension)
python_cpu: $(libdir)/matched_filter_CPU.so
python_gpu: $(libdir)/matched_filter_GPU.so
matlab: $(maindir)/matched_filter.$(mex_extension) $(maindir)/matched_filter_precise.$(mex_extension)
.SUFFIXES: .c .cu
# GPU FLAGS
COPTIMFLAGS_GPU=-O3
CFLAGS_GPU=-Xcompiler "-fopenmp -fPIC -march=native -ftree-vectorize" -Xlinker -lgomp
ARCHFLAG=-gencode arch=compute_35,code=sm_35\
-gencode arch=compute_70,code=sm_70\
-gencode arch=compute_75,code=sm_75\
-gencode arch=compute_80,code=sm_80
LDFLAGS_GPU=--shared
# CPU FLAGS
COPTIMFLAGS_CPU=-O3
# -march=native can cause problems on some CPUs; remove if needed
CFLAGS_CPU=-fopenmp -fPIC -ftree-vectorize -march=native -std=gnu99
LDFLAGS_CPU=-shared
# MEX FLAGS
COPTIMFLAGS_MEX=-O3
CFLAGS_MEX=-fopenmp -fPIC -march=native -std=gnu99
# who knows why mex needs fopenmp again
LDFLAGS_MEX=-fopenmp -shared
# build for python
$(libdir)/matched_filter_GPU.so: $(srcdir)/matched_filter.cu
$(NVCC) $(COPTIMFLAGS_GPU) $(CFLAGS_GPU) $(ARCHFLAG) $(LDFLAGS_GPU) $< -o $@
$(libdir)/matched_filter_CPU.so: $(srcdir)/matched_filter.c
$(CC) $(COPTIMFLAGS_CPU) $(CFLAGS_CPU) $(LDFLAGS_CPU) $< -o $@
# build for Matlab
$(maindir)/matched_filter.$(mex_extension): $(srcdir)/matched_filter_mex.c $(srcdir)/matched_filter.c
$(MEX) CC=$(CC) COPTIMFLAGS="$(COPTIMFLAGS_MEX)" CFLAGS="$(CFLAGS_MEX)" LDFLAGS="$(LDFLAGS_MEX)" -output $@ $^
$(maindir)/matched_filter_precise.$(mex_extension): $(srcdir)/matched_filter_precise_mex.c $(srcdir)/matched_filter.c
$(MEX) CC=$(CC) COPTIMFLAGS="$(COPTIMFLAGS_MEX)" CFLAGS="$(CFLAGS_MEX)" LDFLAGS="$(LDFLAGS_MEX)" -output $@ $^
clean:
rm $(libdir)/*.so $(maindir)/*.mex*