-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
358 lines (325 loc) · 14.7 KB
/
configure.ac
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#############################################################################
# Initialization
AC_PREREQ([2.69])
AC_INIT([teseo], [0.9])
AC_CONFIG_AUX_DIR([build-aux])
AC_PRESERVE_HELP_ORDER
AC_LANG([C++])
#############################################################################
# Main makefile
AC_CONFIG_FILES([Makefile include/teseo/context/static_configuration.hpp])
#############################################################################
# Set the compiler $CC and $CXX.
old_CFLAGS="${CFLAGS}"; old_CXXFLAGS="${CXXFLAGS}" dnl Do not automatically set -g -O2
AC_PROG_CC([gcc cc clang icc])
AC_PROG_CXX([g++ cxx clang++ icpc c++])
CFLAGS="${old_CFLAGS}"; unset old_CFLAGS; CXXFLAGS="${old_CXXFLAGS}"; unset old_CXXFLAGS;
AX_CXX_COMPILE_STDCXX_17 dnl Ask for C++17, thanks!
#############################################################################
# Check whether the user has explicitly set CPPFLAGS, CFLAGS and CXXFLAGS. If
# so we try to avoid polluting these flags and respect the user setting
m4_divert_push([INIT_PREPARE])
if test "x${CPPFLAGS}" != "x"; then ac_user_cppflags="yes"; fi
if test "x${CFLAGS}" != "x"; then ac_user_cflags="yes"; fi
if test "x${CXXFLAGS}" != "x"; then ac_user_cxxflags="yes"; fi
m4_divert_pop([INIT_PREPARE])
#############################################################################
# pthreads
AC_SEARCH_LIBS([pthread_create], [pthread], [],
[ AC_MSG_ERROR([missing prerequisite: this program requires pthreads to work]) ])
#############################################################################
# NUMA support
AC_ARG_ENABLE([numa], AS_HELP_STRING([--enable-numa], [Whether to enable support for NUMA. It requires a dependency on libnuma.]))
if test x"${enable_numa}" = x"" -o x"${enable_numa}" = x"yes" ; then
have_libnuma="yes"
AC_CHECK_HEADERS([numaif.h numa.h], [], [have_libnuma="no"; break;], [ [/* avoid default includes */] ])
AS_IF([test x"${have_libnuma}" == x"yes"], [AC_SEARCH_LIBS([numa_available], [numa], [], [have_libnuma="no"])])
AS_IF([test x"${have_libnuma}" == x"yes"], [
AC_RUN_IFELSE([dnl
AC_LANG_PROGRAM(
[
#include <fstream>
#include <numa.h>
#include <iostream>
using namespace std;
],
[
// first check, numa_available() must return a value >= 0, otherwise any call to libnuma is invalid
if(numa_available() < 0) {
cerr << "NUMA ERROR: numa_available() returned: " << numa_available() << ", expected a non negative value.\n";
return 1;
}
// second check, the nodes available must be a contiguous sequence in @<:@0,... N). Arbitrary node IDs
// and gaps are simply not supported by the current implementation.
struct bitmask* bitmask = numa_get_mems_allowed();
int num_nodes = 0;
for(int i = 0, end = numa_num_possible_nodes(); i < end; i++){
if(numa_bitmask_isbitset(bitmask, i)){
if(i != num_nodes){
cerr << "NUMA ERROR: NUMA support for arbitrary node IDs is not implemented. Node ID: " << i << ", expected: " << num_nodes << "\n";
return 1;
}
num_nodes++;
}
}
numa_free_nodemask(bitmask);
// now that we got that figured out, pass to the caller the actual number of nodes available in the system
fstream f(".biscotto", ios::out);
f << num_nodes;
f.close();
return 0;
]
)
], [conf_numa_num_nodes="$(cat .biscotto)"; rm .biscotto;], [have_libnuma="no"; AC_MSG_WARN([libnuma test failed, check config.log for the string "NUMA ERROR:"])])
])
fi
if test x"${have_libnuma}" == x"yes"; then
AC_MSG_NOTICE([NUMA support enabled...])
conf_numa_enabled="true"
info_numa_support="yes, ${conf_numa_num_nodes} node(s) detected";
elif test x"${enable_numa}" == x"yes"; then
AC_MSG_ERROR([unable to support NUMA in this system]);
else
AC_MSG_WARN([libnuma support disabled...])
conf_numa_enabled="false"
conf_numa_num_nodes="1";
info_numa_support="no";
fi
#############################################################################
# libevent >2.1.1
for header in "event2/event.h" "event2/thread.h"; do
AC_CHECK_HEADER([${header}], [],
[AC_MSG_ERROR([missing prerequisite: this program requires the headers for libevent v2.1.x with support for pthreads]) ],
[ [/* avoid default includes */] ])
done
AC_SEARCH_LIBS([libevent_global_shutdown], [event_core event], [],
[ AC_MSG_ERROR([missing prerequisite: this program requires libevent]) ])
AC_SEARCH_LIBS([evthread_use_pthreads], [event_pthreads event], [],
[ AC_MSG_ERROR([missing prerequisite: this program requires libevent with support for pthreads]) ])
#############################################################################
# Position independent code (PIC)
dnl first argument is the variable with the flags, the second argument is the language
m4_defun([_my_set_pic], [
m4_pushdef([_FLAGS], [m4_translit([$1], [+], [X])FLAGS]) dnl => CFLAGS, CXXFLAGS
AC_LANG_PUSH([$1])
MY_SET_CC_FLAG([_FLAGS], [-fPIC])
AC_LANG_POP([$1])
m4_popdef([_FLAGS])
])
#_my_set_pic([C]) # 24/Apr/2020 disable PIC
#_my_set_pic([C++])
m4_undefine([_my_set_pic])
#############################################################################
# Debug flags (-g)
MY_ARG_ENABLE([debug],
[Whether to enable the debug flags],
[yes no], [yes])
dnl first argument is the variable with the flags, the second argument is the language
m4_defun([_my_set_debug_flags], [
m4_pushdef([_FLAGS], [m4_translit([$1], [+], [X])FLAGS]) dnl => CFLAGS, CXXFLAGS
[if test -n "${ac_user_]m4_tolower(_FLAGS)[}"; then]
AC_MSG_WARN([Action --enable-debug ignored as _FLAGS has been explicitly set through command line])
else
# Append either -g or -g3
AC_LANG_PUSH([$1])
AX_CHECK_COMPILE_FLAG([[-g3]], [AS_VAR_APPEND([_FLAGS], " -g3")], [AS_VAR_APPEND([_FLAGS], " -g")] )
# Force clang to emit the whole debug information
MY_SET_CC_FLAG([_FLAGS], [-fno-limit-debug-info])
MY_SET_CC_FLAG([_FLAGS], [-fno-omit-frame-pointer])
AC_LANG_POP([$1])
fi
m4_popdef([_FLAGS])
])
if( test x"${enable_debug}" = x"yes" ); then
_my_set_debug_flags([C])
_my_set_debug_flags([C++])
fi
m4_undefine([_my_set_debug_flags])
#############################################################################
# Warning flags (-Wall)
MY_ARG_ENABLE([warnings],
[Whether to enable all warnings (-Wall)],
[yes no], [yes])
m4_defun([_my_set_warnings], [
m4_pushdef([_FLAGS], [m4_translit([$1], [+], [X])FLAGS]) dnl => CFLAGS, CXXFLAGS
[if test -n "${ac_user_]m4_tolower(_FLAGS)[}"; then]
AC_MSG_WARN([Action --enable-warnings ignored as _FLAGS has been explicitly set through command line])
[else]
AS_VAR_APPEND([_FLAGS], [" -Wall"])
[fi]
m4_popdef([_FLAGS])
])
if( test x"${enable_warnings}" = x"yes" ); then
_my_set_warnings([C])
_my_set_warnings([CXX])
fi
m4_undefine([_my_set_warnings])
#############################################################################
# Optimization flags (-O3)
MY_ARG_ENABLE([optimize], [Whether to enable the optimization flags], [yes no], [no])
m4_defun([_my_set_optimization_flags], [
m4_pushdef([_FLAGS], [m4_translit([$1], [+], [X])FLAGS]) dnl => CFLAGS, CXXFLAGS
[if test -n "${ac_user_]m4_tolower(_FLAGS)[}"; then]
AC_MSG_WARN([Action --enable-optimize ignored as _FLAGS has been explicitly set through command line])
[else]
if( test x"${enable_optimize}" = x"yes" ); then
AS_VAR_APPEND([_FLAGS], [[" -O3"]])
AC_LANG_PUSH([$1])
MY_SET_CC_FLAG([_FLAGS], [-march=native])
MY_SET_CC_FLAG([_FLAGS], [-mtune=native])
MY_SET_CC_FLAG([_FLAGS], [-fno-stack-protector])
AC_LANG_POP([$1])
else
AS_VAR_APPEND([_FLAGS], [[" -O0"]])
fi
[fi]
m4_popdef([_FLAGS])
])
_my_set_optimization_flags([C])
_my_set_optimization_flags([C++])
m4_undefine([_my_set_optimization_flags])
#############################################################################
# Assertions. Possible values:
# yes => nop
# no => CPPFLAGS += -DNDEBUG
# auto => yes if the optimize mode is not enabled, no otherwise
MY_ARG_ENABLE([assert],
[Whether to enable assertions. The option 'auto' implies the assertions are enabled when --enable-optimize is not specified],
[yes no auto], [auto])
if (test x"${enable_assert}" = x"auto"); then
if (test x"${enable_optimize}" != x"yes"); then
enable_assert=yes
else
enable_assert=no
fi
fi
if (test x"${enable_assert}" = x"yes"); then
: ; # nop
elif (test x"${enable_assert}" = x"no"); then
CPPFLAGS="${CPPFLAGS} -DNDEBUG"
else
AC_MSG_ERROR([Invalid value for --enable-assert: ${enable_assert}])
fi
#############################################################################
# Enable one of the compiler sanitizer, by default the address sanitizer (ASAN). Possible values:
# "" => CPPFLAGS += -fsanitize=address
# <value> => CPPFLAGS += -fsanitize=<value>
AC_ARG_ENABLE([sanitize],
AS_HELP_STRING([--enable-sanitize@<:@=ARG@:>@], [Instruments the code with either the given
sanitizer `ARG' or the default address sanitizer (ASAN) when one is not explicitly provided.]),
[sanitize="${enableval}"],
[sanitize=""]
)
if test x"${sanitize}" != x"" -a x"${sanitize}" != x"no" ; then
if test x"${sanitize}" == x"yes"; then
sanitize="address"
fi
CPPFLAGS="${CPPFLAGS} -fsanitize=${sanitize}"
LDFLAGS="${LDFLAGS} -fsanitize=${sanitize}"
fi
#############################################################################
# Test mode
MY_ARG_ENABLE([test],
[Create a static configuration of the memstore suitable for testing],
[yes no], [no])
if test x"${enable_test}" == x"yes"; then
test_mode="true";
conf_async_num_threads="2";
conf_aux_counting_tree_capacity_inodes="5";
conf_aux_counting_tree_capacity_leaves="4";
conf_crawler_calibrator_tree_height="0";
conf_memstore_max_num_segments_per_leaf="4";
conf_memstore_payload_file_first_block_size="16";
conf_memstore_payload_file_next_block_size="16";
conf_memstore_segment_size="34"; # 1 for the header, 2 for the cached pivot, 31 for the content
conf_runtime_num_threads="2";
conf_runtime_txnlist_refresh="1"; # millisecs
conf_tclist_initial_capacity="4";
conf_transaction_memory_pool_size="8";
conf_vertex_table_min_capacity="2";
else
test_mode="false";
conf_async_num_threads="8";
conf_aux_counting_tree_capacity_inodes="63";
conf_aux_counting_tree_capacity_leaves="64";
conf_crawler_calibrator_tree_height="0";
conf_memstore_max_num_segments_per_leaf="128";
conf_memstore_payload_file_first_block_size="510"; # 2 words for the header
conf_memstore_payload_file_next_block_size="254"; # 2 words for the header
conf_memstore_segment_size="512";
conf_runtime_num_threads="0";
conf_runtime_txnlist_refresh="60"; # millisecs
conf_tclist_initial_capacity="128";
conf_transaction_memory_pool_size="1<<16";
conf_vertex_table_min_capacity="1<<19";
fi
#############################################################################
# Support for huge pages
dnl -- Dean 27/Oct/2020: support for huge pages removed. In the experiments there were no significant gains in using them.
dnl MY_ARG_ENABLE([huge-pages],
dnl [Enable the support for huge pages (2MB)],
dnl [yes no], [no])
dnl if test x"${enable_huge_pages}" == x"yes"; then
dnl conf_huge_pages="true";
dnl info_huge_pages="yes, up to ${info_bp_max_size}";
dnl else
dnl conf_huge_pages="false";
dnl info_huge_pages="no";
dnl fi
#############################################################################
# Profile the execution:
AC_ARG_ENABLE([profile], AS_HELP_STRING([--enable-profile], [Whether to profile the execution [Default: no]]), [CPPFLAGS="${CPPFLAGS} -DHAVE_PROFILER"])
#############################################################################
# Remove extra blanks from our variables
EXTRA_CPPFLAGS=$(echo ${EXTRA_CPPFLAGS} | xargs)
CPPFLAGS=$(echo ${CPPFLAGS} | xargs);
CFLAGS=$(echo ${CFLAGS} | xargs);
EXTRA_CFLAGS=$(echo ${EXTRA_CFLAGS} | xargs);
CXXFLAGS=$(echo ${CXXFLAGS} | xargs);
EXTRA_CXXFLAGS=$(echo ${EXTRA_CXXFLAGS} | xargs);
EXTRA_LDFLAGS=$(echo ${EXTRA_LDFLAGS} | xargs);
# these two variables are only for presentation, overriding won't achieve much
ALL_CFLAGS=$(echo ${EXTRA_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CFLAGS} ${CFLAGS} | xargs)
ALL_CXXFLAGS=$(echo ${EXTRA_CPPFLAGS} ${CPPFLAGS} ${EXTRA_CXXFLAGS} ${CXXFLAGS} | xargs)
LDFLAGS="${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
#############################################################################
# CC, CXX and linker additional output variables
AC_SUBST([EXTRA_CPPFLAGS])
AC_SUBST([EXTRA_CFLAGS])
AC_SUBST([EXTRA_CXXFLAGS])
# Static configuration
AC_SUBST([test_mode])
AC_SUBST([conf_async_num_threads])
AC_SUBST([conf_aux_counting_tree_capacity_inodes])
AC_SUBST([conf_aux_counting_tree_capacity_leaves])
AC_SUBST([conf_crawler_calibrator_tree_height])
dnl AC_SUBST([conf_huge_pages]) # support for huge pages removed
AC_SUBST([conf_memstore_max_num_segments_per_leaf])
AC_SUBST([conf_memstore_payload_file_first_block_size])
AC_SUBST([conf_memstore_payload_file_next_block_size])
AC_SUBST([conf_memstore_segment_size])
AC_SUBST([conf_numa_enabled])
AC_SUBST([conf_numa_num_nodes])
AC_SUBST([conf_runtime_num_threads])
AC_SUBST([conf_runtime_txnlist_refresh])
AC_SUBST([conf_tclist_initial_capacity])
AC_SUBST([conf_transaction_memory_pool_size])
AC_SUBST([conf_vertex_table_min_capacity])
#############################################################################
# Create the configure script
AC_OUTPUT
#############################################################################
# Final summary
echo \
"-------------------------------------------------
${PACKAGE_NAME} version ${PACKAGE_VERSION}
Compiler C..........: ${CC} ${ALL_CFLAGS}
Compiler C++........: ${CXX} ${ALL_CXXFLAGS}
Linker..............: ${CXX} ${LDFLAGS}
Enable assertions...: ${enable_assert}
Enable debug........: ${enable_debug}
Enable optimize.....: ${enable_optimize}
Enable NUMA support.: ${info_numa_support}
dnl Enable huge pages...: ${info_huge_pages}
Now type 'make -j'
--------------------------------------------------"