forked from VolunteerComputingHelp/boinc-app-eah-brp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.mingw.cuda
161 lines (134 loc) · 9.14 KB
/
Makefile.mingw.cuda
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
###########################################################################
# Copyright (C) 2009 by Oliver Bock #
# oliver.bock[AT]aei.mpg.de #
# #
# This file is part of Einstein@Home (Radio Pulsar Edition). #
# #
# Einstein@Home 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, version 2 of the License. #
# #
# Einstein@Home 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 Einstein@Home. If not, see <http://www.gnu.org/licenses/>. #
# #
###########################################################################
# path settings
EINSTEIN_RADIO_SRC?=$(PWD)
EINSTEIN_RADIO_INSTALL?=$(PWD)
CUDA_INSTALL_PATH?=/usr/local/cuda
# config values
CXX ?= g++
ARCH=$(if $(findstring x86_64-w64-mingw32-g++,$(CXX)),64,32)
# variables
LIBS = -Wl,-Bstatic
LIBS += -L$(EINSTEIN_RADIO_INSTALL)/lib
LIBS += $(shell $(EINSTEIN_RADIO_INSTALL)/bin/gsl-config --libs)
LIBS += -lfftw3f -lm # there's no pkg-config in our MinGW setup
LIBS += $(shell $(EINSTEIN_RADIO_INSTALL)/bin/xml2-config --libs)
LIBS += -lws2_32 # required by libxml2
LIBS += -lboinc_graphics2 -lboinc_api -lboinc
LIBS += -lpsapi # required by BOINC API
LIBS += -lbfd -liberty -lintl # required for exception handling
LIBS += -Wl,-Bdynamic
LIBS += $(EINSTEIN_RADIO_SRC)/cuda/redist/winxp_32/5.5/lib/cufft.lib # CUDA FFT
LIBS += $(EINSTEIN_RADIO_SRC)/cuda/redist/winxp_32/5.5/lib/cudart.lib # CUDA runtime library
LIBS += $(EINSTEIN_RADIO_SRC)/cuda/redist/winxp_32/5.5/lib/cuda.lib # CUDA driver library
LIBS += $(EINSTEIN_RADIO_INSTALL)/lib/libz.a
LDFLAGS = -static-libgcc $(if $(ARCH)=64,-static-libstdc++,)
CXXFLAGS += -I$(EINSTEIN_RADIO_INSTALL)/include
CXXFLAGS += $(shell $(EINSTEIN_RADIO_INSTALL)/bin/gsl-config --cflags)
CXXFLAGS += $(shell $(EINSTEIN_RADIO_INSTALL)/bin/xml2-config --cflags)
CXXFLAGS += -I$(EINSTEIN_RADIO_INSTALL)/include/boinc
CXXFLAGS += -I$(CUDA_INSTALL_PATH)/include
CXXFLAGS += -DHAVE_INLINE -DBOINCIFIED $(CPPFLAGS)
CXXFLAGS += -malign-double
CXXFLAGS += -DUSE_CUDA
DEPS = Makefile
OBJS = demod_binary.o demod_binary_cuda.cu.o demod_binary_hs_cuda.cu.o hs_common.o rngmed.o erp_boinc_ipc.o erp_getopt.o erp_getopt1.o erp_utilities.o cuda_utilities.o exchndl.o
EINSTEINBINARY_TARGET ?= einsteinbinary_cuda.exe
TARGET = $(EINSTEINBINARY_TARGET)
# primary role based tagets
default: release
debug: $(TARGET)
#profile: clean $(TARGET)
release: clean $(TARGET)
# target specific options (generic)
debug: CXXFLAGS_BASE += -DLOGLEVEL=debug -O3 -Wall
#profile: CXXFLAGS_BASE += -DNDEBUG -DLOGLEVEL=info -O3 -Wall
release: CXXFLAGS_BASE += -DNDEBUG -DLOGLEVEL=info -O3 -Wall
# target specific options (nvcc)
debug: CXXFLAGS_CUDA += $(CXXFLAGS) $(CXXFLAGS_BASE)
debug: NVCCFLAGS += -G
#profile: CXXFLAGS_CUDA += $(CXXFLAGS) $(CXXFLAGS_BASE)
#profile: NVCCFLAGS += -O3
release: CXXFLAGS_CUDA += $(CXXFLAGS) $(CXXFLAGS_BASE)
release: NVCCFLAGS += -O3
# target specific options (gcc)
debug: CXXFLAGS_GCC += $(CXXFLAGS) $(CXXFLAGS_BASE) -gstabs3
#profile: CXXFLAGS_GCC += $(CXXFLAGS) $(CXXFLAGS_BASE) -gstabs3 -fprofile-generate
#release: CXXFLAGS_GCC += $(CXXFLAGS) $(CXXFLAGS_BASE) -gstabs3 -fprofile-use
release: CXXFLAGS_GCC += $(CXXFLAGS) $(CXXFLAGS_BASE) -gstabs3
# file based targets
#profile:
# @echo "Removing previous profiling data..."
# rm -f *_profile.*
# rm -f *.gcda
# @echo "In order to gather profiling data one needs to run the following command on a windoze box:"
# @echo "cd build/einsteinradio && $(TARGET) -t $(EINSTEIN_RADIO_SRC)/../test/templates_400Hz_2_short.bank -l $(EINSTEIN_RADIO_SRC)/data/zaplist_232.txt -A 0.04 -P 3.0 -W -z -i $(EINSTEIN_RADIO_SRC)/../test/J1907+0740_dm_482.bina$
$(TARGET): $(DEPS) $(EINSTEIN_RADIO_SRC)/erp_boinc_wrapper.cpp $(OBJS)
$(CXX) -g $(CXXFLAGS_GCC) $(LDFLAGS) $(EINSTEIN_RADIO_SRC)/erp_boinc_wrapper.cpp -o $(TARGET) $(OBJS) $(LIBS)
demod_binary.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/demod_binary.c $(EINSTEIN_RADIO_SRC)/demod_binary.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/demod_binary.c
demod_binary_cuda.ptx: $(DEPS) $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.cu $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.cuh
nvcc --ptx $(NVCCFLAGS) --compiler-options="$(CXXFLAGS_CUDA)" $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.cu
mv demod_binary_cuda.ptx db.dev
demod_binary_cuda.cu.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.cu $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.h demod_binary_cuda.ptx
nvcc --cuda -dir=$(TARGET).devcode -ext=all $(NVCCFLAGS) --compiler-options="$(CXXFLAGS_CUDA)" $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_cuda.cu
sed -i 's/extern "C" CUresult/extern "C" CUresult __attribute__\(\(stdcall\)\)/g' demod_binary_cuda.cu.cpp.ii
sed -i 's/extern "C" cudaError_t/extern "C" cudaError_t __attribute__\(\(stdcall\)\)/g' demod_binary_cuda.cu.cpp.ii
sed -i 's/extern "C" cufftResult/extern "C" cufftResult __attribute__\(\(stdcall\)\)/g' demod_binary_cuda.cu.cpp.ii
sed -i 's/extern "C" const char \*/extern "C" const char \* __attribute__\(\(stdcall\)\) /g' demod_binary_cuda.cu.cpp.ii
sed -i 's/extern \(.*\) __cuda/extern \1 __attribute__\(\(stdcall\)\) __cuda/g' demod_binary_cuda.cu.cpp.ii
$(CXX) -g $(CXXFLAGS_CUDA) -gstabs3 -c demod_binary_cuda.cu.cpp.ii -o demod_binary_cuda.cu.o
demod_binary_hs_cuda.ptx: $(DEPS) $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_hs_cuda.cu $(EINSTEIN_RADIO_SRC)/cuda/app/harmonic_summing_kernel.cuh
nvcc --ptx $(NVCCFLAGS) --compiler-options="$(CXXFLAGS_CUDA)" $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_hs_cuda.cu
mv demod_binary_hs_cuda.ptx dbhs.dev
demod_binary_hs_cuda.cu.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_hs_cuda.cu $(EINSTEIN_RADIO_SRC)/cuda/app/harmonic_summing_kernel.cuh demod_binary_hs_cuda.ptx
nvcc --cuda -dir=$(TARGET).devcode -ext=all $(NVCCFLAGS) --compiler-options="$(CXXFLAGS_CUDA)" $(EINSTEIN_RADIO_SRC)/cuda/app/demod_binary_hs_cuda.cu
sed -i 's/extern "C" CUresult/extern "C" CUresult __attribute__\(\(stdcall\)\)/g' demod_binary_hs_cuda.cu.cpp.ii
sed -i 's/extern "C" cudaError_t/extern "C" cudaError_t __attribute__\(\(stdcall\)\)/g' demod_binary_hs_cuda.cu.cpp.ii
sed -i 's/extern "C" cufftResult/extern "C" cufftResult __attribute__\(\(stdcall\)\)/g' demod_binary_hs_cuda.cu.cpp.ii
sed -i 's/extern "C" const char \*/extern "C" const char \* __attribute__\(\(stdcall\)\) /g' demod_binary_hs_cuda.cu.cpp.ii
sed -i 's/extern \(.*\) __cuda/extern \1 __attribute__\(\(stdcall\)\) __cuda/g' demod_binary_hs_cuda.cu.cpp.ii
sed -i 's/extern "C" cudaChannelFormatDesc cudaCreateChannelDesc(/extern "C" cudaChannelFormatDesc __attribute__\(\(stdcall\)\) cudaCreateChannelDesc(/g' demod_binary_hs_cuda.cu.cpp.ii
$(CXX) -g $(CXXFLAGS_CUDA) -gstabs3 -c demod_binary_hs_cuda.cu.cpp.ii -o demod_binary_hs_cuda.cu.o
hs_common.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/hs_common.c $(EINSTEIN_RADIO_SRC)/hs_common.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/hs_common.c
rngmed.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/rngmed.c $(EINSTEIN_RADIO_SRC)/rngmed.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/rngmed.c
erp_boinc_ipc.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/erp_boinc_ipc.cpp $(EINSTEIN_RADIO_SRC)/erp_boinc_ipc.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/erp_boinc_ipc.cpp
erp_getopt.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/erp_getopt.c $(EINSTEIN_RADIO_SRC)/erp_getopt.h $(EINSTEIN_RADIO_SRC)/erp_getopt_int.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/erp_getopt.c
erp_getopt1.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/erp_getopt1.c $(EINSTEIN_RADIO_SRC)/erp_getopt.h $(EINSTEIN_RADIO_SRC)/erp_getopt_int.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/erp_getopt1.c
erp_utilities.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/erp_utilities.cpp $(EINSTEIN_RADIO_SRC)/erp_utilities.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/erp_utilities.cpp
cuda_utilities.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/cuda/app/cuda_utilities.c $(EINSTEIN_RADIO_SRC)/cuda/app/cuda_utilities.h
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/cuda/app/cuda_utilities.c
exchndl.o: $(DEPS) $(EINSTEIN_RADIO_SRC)/exchndl$(ARCH).c
$(CXX) -g $(CXXFLAGS_GCC) -c $(EINSTEIN_RADIO_SRC)/exchndl$(ARCH).c -o exchndl.o
install:
mkdir -p $(EINSTEIN_RADIO_INSTALL)/../dist
cp $(TARGET) $(EINSTEIN_RADIO_INSTALL)/../dist
cp *.dev $(EINSTEIN_RADIO_INSTALL)/../dist
cp db.dev $(EINSTEIN_RADIO_INSTALL)/../dist/$(TARGET)-db.dev
cp dbhs.dev $(EINSTEIN_RADIO_INSTALL)/../dist/$(TARGET)-dbhs.dev
clean:
rm -f $(OBJS) $(TARGET)
rm -rf $(TARGET).devcode