-
Notifications
You must be signed in to change notification settings - Fork 57
/
configure.ac
266 lines (220 loc) · 9.5 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
# -*- Autoconf -*-
#
# Copyright (c) 2018-2023, Amazon.com, Inc. or its affiliates. All rights reserved.
#
# See LICENSE.txt for license information
#
# Initialization
AC_INIT([aws-ofi-nccl], [GitHub-dev], [al-ofi-nccl-team@amazon.com], , [http://github.com/aws/aws-ofi-nccl])
AC_PREREQ([2.69])
AC_CONFIG_SRCDIR([src/nccl_ofi_net.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects tar-pax])
AM_SILENT_RULES([yes])
AH_TOP([/*
* Copyright (c) 2018-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
*/
#ifndef NCCL_OFI_CONFIG_H
#define NCCL_OFI_CONFIG_H
])
AH_BOTTOM([
#include "nccl_ofi_config_bottom.h"
#endif /* NCCL_OFI_CONFIG_H */
])
dnl AX_CHECK_ENABLE_DEBUG must be called before AC_PROG_CC or
dnl AM_PROG_AR
AX_CHECK_ENABLE_DEBUG([no])
dnl Enable _GNU_SOURCE and other system extensions. The plugin uses several
dnl nonstandard system functions, and the plugin only supports Linux OSes, so
dnl the risk of silently enabling system extensions is minimal.
AC_USE_SYSTEM_EXTENSIONS
dnl AM_PROG_AR must be called before LT_INIT
AM_PROG_AR
AC_PROG_RANLIB
LT_INIT([shared disable-static pic-only])
NCCL_NET_OFI_DISTCHCK_CONFIGURE_FLAGS=
# Checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
AC_C_INLINE
dnl ac_check_enable_debug will make sure AC_PROG_CC doesn't add a
dnl bunch of debugging flags, so there's no ordering requirement
dnl between this and AC_PROG_CC.
AS_IF([test "${ax_enable_debug}" = "no"], [
dnl Enable O3 optimization
CFLAGS="${CFLAGS} -O3"
CXXFLAGS="${CXXFLAGS} -O3"
dnl use C++17, disable exceptions, and disable runtime type information
CXXFLAGS="-std=c++17 -fno-rtti -fno-exceptions"
dnl dead code elim
CFLAGS="${CFLAGS} -ffunction-sections -fdata-sections"
CXXFLAGS="${CXXFLAGS} -ffunction-sections -fdata-sections"
dnl https://maskray.me/blog/2021-05-09-fno-semantic-interposition
CFLAGS="${CFLAGS} -fno-semantic-interposition -fvisibility=hidden"
CXXFLAGS="${CXXFLAGS} -fno-semantic-interposition -fvisibility=hidden "
LDFLAGS="${LDFLAGS} -Bsymbolic"
])
CHECK_ENABLE_SANITIZER()
# Checks for header files
AC_HEADER_STDBOOL
AS_IF([test "${ac_cv_header_stdbool_h}" = "no"],
[AC_MSG_ERROR([NCCL OFI Plugin requires stdbool.h])])
AC_CHECK_HEADER([limits.h], [], [AC_MSG_ERROR([NCCL OFI Plugin rquires limits.h])])
AC_CHECK_HEADER([stdlib.h], [], [AC_MSG_ERROR([NCCL OFI Plugin rquires stdlib.h])])
AC_CHECK_HEADER([string.h], [], [AC_MSG_ERROR([NCCL OFI Plugin rquires string.h])])
AC_CHECK_HEADER([unistd.h], [], [AC_MSG_ERROR([NCCL OFI Plugin rquires unistd.h])])
AC_CHECK_HEADERS([linux/limits.h])
# Checks for types
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT64_T
# Checks for library functions
AC_FUNC_MALLOC
AC_CHECK_FUNC([memset], [], [AC_MSG_ERROR([NCCL OFI Plugin requires memset function.])])
AC_CHECK_FUNC([realpath], [], [AC_MSG_ERROR([NCCL OFI Plugin requires realpath function.])])
AC_CHECK_FUNCS([gettid])
AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([NCCL OFI Plugin requires dlopen])])
dnl it is insufficient to just link against pthread with -lpthread
dnl background: https://stackoverflow.com/a/23251828
CPPFLAGS="${CPPFLAGS} -pthread"
LDFLAGS="${LDFLAGS} -pthread"
AC_SEARCH_LIBS([pthread_mutexattr_settype], [pthread], [], [AC_MSG_ERROR([NCCL OFI Plugin requires pthreads.])])
AC_SEARCH_LIBS([log2], [m], [], [AC_MSG_ERROR([NCCL OFI Plugin requires the log2 library function.])])
dnl Need at least glibc 2.3 or later (released 2002-10-02) , because
dnl 2.2.3 added support for atexit() in shared libraries.
AC_MSG_CHECKING([for glibc 2.3 or later])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <gnu/libc-version.h>
]],
[[#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 3)
#error "Glibc too old to support atexit."
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Found glibc prior to version 2.3. Version 2.3 or later required])])
# Checks for external packages
CHECK_PKG_LIBFABRIC([], [AC_MSG_ERROR([NCCL OFI Plugin could not find a working Libfabric install.])])
have_device_interface=no
CHECK_PKG_NEURON([AS_IF([test -n "${want_cuda}"],
[AC_MSG_ERROR([Cannot enable both CUDA and neuron.])],
[want_cuda=no])
have_device_interface=neuron])
CHECK_PKG_CUDA([have_device_interface=cuda])
AS_IF([test "${have_device_interface}" = "no"],
[AC_MSG_ERROR([NCCL OFI Plugin requires either CUDA or Neuron runtime.])])
DEVICE_INTERFACE="${have_device_interface}"
AC_SUBST([DEVICE_INTERFACE])
CHECK_PKG_LTTNG()
CHECK_PKG_NVTX()
CHECK_PKG_HWLOC([],
[AC_MSG_ERROR([Could not find the hwloc library. Use --with-hwloc to provide the path to non-standard hwloc installation.])])
CHECK_PKG_VALGRIND()
CHECK_VAR_REDZONE()
NCCL_OFI_PLATFORM="none"
AS_IF([test "${NCCL_OFI_PLATFORM}" = "none"], [AX_CHECK_PLATFORM_AWS()])
AS_IF([test "${valgrind_enabled}" = "1" -a "${enable_asan}" = "yes"],
[AC_MSG_ERROR([Enabling ASAN and valgrind at the same time is not permitted])])
CHECK_ENABLE_MEMFD_CREATE()
# do we want our tests?
CHECK_PKG_MPI([found_mpi="yes"], [found_mpi="no"])
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--disable-tests], [Disable build of unit/functional test binaries])])
build_unit_tests=yes
build_func_tests=yes
AS_IF([test "${enable_tests}" == "no"],
[build_unit_tests=no build_func_tests=no])
AS_IF([test "${enable_tests}" != "no" -a "${found_mpi}" = "no" ],
[AC_MSG_WARN([Cannot build functional tests without MPI. Disabling functional tests.])
build_func_tests=no])
AS_IF([test "${enable_tests}" != "no" -a "${have_device_interface}" = "neuron" ],
[AC_MSG_WARN([Functional tests not available on neuron, disabling.])
build_func_tests=no])
AM_CONDITIONAL([ENABLE_UNIT_TESTS], [test "$build_unit_tests" == "yes"])
AM_CONDITIONAL([ENABLE_FUNC_TESTS], [test "$build_func_tests" == "yes"])
# Enable output at the TRACE level for unit tests.
AC_ARG_ENABLE([trace],
[AS_HELP_STRING([--enable-trace], [Enable printing trace messages in test programs])])
AC_MSG_CHECKING([whether to enable trace messages])
AS_IF([test "${enable_trace}" = "yes" ],
[trace=1
AC_MSG_RESULT(yes)],
[trace=0
AC_MSG_RESULT(no)])
AC_DEFINE_UNQUOTED([OFI_NCCL_TRACE], [${trace}], [Defined to 1 unit test output should include TRACE level])
picky_cflags=""
picky_cxxflags=""
AC_DEFUN([ADD_PICKY_FLAGS],[
AC_LANG_PUSH([C])
AX_CHECK_COMPILE_FLAG([$1], [picky_cflags="${picky_cflags} $1"], [], [-Werror])
AC_LANG_POP()
AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([$1], [picky_cxxflags="${picky_cxxflags} $1"], [], [-Werror -x c++])
AC_LANG_POP()
])
dnl standard and normal
ADD_PICKY_FLAGS([-Wall -Wextra])
dnl C specific warning that warngs when using C features which prevent parsing
dnl as C++. Best-effort, and doesn't cover everything.
ADD_PICKY_FLAGS([-Wc++-compat])
dnl gcc manual says this is enabled with c++-compat, but seemingly bugged.
ADD_PICKY_FLAGS([-Wjump-misses-init])
dnl some top-level API functions have unused parameters, but we have to keep
dnl them. TODO: explicitly annotate those functions, rather than setting this
dnl globally.
ADD_PICKY_FLAGS([-Wno-unused-parameter])
dnl warn when a variable shadows another variable.
ADD_PICKY_FLAGS([-Wshadow])
dnl warn on security issues around functions that format output (ie printf)
ADD_PICKY_FLAGS([-Wformat=2])
dnl warn for potential performance problem casts
ADD_PICKY_FLAGS([-Wcast-align])
dnl warn if a null dereference is detected
ADD_PICKY_FLAGS([-Wnull-dereference])
dnl warn when a case statement is missing a break or a line that contains a
dnl comment before the next case.
ADD_PICKY_FLAGS([-Wimplicit-fallthrough=2])
dnl functions should either have internal linkage (static) or there should be a
dnl header declarating the function.
ADD_PICKY_FLAGS([-Wmissing-declarations])
dnl enable GCC's static analyzer
ADD_PICKY_FLAGS([-fanalyzer])
dnl todo: clang-sa flags
AC_ARG_ENABLE([picky-compiler],
[AS_HELP_STRING([--disable-picky-compiler], [Disable adding picky compiler flags.])])
AS_IF([test "${enable_picky_compiler}" != "no"],
[AC_MSG_NOTICE([Adding ${picky_cflags} to CFLAGS.])
CFLAGS="${CFLAGS} ${picky_cflags}"
CXXFLAGS="${CXXFLAGS} ${picky_cxxflags}"
AS_UNSET([picky_cxxflags])
AS_UNSET([picky_cflags])])
werror_flags="-Werror"
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror], [(Developer) Enable setting -Werror. Off by default, unless building from Git tree.])])
AS_IF([test -d "${srcdir}/.git" -a -z "${enable_werror}"],
[AC_MSG_NOTICE([Found .git directory. Adding ${werror_flags} to CFLAGS.])
CXXFLAGS="${werror_flags} ${CXXFLAGS} "
CFLAGS="${werror_flags} ${CFLAGS} "],
[test "${enable_werror}" = "yes"],
[AC_MSG_NOTICE([Adding ${werror_flags} to CFLAGS.])
CXXFLAGS="${werror_flags} ${CXXFLAGS} "
CFLAGS="${werror_flags} ${CFLAGS} "])
AC_SUBST([NCCL_NET_OFI_DISTCHCK_CONFIGURE_FLAGS])
AC_CONFIG_FILES([Makefile
include/Makefile
3rd-party/Makefile
src/Makefile
tests/Makefile
tests/functional/Makefile
tests/unit/Makefile
topology/Makefile])
AC_OUTPUT
echo "*"
echo "* AWS OFI NCCL plugin has been configured."
echo "*"
echo "* Platform-specific optimizations: ${NCCL_OFI_PLATFORM}"
echo "*"