forked from smarco/gem3-mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.mk.in
executable file
·255 lines (228 loc) · 8.25 KB
/
Makefile.mk.in
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
###############################################################################
# GEM-Mapper v3 (GEM3)
# Copyright (c) 2011-2018 by Santiago Marco-Sola <[email protected]>
# Copyright (c) 2011-2018 by Alejandro Chacon <[email protected]>
#
# This file is part of GEM-Mapper v3 (GEM3).
#
# This program 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, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# PROJECT: GEM-Mapper v3 (GEM3)
# AUTHOR(S): Santiago Marco-Sola <[email protected]>
# Alejandro Chacon <[email protected]>
###############################################################################
###############################################################################
# System
###############################################################################
PLATFORM=$(shell uname)
ARCH=$(shell uname -m)
# Knights Landing (KNL) supports AVX512 instructions: AVX-512F (foundation),
# AVX-512CD (conflict detection), AVX-512ER (exponential and reciprocal) and
# AVX-512PF (prefetch)
# Skylake-Server (SKX) supports all AVX512 instructions: we check for avx512vl (since KNL doesn't support it)
CPU_FLAGS=$(shell grep -m 1 flags /proc/cpuinfo)
# Utilities
CC=@CC@
AR=ar
###############################################################################
# Paths
###############################################################################
# Folders
FOLDER_BIN=$(ROOT_PATH)/bin
FOLDER_BUILD=$(ROOT_PATH)/build
FOLDER_DATASETS=$(ROOT_PATH)/datasets
FOLDER_INCLUDE=$(ROOT_PATH)/include
FOLDER_LIB=$(ROOT_PATH)/lib
FOLDER_RESOURCES=$(ROOT_PATH)/resources
FOLDER_RESOURCES_BUILD=$(ROOT_PATH)/resources/build
FOLDER_RESOURCES_INCLUDE=$(ROOT_PATH)/resources/include
FOLDER_SOURCE=$(ROOT_PATH)/src
FOLDER_TEST=$(ROOT_PATH)/test
FOLDER_TOOLS=$(ROOT_PATH)/tools
###############################################################################
# Configure flags
###############################################################################
HAVE_ZLIB = @HAVE_ZLIB@
HAVE_BZLIB = @HAVE_BZLIB@
HAVE_CUDA = @HAVE_CUDA@
HAVE_LTO = @HAVE_LTO@
HAVE_GOLD = @HAVE_GOLD@
###############################################################################
# General Flags
###############################################################################
# GEM Flags
LIB_GEM_CORE=$(FOLDER_LIB)/libgemcore_c.a
FLAGS_GEM_PROFILE=-DGEM_PROFILE
FLAGS_GEM_DEBUG=-DGEM_DEBUG
ifeq ($(VTUNE),true)
FLAGS_GEM_VTUNE=-DGEM_VTUNE
endif
FLAGS_GCC_WARNINGS0=-Wcast-align \
-Wlogical-op \
-Wmaybe-uninitialized \
-Wshadow \
-Wstrict-aliasing=1 \
-Wtype-limits \
-Wuninitialized \
-Wunused
FLAGS_GCC_WARNINGS1=-Wconversion \
-Wdouble-promotion \
-Wfloat-conversion \
-Wsign-compare \
-Wsign-conversion \
-Wcast-qual \
-Wunused-parameter
FLAGS_GCC_WARNINGS2=-Waggregate-return \
-Wempty-body \
-Wfloat-equal \
-Wignored-qualifiers \
-Wimplicit-fallthrough \
-Wjump-misses-init \
-Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wno-aggressive-loop-optimizations \
-Wpadded \
-Wredundant-decls \
-Wswitch-default \
-Wswitch-enum \
-Wunsafe-loop-optimizations \
-Wuseless-cast
FLAGS_GCC_WARNINGS3=-pedantic \
-Wextra \
-Wdangling-else \
-Wtautological-compare \
-Wduplicated-cond \
-Wnull-dereference \
-Wswitch-bool \
-Wswitch-unreachable \
-Wshift-overflow=2 \
-Wshift-negative-value \
-Wtraditional \
-Wtraditional-conversion
## Base flags (Generic Compiler)
FLAGS_GENERAL=-std=c99 -Wall
FLAGS_SUPPRESS_CHECKS=-DNDEBUG
FLAGS_OPT=-O3
FLAGS_DEVEL=-g
FLAGS_DEBUG=-Og
FLAGS_PROFILE=-rdynamic
## GCC Compiler
ifeq ($(CC),gcc)
ifeq ($(HAVE_LTO),1)
OPT_LTO=-flto
endif
ifeq ($(HAVE_GOLD),1)
AR=gcc-ar
OPT_AR=-fuse-linker-plugin -Wno-ignored-optimization-argument
endif
ifeq ($(ARCH),ppc64le)
FLAGS_OPT=-Ofast -mcpu=native -mtune=native $(OPT_LTO)
else ifeq ($(ARCH),aarch64)
FLAGS_OPT=-Ofast -march=native -mcpu=thunderx2t99 $(OPT_LTO)
else ifeq ($(ARCH),x86_64)
ifneq (,$(findstring avx512vl, $(CPU_FLAGS)))
FLAGS_OPT=-Ofast -march=skylake-avx512 $(OPT_LTO)
else ifneq (,$(findstring avx512f, $(CPU_FLAGS)))
FLAGS_OPT=-march=knl -O3 -mavx512f -mavx512pf -mavx512er -mavx512cd -mfma -malign-data=cacheline -finline-functions $(OPT_LTO)
else
FLAGS_OPT=-Ofast -march=native $(OPT_LTO)
endif
else
echo 'unknown arch, run "uname -m" to verify your arch (ppc64le, aarch64, x86_64)'
exit -1
endif
FLAGS_LINK=$(OPT_AR)
endif
## ICC Compiler
ifeq ($(CC),icc)
ifneq (,$(findstring avx512vl, $(CPU_FLAGS)))
FLAGS_OPT=-O3 -xCORE-AVX512 -mtune=skylake -ipo
else ifneq (,$(findstring avx512f, $(CPU_FLAGS)))
FLAGS_OPT=-O3 -xMIC-AVX512 -fma -align -finline-functions -ipo
else
FLAGS_OPT=-Ofast -march=native -ipo
endif
FLAGS_DEBUG=-g
endif
## armclang Compiler
ifeq ($(CC),armclang)
ifeq ($(ARCH),aarch64)
FLAGS_OPT=-Ofast -march=armv8-a -mcpu=thunderx2t99 $(OPT_LTO)
else
echo 'armclang can be used for aarch64 arch, run "uname -m" to verify your arch (aarch64)'
exit -1
endif
endif
###############################################################################
# Library Flags
###############################################################################
# Libs/Include Flags
PATH_INCLUDE=-I$(FOLDER_INCLUDE)
PATH_LIB=-L$(FOLDER_LIB)
# Link Libs
LIBS=-lpthread -lm $(LIBS_ZLIB) $(LIBS_BZLIB)
ifeq ($(PLATFORM),Linux)
LIBS+=-lrt
endif
###############################################################################
# System dependent flags
###############################################################################
# GZip
ifeq ($(HAVE_ZLIB),1)
DEF_ZLIB=-DHAVE_ZLIB
LIB_ZLIB+=-lz
LIBS+=$(LIB_ZLIB)
endif
# BZip
ifeq ($(HAVE_BZLIB),1)
DEF_BZLIB=-DHAVE_BZLIB
LIB_BZLIB+=-lbz2
LIBS+=$(LIB_BZLIB)
endif
###############################################################################
# CUDA
###############################################################################
ifeq ($(HAVE_CUDA),1)
# Paths
DEF_CUDA=-DHAVE_CUDA
PATH_CUDA=@CUDA_PATH@
NVCC=@CUDA_BIN_PATH@/nvcc
# CUDA Libs
CUDA_PATH_INCLUDE+=-I@CUDA_INCLUDE_PATH@
CUDA_PATH_LIB+=-L@CUDA_LIB_PATH@ -L@CUDA_LIB_PATH@/stubs
CUDA_PROFILE_LIB=-lnvToolsExt
CUDA_LIB=-lcuda -lcudart -lstdc++
endif
###############################################################################
# VTune
###############################################################################
ifeq ($(VTUNE),true)
# Path
VTUNE_PATH=/opt/intel/vtune_amplifier_xe/
ifeq ("$(wildcard $(VTUNE_PATH))","")
VTUNE_PATH=/usr/local/software/intel/vtune_amplifier_xe_2016.3.0.463186/
endif
# Libs
VTUNE_PROFILE_LIB=-Wl,--no-as-needed -ldl
LIBITTNOTIFY=$(VTUNE_PATH)/lib64/libittnotify.a
ifeq ($(wildcard LIBITTNOTIFY),)
VTUNE_PROFILE_LIB+=$(LIBITTNOTIFY)
endif
# Includes
VTUNE_PROFILE_INCLUDE=-I$(VTUNE_PATH)/include/
endif
###############################################################################
# Other
###############################################################################
ARCHIVENAME=gem3-mapper.tar