-
Notifications
You must be signed in to change notification settings - Fork 25
/
makefile
250 lines (212 loc) · 7.19 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
all: famsa
####################
UNAME_S := $(shell uname -s)
GCC_VERSION= $(shell $(CXX) -dumpversion | cut -f1 -d.)
ifeq ($(UNAME_S),Darwin)
ABI_FLAG =
CLINK_FLAGS =
else
ABI_FLAG = -fabi-version=0
CLINK_FLAGS = -lrt
endif
ifeq ($(GCC_VERSION), 5)
$(info *** Detecting g++ version 5 ***)
CPP_STD=c++11
DEFINE_FLAGS = -DNO_PROFILE_PAR -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 6)
$(info *** Detecting g++ version 6 ***)
CPP_STD=c++11
DEFINE_FLAGS = -DNO_PROFILE_PAR -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 7)
$(info *** Detecting g++ version 7 ***)
CPP_STD=c++14
DEFINE_FLAGS = -DNO_PROFILE_PAR -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 8)
$(info *** Detecting g++ version 8 ***)
CPP_STD=c++2a
DEFINE_FLAGS = -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 9)
$(info *** Detecting g++ version 9 ***)
CPP_STD=c++2a
DEFINE_FLAGS = -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 10)
$(info *** Detecting g++ version 10 ***)
CPP_STD=c++2a
DEFINE_FLAGS = -DOLD_ATOMIC_FLAG
else ifeq ($(GCC_VERSION), 11)
$(info *** Detecting g++ version 11 ***)
ifeq ($(UNAME_S),Darwin)
CPP_STD=c++2a
DEFINE_FLAGS = -DOLD_ATOMIC_FLAG
else
CPP_STD=c++20
DEFINE_FLAGS =
endif
else
$(info *** Detecting g++ version 12 or higher ***)
ifeq ($(UNAME_S),Darwin)
CPP_STD=c++2a
DEFINE_FLAGS = -DOLD_ATOMIC_FLAG
else
CPP_STD=c++20
DEFINE_FLAGS =
endif
# DEFINE_FLAGS = -DUSE_NATIVE_BARRIERS
endif
SIMD_NONE=0
SIMD_AVX1=1
SIMD_AVX2=2
SIMD_AVX512=3
SIMD_NEON=4
# Detecting user's options and add flags
ifeq ($(PLATFORM), none)
$(info *** Unspecified platform w/o extensions ***)
COMMON_FLAGS :=
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_NONE)
SIMD=NONE
else ifeq ($(PLATFORM), arm8)
$(info *** ARMv8 with NEON extensions ***)
COMMON_FLAGS := -march=armv8-a
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_NEON)
SIMD=NEON
else ifeq ($(PLATFORM), m1)
$(info *** Apple M1 with NEON extensions ***)
COMMON_FLAGS := -march=armv8.4-a
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_NEON)
SIMD=NEON
else ifeq ($(PLATFORM), sse4)
$(info *** x86-64 with SSE4 extensions***)
COMMON_FLAGS := -msse4
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_NONE)
SIMD=NONE
else ifeq ($(PLATFORM), avx)
$(info *** x86-64 with AVX extensions***)
COMMON_FLAGS := -msse4
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_AVX1)
SIMD=AVX1
else ifeq ($(PLATFORM), native)
$(info *** x86-64 with AVX2 extensions and native architecture ***)
COMMON_FLAGS := -mavx2 -march=native
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_AVX2)
SIMD=AVX2
else
$(info *** x86-64 with AVX2 extensions***)
COMMON_FLAGS := -msse4
DEFINE_FLAGS := $(DEFINE_FLAGS) -DSIMD=$(SIMD_AVX2)
SIMD=AVX2
endif
# get commit hash
GIT_COMMIT = $(shell git describe --always --dirty)
DEFINE_FLAGS := $(DEFINE_FLAGS) -DGIT_COMMIT=$(GIT_COMMIT)
INC_DIRS =. libs/mimalloc/include libs
INCLUDES=$(foreach d, $(INC_DIRS), -I$d)
ifeq ($(STATIC_LINK), true)
CXXFLAGS = -Wall -Wno-char-subscripts -Wno-attributes -O3 $(COMMON_FLAGS) $(DEFINE_FLAGS) -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=$(CPP_STD) $(INCLUDES)
CLINK = -lm -static -O3 -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=$(CPP_STD)
else
CXXFLAGS = -Wall -Wno-char-subscripts -Wno-attributes -O3 $(COMMON_FLAGS) $(DEFINE_FLAGS) -std=$(CPP_STD) -pthread $(INCLUDES)
CLINK = -lm $(CLINK_FLAGS) -O3 $(COMMON_FLAGS) -std=$(CPP_STD) -pthread
endif
CXXFLAGS_AVX = $(CXXFLAGS) -mavx ${ABI_FLAG} -mpopcnt -funroll-loops
CXXFLAGS_AVX2 = $(CXXFLAGS) -mavx2 ${ABI_FLAG} -mpopcnt -funroll-loops
CXXFLAGS_NEON = $(CXXFLAGS) ${ABI_FLAG} -funroll-loops
LIB_DEFLATE=libs/libdeflate/build/libdeflate.a
deflate:
cmake -S libs/libdeflate -B libs/libdeflate/build
cmake --build libs/libdeflate/build
MIMALLOC_OBJ=libs/mimalloc/mimalloc.o
$(MIMALLOC_OBJ):
$(CXX) -DMI_MALLOC_OVERRIDE -O3 -DNDEBUG -fPIC -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden -Wstrict-prototypes -ftls-model=initial-exec -fno-builtin-malloc -std=$(CPP_STD) -c -I libs/mimalloc/include libs/mimalloc/src/static.c -o $(MIMALLOC_OBJ)
COMMON_OBJS := src/msa.o \
src/msa_refinement.o \
src/tree/AbstractTreeGenerator.o \
src/tree/Clustering.o \
src/tree/DistanceCalculator.o \
src/tree/FastTree.o \
src/tree/GuideTree.o \
src/tree/MSTPrim.o \
src/tree/NeighborJoining.o \
src/tree/NewickParser.o \
src/tree/SingleLinkage.o \
src/tree/UPGMA.o \
src/utils/timer.o \
src/utils/log.o \
src/core/io_service.o \
src/core/params.o \
src/core/profile.o \
src/core/profile_par.o \
src/core/profile_seq.o \
src/core/sequence.o \
src/core/queues.o
src/lcs/lcsbp_classic.o : src/lcs/lcsbp_classic.cpp
$(CXX) $(CXXFLAGS) -c src/lcs/lcsbp_classic.cpp -o $@
ifeq ($(SIMD), NONE)
LCS_OBJS := src/lcs/lcsbp.o \
src/lcs/lcsbp_classic.o
UTILS_OBJS := src/utils/utils.o
src/lcs/lcsbp.o : src/lcs/lcsbp.cpp
$(CXX) $(CXXFLAGS) -c src/lcs/lcsbp.cpp -o $@
src/utils/utils.o : src/utils/utils.cpp
$(CXX) $(CXXFLAGS) -c src/utils/utils.cpp -o $@
else ifeq ($(SIMD), AVX1)
LCS_OBJS := src/lcs/lcsbp.o \
src/lcs/lcsbp_classic.o \
src/lcs/lcsbp_avx_intr.o
UTILS_OBJS := src/utils/utils.o \
src/utils/utils_avx.o
src/lcs/lcsbp.o : src/lcs/lcsbp.cpp
$(CXX) $(CXXFLAGS) -c src/lcs/lcsbp.cpp -o $@
src/lcs/lcsbp_avx_intr.o : src/lcs/lcsbp_avx_intr.cpp
$(CXX) $(CXXFLAGS_AVX) -c src/lcs/lcsbp_avx_intr.cpp -o $@
src/utils/utils.o : src/utils/utils.cpp
$(CXX) $(CXXFLAGS) -c src/utils/utils.cpp -o $@
src/utils/utils_avx.o : src/utils/utils_avx.cpp
$(CXX) $(CXXFLAGS_AVX) -c src/utils/utils_avx.cpp -o $@
else ifeq ($(SIMD), NEON)
LCS_OBJS := src/lcs/lcsbp.o \
src/lcs/lcsbp_classic.o \
src/lcs/lcsbp_neon_intr.o
UTILS_OBJS := src/utils/utils.o \
src/utils/utils_neon.o
src/lcs/lcsbp.o : src/lcs/lcsbp.cpp
$(CXX) $(CXXFLAGS) -c src/lcs/lcsbp.cpp -o $@
src/lcs/lcsbp_neon_intr.o : src/lcs/lcsbp_neon_intr.cpp
$(CXX) $(CXXFLAGS_NEON) -c src/lcs/lcsbp_neon_intr.cpp -o $@
src/utils/utils.o : src/utils/utils.cpp
$(CXX) $(CXXFLAGS) -c src/utils/utils.cpp -o $@
src/utils/utils_neon.o : src/utils/utils_neon.cpp
$(CXX) $(CXXFLAGS_NEON) -c src/utils/utils_neon.cpp -o $@
else
LCS_OBJS := src/lcs/lcsbp.o \
src/lcs/lcsbp_classic.o \
src/lcs/lcsbp_avx_intr.o \
src/lcs/lcsbp_avx2_intr.o
UTILS_OBJS := src/utils/utils.o \
src/utils/utils_avx.o \
src/utils/utils_avx2.o
src/lcs/lcsbp.o : src/lcs/lcsbp.cpp
$(CXX) $(CXXFLAGS) -c src/lcs/lcsbp.cpp -o $@
src/lcs/lcsbp_avx_intr.o : src/lcs/lcsbp_avx_intr.cpp
$(CXX) $(CXXFLAGS_AVX) -c src/lcs/lcsbp_avx_intr.cpp -o $@
src/lcs/lcsbp_avx2_intr.o : src/lcs/lcsbp_avx2_intr.cpp
$(CXX) $(CXXFLAGS_AVX2) -c src/lcs/lcsbp_avx2_intr.cpp -o $@
src/utils/utils.o : src/utils/utils.cpp
$(CXX) $(CXXFLAGS) -c src/utils/utils.cpp -o $@
src/utils/utils_avx.o : src/utils/utils_avx.cpp
$(CXX) $(CXXFLAGS_AVX) -c src/utils/utils_avx.cpp -o $@
src/utils/utils_avx2.o : src/utils/utils_avx2.cpp
$(CXX) $(CXXFLAGS_AVX2) -c src/utils/utils_avx2.cpp -o $@
endif
.cpp.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
famsa: deflate $(MIMALLOC_OBJ) src/famsa.o $(COMMON_OBJS) $(LCS_OBJS) $(UTILS_OBJS)
$(CXX) $(CLINK) -o $@ $(MIMALLOC_OBJ) src/famsa.o $(COMMON_OBJS) $(LCS_OBJS) $(UTILS_OBJS) $(LIB_DEFLATE)
clean:
cd libs/libdeflate/build && make clean
-rm src/core/*.o
-rm src/lcs/*.o
-rm src/tree/*.o
-rm src/utils/*.o
-rm src/*.o
-rm libs/mimalloc/*.o
-rm famsa