-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
229 lines (162 loc) · 8.18 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
222
223
224
225
226
227
228
229
.PHONY: all clean fall pgall pgfall
INCLUDE_PATHS=. include include/minicore blaze libosmium/include protozero/include pdqsort include/thirdparty
ifdef BOOST_DIR
INCLUDE_PATHS += $(BOOST_DIR)
endif
LIBKL?=./libkl
LIBPATHS+=$(LIBKL)
LINKS+=-lz
ifdef HDFPATH
INCLUDE_PATHS+= $(HDFPATH)/include
LIBPATHS+= $(HDFPATH)/lib
LINKS+=-lhdf5 -lhdf5_hl -lhdf5_hl_cpp -lhdf5_cpp
endif
# Handle SLEEF
CXXFLAGS+=-DBLAZE_USE_SLEEF=1
ifdef SLEEF_DIR
INCLUDE_PATHS+= $(SLEEF_DIR)/include
LIBPATHS+=$(SLEEF_DIR)/lib
else
INCLUDE_PATHS+=sleef/build/include
INCLUDE_PATHS+=sleef/dynbuild/include
LIBPATHS+=sleef/build/lib
LIBPATHS+=sleef/dynbuild/lib
endif
LINKS+= # -lsleef #-lkl -lsimdsampling
ifdef TBBDIR
INCLUDE_PATHS+= $(TBBDIR)/include
LIBPATHS+= $(TBBDIR)/lib
CXXFLAGS += -DUSE_TBB
LINKS += -ltbb
endif
ifdef CBLASFILE
DEFINES+= -DCBLASFILE='${CBLASFILE}'
endif
CMAKE?=cmake
INCLUDE=$(patsubst %,-I%,$(INCLUDE_PATHS))
LIBS=$(patsubst %,-L%,$(LIBPATHS))
CXX?=g++
CC?=gcc
STD?=c++17
WARNINGS+=-Wall -Wextra -Wpointer-arith -Wformat -Wunused-variable -Wno-attributes -Wno-ignored-qualifiers -Wno-unused-function -Wdeprecated -Wno-deprecated-declarations \
-Wno-deprecated-copy # Because of Boost.Fusion
OPT?=O3
#LDFLAGS+=$(LIBS) $(LINKS)
EXTRA?=
DEFINES+= #-DBLAZE_RANDOM_NUMBER_GENERATOR='wy::WyHash<uint64_t, 2>'
CXXFLAGS+=-$(OPT) -std=$(STD) -march=native $(WARNINGS) $(INCLUDE) $(DEFINES) $(BLAS_LINKING_FLAGS) \
-DBOOST_NO_AUTO_PTR -lz # -DBLAZE_USE_SHARED_MEMORY_PARALLELIZATION=0
EX=$(patsubst src/utils/%.cpp,%,$(wildcard src/utils/*.cpp)) $(patsubst src/%.cpp,%,$(wildcard src/*.cpp))
ifneq (,$(findstring clang++,$(CXX)))
OMP_STR:=-lomp
else
OMP_STR:=-fopenmp#-simd
endif
ifdef LZMA_ARCHIVE
CXXFLAGS += $(LZMA_ARCHIVE) -llzma -DHAVE_LZMA
endif
TESTS=tbmdbg coreset_testdbg bztestdbg btestdbg osm2dimacsdbg dmlsearchdbg diskmattestdbg graphtestdbg jvtestdbg kmpptestdbg tbasdbg \
jsdtestdbg jsdkmeanstestdbg jsdhashdbg fgcinctestdbg geomedtestdbg oracle_thorup_ddbg sparsepriortestdbg istestdbg msvdbg knntestdbg \
fkmpptestdbg mergetestdbg solvetestdbg testmsrdbg testmsrcsrdbg test_centroiddbg
all: $(EX)
ex: $(EX)
LIBPATHS+= libkl
LIBPATHS+= libsimdsampling
tests: $(TESTS)
print_tests:
@echo "Tests: " $(TESTS)
ifdef USESAN
CXXFLAGS += -fsanitize=address
endif
CXXFLAGS += $(EXTRA)
CXXFLAGS += $(LIBS) $(LINKS)
HEADERS=$(shell find include -name '*.h')
STATIC_LIBS=libsleef.a
#libsimdsampling/libsimdsampling.a: libsimdsampling/simdsampling.cpp libsimdsampling/simdsampling.h libsleef.dyn.gen
#ls libsimdsampling/libsimdsampling.a 2>/dev/null || (cd libsimdsampling && $(MAKE) libsimdsampling.a INCLUDE_PATHS="../sleef/build/include" LINK_PATHS="../sleef/build/lib" && cd ..)
%: src/tests/%.o $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -pthread -UNDEBUG $(OMP_STR) $(STATIC_LIBS) libkl/libkl.a libsimdsampling/libsimdsampling.a
src/tests/%.o: src/tests/%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) -c $< -o $@ -pthread -UNDEBUG $(OMP_STR) $(STATIC_LIBS)
%.dbgo: %.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) -c $< -o $@ -pthread $(OMP_STR) $(STATIC_LIBS) -O1
%dbg: src/tests/%.dbgo $(HEADERS) $(STATIC_LIBS) libkl/libkl.a libsimdsampling/libsimdsampling.a
$(CXX) $(CXXFLAGS) $< -o $@ -pthread $(OMP_STR) $(STATIC_LIBS) -O1 libkl/libkl.a libsimdsampling/libsimdsampling.a
printlibs:
echo $(LIBPATHS)
#graphrun: src/graphtest.cpp $(wildcard include/minicore/*.h)
# $(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR)
%: src/%.cpp $(HEADERS) $(STATIC_LIBS) libkl/libkl.a libsimdsampling/libsimdsampling.a
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 $(STATIC_LIBS) libkl/libkl.a libsimdsampling/libsimdsampling.a
%: src/utils/%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 $(STATIC_LIBS) libkl/libkl.a libsimdsampling/libsimdsampling.a
mtx%: src/mtx%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ $(OMP_STR) -O3 -DNDEBUG $(STATIC_LIBS) # -fsanitize=undefined -fsanitize=address
mtx%: src/utils/mtx%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ $(OMP_STR) -O3 -DNDEBUG $(STATIC_LIBS) # -fsanitize=undefined -fsanitize=address
mtx%dbg: src/mtx%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ $(OMP_STR) -O3 $(STATIC_LIBS) # -fsanitize=undefined -fsanitize=address
mtx%dbg: src/utils/mtx%.cpp $(HEADERS) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ $(OMP_STR) -O3 $(STATIC_LIBS)
alphaest: src/utils/alphaest.cpp $(wildcard include/minicore/*.h) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 $(STATIC_LIBS)
dae: src/utils/alphaest.cpp $(wildcard include/minicore/*.h) $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 -DDENSESUB $(STATIC_LIBS)
jsdkmeanstest: src/tests/jsdkmeanstest.cpp $(wildcard include/minicore/*.h) $(STATIC_LIBS) libsleef.dyn.gen libsimdsampling/libsimdsampling.a
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 -lz $(STATIC_LIBS) libsimdsampling/libsimdsampling.a
jsdkmeanstestdbg: src/tests/jsdkmeanstest.cpp $(wildcard include/minicore/*.h) $(STATIC_LIBS) libsleef.dyn.gen libsimdsampling/libsimdsampling.a
$(CXX) $(CXXFLAGS) $< -o $@ $(OMP_STR) -O3 -lz $(STATIC_LIBS) libsimdsampling/libsimdsampling.a
HDFLAGS=-L$(HDFPATH)/lib -I$(HDFPATH)/include -lhdf5_cpp -lhdf5 -lhdf5_hl -lhdf5_hl_cpp
hdf2dm: src/utils/hdf2dm.cpp $(wildcard include/minicore/*.h) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -O3 $(HDFLAGS)
mpi%: src/%.cpp $(wildcard include/minicore/*.h) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -o $@ -DNDEBUG $(OMP_STR) -Ofast -DUSE_BOOST_PARALLEL=1
%pg: src/%.cpp $(wildcard include/minicore/*.h) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -pg -o $@
%pgf: src/%.cpp $(wildcard include/minicore/*.h) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< -pg $(OMP_STR) -o $@
%f: src/%.cpp $(wildcard include/minicore/*.h) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) $< $(OMP_STR) -o $@
osm2dimacsdbg: src/utils/osm2dimacs.cpp $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) \
$(OSINC) -pthread \
$< -lz -lbz2 -lexpat -o $@
osm2dimacs: src/utils/osm2dimacs.cpp $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) \
$(OSINC) -pthread \
$< -lz -lbz2 -lexpat -o $@ -O3 $(OMP_STR) -DNDEBUG
osm2dimacspgf: src/utils/osm2dimacs.cpp $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) \
$(OSINC) -pthread \
$< -lbz2 -lexpat -o $@ -O3 -lbz2 -lexpat -pg -DNDEBUG $(OMP_STR)
osm2dimacspg: src/utils/osm2dimacs.cpp $(STATIC_LIBS) libsleef.dyn.gen
$(CXX) $(CXXFLAGS) \
$(OSINC) -pthread \
$< -lbz2 -lexpat -o $@ -O3 -lbz2 -lexpat -pg
libsimdsampling/libsimdsampling.so: libsimdsampling/simdsampling.cpp libsimdsampling/simdsampling.h
cd libsimdsampling && $(MAKE) libsimdsampling.so SLEEF_DIR=../sleef && cp libsimdsampling.so ..
libkl/libkl.so: libkl/libkl.c libkl/libkl.h sleef.h
ls $@ libkl/libkl.dylib 2>/dev/null || (cd libkl && $(MAKE) SLEEF_DIR=../sleef/build)
libkl.o: libkl/libkl.c libkl/libkl.h libsleef.a sleef.h
$(CC) $< -o $@ -c $(INCLUDE) $(WARNINGS) $(EXTRA) -std=c11 $(ND) -fPIC
libkl.a: libkl.o
$(AR) rcs $@ $<
libsimdsampling.a: libsimdsampling/libsimdsampling.a
cp $< $@
libsimdsampling/libsimdsampling.a:
cd libsimdsampling && $(MAKE) libsimdsampling.a
libsleef.dyn.gen:
+(ls libsleef.so || ls libsleef.dylib) 2>/dev/null || (cd sleef && mkdir -p dynbuild && cd dynbuild && $(CMAKE) .. -DBUILD_SHARED_LIBS=1 && $(MAKE) && cp lib/* ../.. && cd ../.. && touch libsleef.dyn.gen)
sleef/sleefbuild/lib/libsleef.a:
(ninja --version 2>/dev/null && mkdir -p sleef/sleefbuild && cd sleef/sleefbuild && rm -f CMakeCache.txt && $(CMAKE) .. -DBUILD_SHARED_LIBS=0 -G "Ninja" && ninja -j10) ||\
(mkdir -p sleef/sleefbuild && cd sleef/sleefbuild && rm -f CMakeCache.txt && cmake .. -DBUILD_SHARED_LIBS=0 && (make || ls lib/libsleef.a))
libsleef.a: sleef/sleefbuild/lib/libsleef.a
cp $< $@
sleef/sleefbuild/include/sleef.h: libsleef.a sleef/sleefbuild
sleef.h: sleef/sleefbuild/include/sleef.h
cp $< $@
soft: solvetestdbg solvetest solvesoft solvesoftdbg
ssoft: solvesoft solvesoftdbg
hsoft: solvetest solvetestdbg
clean:
rm -f $(EX) graphrun dmlrun