forked from BlueBrain/CoreNeuron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
338 lines (299 loc) · 13.8 KB
/
CMakeLists.txt
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
# =============================================================================
# Copyright (C) 2016-2019 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
project(coreneuron VERSION 0.18.0)
# It is a bad idea having floating point versions, since macros cant handle them
# We therefore, have version as an int, which is pretty much standard
math(EXPR CORENEURON_VERSION_COMBINED
"${coreneuron_VERSION_MAJOR} * 100 + ${coreneuron_VERSION_MINOR}")
# =============================================================================
# CMake common project settings
# =============================================================================
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Empty or one of Debug, Release, RelWithDebInfo")
# =============================================================================
# Settings to enable project as submodule
# =============================================================================
set(CORENEURON_PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CORENEURON_AS_SUBPROJECT OFF)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CORENEURON_AS_SUBPROJECT ON)
endif()
# =============================================================================
# Include cmake modules path
# =============================================================================
list(APPEND CMAKE_MODULE_PATH
${CORENEURON_PROJECT_SOURCE_DIR}/CMake
${CORENEURON_PROJECT_SOURCE_DIR}/CMake/packages
${CORENEURON_PROJECT_SOURCE_DIR}/CMake/config)
# =============================================================================
# Include common cmake modules
# =============================================================================
include(CheckIncludeFiles)
include(ReleaseDebugAutoFlags)
include(CrayPortability)
include(SetRpath)
include(CTest)
include(AddRandom123Submodule)
include(AddCLI11Submodule)
add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11)
# =============================================================================
# Build options
# =============================================================================
option(CORENRN_ENABLE_OPENMP "Build the CORE NEURON with OpenMP implementation" ON)
option(CORENRN_ENABLE_TIMEOUT "Enable nrn_timeout implementation" ON)
option(CORENRN_ENABLE_REPORTING "Enable use of ReportingLib for soma reports" OFF)
option(CORENRN_ENABLE_MPI "Enable MPI-based execution" ON)
option(CORENRN_ENABLE_SOA "Enable SoA Memory Layout" ON)
option(CORENRN_ENABLE_HOC_EXP "Enable wrapping exp with hoc_exp()" OFF)
option(CORENRN_ENABLE_SPLAYTREE_QUEUING "Enable use of Splay tree for spike queuing" ON)
option(CORENRN_ENABLE_NET_RECEIVE_BUFFER "Enable event buffering in net_receive function" ON)
option(CORENRN_ENABLE_ISPC "Enable ispc interoperability structs and data" OFF)
option(CORENRN_ENABLE_NMODL "Enable external nmodl source-to-source compiler" OFF)
option(CORENRN_ENABLE_CALIPER_PROFILING "Enable Caliper instrumentation" OFF)
option(CORENRN_ENABLE_LIKWID_PROFILING "Enable LIKWID instrumentation" OFF)
option(CORENRN_ENABLE_CUDA_UNIFIED_MEMORY "Enable CUDA unified memory support" OFF)
option(CORENRN_ENABLE_UNIT_TESTS "Enable unit tests execution" ON)
option(CORENRN_ENABLE_GPU "Enable GPU support using OpenACC" OFF)
option(CORENRN_ENABLE_SHARED "Enable shared library build" ON)
set(CORENRN_NMODL_DIR "" CACHE PATH "Path to nmodl source-to-source compiler installation")
set(LIKWID_DIR "" CACHE PATH "Path to likwid performance analysis suite")
set(CORENRN_FRONTEND_C_COMPILER gcc CACHE FILEPATH "C compiler for building mod2c [frontend]")
set(CORENRN_FRONTEND_CXX_COMPILER g++ CACHE FILEPATH "C++ compiler for building mod2c [frontend]")
if (CORENEURON_AS_SUBPROJECT)
set(CORENRN_ENABLE_UNIT_TESTS OFF)
endif()
# =============================================================================
# Include cmake modules after cmake options
# =============================================================================
include(OpenAccHelper)
include(ClangFormatHelper)
# =============================================================================
# Common dependencies
# =============================================================================
find_package(PythonInterp REQUIRED)
# =============================================================================
# ISPC should compile with --pic by default
# =============================================================================
set(CMAKE_ISPC_FLAGS "--pic ${CMAKE_ISPC_FLAGS}")
# =============================================================================
# Common build options
# =============================================================================
# build mod files for coreneuron
add_definitions(-DCORENEURON_BUILD)
set(CMAKE_REQUIRED_QUIET TRUE)
check_include_files(malloc.h have_malloc_h)
if(have_malloc_h)
add_definitions("-DHAVE_MALLOC_H")
endif()
# =============================================================================
# Build option specific compiler flags
# =============================================================================
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "PGI")
add_definitions(-DSWAP_ENDIAN_DISABLE_ASM)
# PGI with llvm code generation doesn't have necessary assembly intrinsic headers
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
endif()
# OpenACC needs to build static library in order to have global/routines
# working. See https://www.pgroup.com/userforum/viewtopic.php?t=5350
if(CORENRN_ENABLE_SHARED AND NOT CORENRN_ENABLE_GPU)
set(COMPILE_LIBRARY_TYPE "SHARED")
else()
set(COMPILE_LIBRARY_TYPE "STATIC")
endif()
if(CORENRN_ENABLE_ISPC)
enable_language(ISPC)
add_definitions("-DISPC_INTEROP=1")
set(CORENRN_ENABLE_NMODL ON)
endif()
if(CORENRN_ENABLE_MPI)
find_package(MPI REQUIRED)
add_definitions("-DNRNMPI=1")
else()
add_definitions("-DNRNMPI=0")
add_definitions("-DNRN_MULTISEND=0")
endif()
if(CORENRN_ENABLE_OPENMP)
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} ${ADDITIONAL_THREADSAFE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} ${ADDITIONAL_THREADSAFE_FLAGS}")
endif()
endif()
if(CORENRN_ENABLE_SOA)
add_definitions("-DLAYOUT=0")
else()
add_definitions("-DLAYOUT=1")
endif()
if(NOT CORENRN_ENABLE_HOC_EXP)
add_definitions("-DDISABLE_HOC_EXP")
endif()
# splay tree required for net_move
if(CORENRN_ENABLE_SPLAYTREE_QUEUING)
add_definitions("-DENABLE_SPLAYTREE_QUEUING")
endif()
if(NOT CORENRN_ENABLE_NET_RECEIVE_BUFFER)
add_definitions("-DNET_RECEIVE_BUFFERING=0")
endif()
if(NOT CORENRN_ENABLE_TIMEOUT)
add_definitions("-DDISABLE_TIMEOUT")
endif()
if(CORENRN_ENABLE_REPORTING)
find_package(reportinglib)
find_package(sonata)
find_program (H5DUMP_EXECUTABLE h5dump)
if(NOT reportinglib_FOUND AND NOT sonata_FOUND)
message(SEND_ERROR "Neither reportinglib nor SONATA libraries were found")
elseif(reportinglib_FOUND AND sonata_FOUND)
add_definitions("-DENABLE_BIN_REPORTS")
add_definitions("-DENABLE_SONATA_REPORTS")
elseif(reportinglib_FOUND)
add_definitions("-DENABLE_BIN_REPORTS")
set(ENABLE_BIN_REPORTS ON)
else() # sonata_FOUND
if(TARGET sonata::sonata_report)
add_definitions("-DENABLE_SONATA_REPORTS")
set(ENABLE_SONATA_REPORTS ON)
set(reportinglib_INCLUDE_DIR "")
set(reportinglib_LIBRARY "")
else()
message(SEND_ERROR "SONATA library was found but without reporting support")
endif()
endif()
include_directories(${reportinglib_INCLUDE_DIR})
include_directories(${sonatareport_INCLUDE_DIR})
endif()
if(MINGW)
add_definitions("-DMINGW")
endif()
# =============================================================================
# NMODL specific options
# =============================================================================
if(CORENRN_ENABLE_NMODL)
find_package(nmodl)
if (nmodl_FOUND)
set(CORENRN_NMODL_BINARY ${nmodl_BINARY})
set(CORENRN_NMODL_INCLUDE ${nmodl_INCLUDE})
# path to python interface
set(ENV{PYTHONPATH} "${nmodl_PYTHONPATH}:$ENV{PYTHONPATH}")
set(CORENRN_NMODL_PYTHONPATH $ENV{PYTHONPATH})
else()
include(AddNmodlSubmodule)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/nmodl${CMAKE_EXECUTABLE_SUFFIX})
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
set(ENV{PYTHONPATH} "$ENV{PYTHONPATH}")
set(nmodl_PYTHONPATH "${CMAKE_BINARY_DIR}/lib")
set(CORENRN_NMODL_PYTHONPATH "${nmodl_PYTHONPATH}:$ENV{PYTHONPATH}")
endif()
include_directories(${CORENRN_NMODL_INCLUDE})
# set correct arguments for nmodl for cpu/gpu target
set(CORENRN_NMODL_FLAGS "" CACHE STRING "Extra NMODL options such as passes")
if(CORENRN_ENABLE_GPU)
string(APPEND CORENRN_NMODL_FLAGS " acc --oacc")
endif()
separate_arguments(NMODL_EXTRA_FLAGS_LIST UNIX_COMMAND "${CORENRN_NMODL_FLAGS}")
else()
include(AddMod2cSubmodule)
set(CORENRN_NMODL_BINARY ${CMAKE_BINARY_DIR}/bin/mod2c_core${CMAKE_EXECUTABLE_SUFFIX})
set(CORENRN_NMODL_INCLUDE ${CMAKE_BINARY_DIR}/include)
endif()
# =============================================================================
# Profiler/Instrumentation Options
# =============================================================================
if(CORENRN_ENABLE_CALIPER_PROFILING)
find_package(caliper REQUIRED)
include_directories(${caliper_INCLUDE_DIR})
add_definitions("-DCORENEURON_CALIPER")
set(CALIPER_LIB "caliper")
if(CORENRN_ENABLE_MPI)
set(CALIPER_MPI_LIB "caliper-mpi")
endif()
endif()
if(CORENRN_ENABLE_LIKWID_PROFILING)
find_package(likwid REQUIRED)
include_directories(${likwid_INCLUDE_DIRS})
add_definitions("-DLIKWID_PERFMON")
endif()
# =============================================================================
# Add main directories
# =============================================================================
add_subdirectory(coreneuron)
add_subdirectory(extra)
if(CORENRN_ENABLE_UNIT_TESTS)
add_subdirectory(tests)
endif()
# =============================================================================
# Install cmake modules
# =============================================================================
install(FILES CMake/coreneuron-config.cmake DESTINATION share/cmake)
install(EXPORT coreneuron DESTINATION share/cmake)
# just for printing the compiler flags in the build status
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
if(BUILD_TYPE_UPPER MATCHES "CUSTOM")
set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}}")
endif()
# =============================================================================
# Build status
# =============================================================================
message(STATUS "")
message(STATUS "Configured CoreNEURON ${PROJECT_VERSION}")
message(STATUS "")
string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_tolower)
if(cmake_generator_tolower MATCHES "makefile")
message(STATUS "Some things you can do now:")
message(STATUS "--------------------+--------------------------------------------------------")
message(STATUS "Command | Description")
message(STATUS "--------------------+--------------------------------------------------------")
message(STATUS "make install | Will install CoreNEURON to: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "--------------------+--------------------------------------------------------")
message(STATUS " Build option | Status")
message(STATUS "--------------------+--------------------------------------------------------")
message(STATUS "COMPILE FLAGS | ${COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
message(STATUS "Build Type | ${COMPILE_LIBRARY_TYPE}")
message(STATUS "MPI | ${CORENRN_ENABLE_MPI}")
if(CORENRN_ENABLE_MPI)
message(STATUS " INC | ${MPI_C_INCLUDE_PATH}")
endif()
message(STATUS "OpenMP | ${CORENRN_ENABLE_OPENMP}")
message(STATUS "NMODL | ${CORENRN_ENABLE_NMODL}")
if(CORENRN_ENABLE_NMODL)
message(STATUS " PATH | ${CORENRN_NMODL_BINARY}")
message(STATUS " ISPC | ${CORENRN_ENABLE_ISPC}")
message(STATUS " FLAGS | ${CORENRN_NMODL_FLAGS}")
else()
message(STATUS "MOD2C | ${MOD2C_PROJ}")
endif()
message(STATUS "GPU Support | ${CORENRN_ENABLE_GPU}")
if(CORENRN_ENABLE_GPU)
message(STATUS " CUDA | ${CUDA_TOOLKIT_ROOT_DIR}")
message(STATUS " Unified Memory | ${CORENRN_ENABLE_CUDA_UNIFIED_MEMORY}")
message(STATUS " HOST COMPILER | ${CUDA_HOST_COMPILER}")
endif()
message(STATUS "Auto Timeout | ${CORENRN_ENABLE_TIMEOUT}")
message(STATUS "Wrap exp() | ${CORENRN_ENABLE_HOC_EXP}")
message(STATUS "SplayTree Queue | ${CORENRN_ENABLE_SPLAYTREE_QUEUING}")
message(STATUS "NetReceive Buffer | ${CORENRN_ENABLE_NET_RECEIVE_BUFFER}")
message(STATUS "Caliper | ${CORENRN_ENABLE_CALIPER_PROFILING}")
message(STATUS "Likwid | ${CORENRN_ENABLE_LIKWID_PROFILING}")
message(STATUS "Unit Tests | ${CORENRN_ENABLE_UNIT_TESTS}")
message(STATUS "Reporting | ${CORENRN_ENABLE_REPORTING}")
if(CORENRN_ENABLE_REPORTING)
message(STATUS " sonatareport_INC | ${sonatareport_INCLUDE_DIR}")
message(STATUS " sonatareport_LIB | ${sonatareport_LIBRARY}")
message(STATUS " reportinglib_INC | ${reportinglib_INCLUDE_DIR}")
message(STATUS " reportinglib_LIB | ${reportinglib_LIBRARY}")
endif()
message(STATUS "--------------+--------------------------------------------------------------")
message(STATUS " See documentation : https://github.com/BlueBrain/CoreNeuron/")
message(STATUS "--------------+--------------------------------------------------------------")
endif()
message(STATUS "")