Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 03de9b6

Browse files
authored
CMake / build system improvements + remove outdated warning (#517)
* Include PR#95 and PR#96 in hpc-coding-conventions - Use the new `cpp_cc_build_time_copy` helper function to help set up build rules properly. * Remove outdated warning for VectorPlay support in GPUs. * Improve build dependency declarations.
1 parent dd57745 commit 03de9b6

File tree

5 files changed

+46
-33
lines changed

5 files changed

+46
-33
lines changed

.cmake-format.changes.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ additional_commands:
44
flags: ["STATIC", "SHARED", "MODULE", "EXCLUDE_FROM_ALL"]
55
kwargs:
66
OPTIONS: '*'
7+
cpp_cc_build_time_copy:
8+
flags: ['NO_TARGET']
9+
kwargs:
10+
INPUT: '1'
11+
OUTPUT: '1'

coreneuron/CMakeLists.txt

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,51 @@ set(KINDERIV_HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/_kinderiv.h")
5353

5454
set(NMODL_UNITS_FILE "${CMAKE_BINARY_DIR}/share/mod2c/nrnunits.lib")
5555

56-
# copy inbuilt mod files {source}/coreneuron/mechanism/mech/modfile/*.mod to
57-
# {build_dir}/share/modfile/
56+
# =============================================================================
57+
# Copy files that are required by nrnivmodl-core to the build tree at build time.
58+
# =============================================================================
59+
cpp_cc_build_time_copy(
60+
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/${MODFUNC_PERL_SCRIPT}"
61+
OUTPUT "${CMAKE_BINARY_DIR}/share/coreneuron/mod_func.c.pl"
62+
NO_TARGET)
63+
cpp_cc_build_time_copy(
64+
INPUT "${KINDERIV_PYTHON_SCRIPT}"
65+
OUTPUT "${CMAKE_BINARY_DIR}/share/coreneuron/kinderiv.py"
66+
NO_TARGET)
67+
cpp_cc_build_time_copy(
68+
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/${DIMPLIC_CODE_FILE}"
69+
OUTPUT "${CMAKE_BINARY_DIR}/share/coreneuron/dimplic.cpp"
70+
NO_TARGET)
71+
cpp_cc_build_time_copy(
72+
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/${ENGINEMECH_CODE_FILE}"
73+
OUTPUT "${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp"
74+
NO_TARGET)
75+
set(nrnivmodl_core_dependencies
76+
"${CMAKE_BINARY_DIR}/share/coreneuron/mod_func.c.pl"
77+
"${CMAKE_BINARY_DIR}/share/coreneuron/kinderiv.py"
78+
"${CMAKE_BINARY_DIR}/share/coreneuron/dimplic.cpp"
79+
"${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp")
80+
# Set up build rules that copy builtin mod files from
81+
# {source}/coreneuron/mechanism/mech/modfile/*.mod to {build_dir}/share/modfile/
5882
file(GLOB builtin_modfiles
5983
"${CORENEURON_PROJECT_SOURCE_DIR}/coreneuron/mechanism/mech/modfile/*.mod")
60-
# get the corresponding list of paths to the modfiles in the build directory
61-
set(builtin_modfiles_in_build_dir)
6284
foreach(builtin_modfile ${builtin_modfiles})
85+
# Construct the path in the build directory.
6386
get_filename_component(builtin_modfile_name "${builtin_modfile}" NAME)
64-
list(APPEND builtin_modfiles_in_build_dir
65-
"${CMAKE_BINARY_DIR}/share/modfile/${builtin_modfile_name}")
87+
set(modfile_build_path "${CMAKE_BINARY_DIR}/share/modfile/${builtin_modfile_name}")
88+
# Create a build rule to copy the modfile there.
89+
cpp_cc_build_time_copy(
90+
INPUT "${builtin_modfile}"
91+
OUTPUT "${modfile_build_path}"
92+
NO_TARGET)
93+
list(APPEND nrnivmodl_core_dependencies "${modfile_build_path}")
6694
endforeach()
67-
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/share/modfile")
68-
# set up a build rule that ensures the modfiles in the build directory are updated if their
69-
# counterparts in the source directory are touched
70-
add_custom_command(
71-
OUTPUT ${builtin_modfiles_in_build_dir}
72-
DEPENDS ${builtin_modfiles}
73-
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${builtin_modfiles}
74-
"${CMAKE_BINARY_DIR}/share/modfile")
75-
add_custom_target(copy-builtin-modfiles ALL DEPENDS ${builtin_modfiles_in_build_dir})
95+
add_custom_target(coreneuron-copy-nrnivmodl-core-dependencies ALL
96+
DEPENDS ${nrnivmodl_core_dependencies})
97+
# Store the build-tree modfile paths in a cache variable; these are an implicit dependency of
98+
# nrnivmodl-core.
7699
set(CORENEURON_BUILTIN_MODFILES
77-
"${builtin_modfiles_in_build_dir}"
100+
"${nrnivmodl_core_dependencies}"
78101
CACHE STRING "List of builtin modfiles that nrnivmodl-core implicitly depends on" FORCE)
79102

80103
# =============================================================================
@@ -201,15 +224,6 @@ set(CORENRN_LINK_LIBS
201224
"${CORENRN_LINK_LIBS}"
202225
PARENT_SCOPE)
203226

204-
# =============================================================================
205-
# Copy files for nrnivmodl-core workflow during build time
206-
# =============================================================================
207-
208-
configure_file(${MODFUNC_PERL_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/mod_func.c.pl COPYONLY)
209-
configure_file(${KINDERIV_PYTHON_SCRIPT} ${CMAKE_BINARY_DIR}/share/coreneuron/kinderiv.py COPYONLY)
210-
configure_file(${DIMPLIC_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/dimplic.cpp COPYONLY)
211-
configure_file(${ENGINEMECH_CODE_FILE} ${CMAKE_BINARY_DIR}/share/coreneuron/enginemech.cpp COPYONLY)
212-
213227
# Make headers avail to build tree
214228
configure_file(engine.h.in ${CMAKE_BINARY_DIR}/include/coreneuron/engine.h @ONLY)
215229

coreneuron/gpu/nrn_acc_manager.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ void setup_nrnthreads_on_device(NrnThread* threads, int nthreads) {
6060

6161
if (nt->n_vecplay) {
6262
/* copy VecPlayContinuous instances */
63-
64-
printf("\n Warning: VectorPlay used but NOT implemented on GPU! ");
65-
6663
/** just empty containers */
6764
void** d_vecplay = (void**) acc_copyin(nt->_vecplay, sizeof(void*) * nt->n_vecplay);
6865
// note: we are using unified memory for NrnThread. Once VecPlay is copied to gpu,
@@ -337,9 +334,6 @@ void setup_nrnthreads_on_device(NrnThread* threads, int nthreads) {
337334

338335
if (nt->n_vecplay) {
339336
/* copy VecPlayContinuous instances */
340-
341-
printf("\n Warning: VectorPlay used but NOT implemented on GPU! ");
342-
343337
/** just empty containers */
344338
void** d_vecplay = (void**) acc_copyin(nt->_vecplay, sizeof(void*) * nt->n_vecplay);
345339
acc_memcpy_to_device(&(d_nt->_vecplay), &d_vecplay, sizeof(void**));

extra/nrnivmodl_core_makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ coremech_lib_target: $(corenrnmech_lib_target)
191191
mkdir -p $(OUTPUT_DIR)/.libs; \
192192
ln -s ../lib$(COREMECH_LIB_NAME)$(LIB_SUFFIX) $(OUTPUT_DIR)/.libs/lib$(COREMECH_LIB_NAME)$(LIB_SUFFIX)
193193

194-
$(ENGINEMECH_OBJ): | $(MOD_OBJS_DIR)
194+
$(ENGINEMECH_OBJ): $(CORENRN_SHARE_CORENRN_DIR)/enginemech.cpp | $(MOD_OBJS_DIR)
195195
$(CXX_COMPILE_CMD) -c -DADDITIONAL_MECHS $(CORENRN_SHARE_CORENRN_DIR)/enginemech.cpp -o $(ENGINEMECH_OBJ)
196196

197197
# build shared library of mechanisms

0 commit comments

Comments
 (0)