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

Commit f6da640

Browse files
jorblancoaTristan CarelBlanco Alonso JorgeOmar Awilepramodk
authored
Support for SONATA reports (#225)
* Select report type at runtime (Bin, SONATA) - Revert SONATA_ENABLE cmake changes - Add ReportHandler class * Refactor report module - Split nrnreport into different classes - Allow sonata reports to coexist with current reportinglib - Adapt integration tests for sonata reports * Move sort_spikes after sonata_write_spikes * Error messages on integration tests * Fixed an issue where clang invoking the linker will always add mentioned libraries into the ELF header of the executable, this causes special-core to fail at load with libraries not found. By forcing the `--as-needed` flag, we reproduce the gcc behavior, which adds libraries only when needed and relies on the loader to recursively resolve libraries. * Choose between reportinglib and sonata reports - If CORENRN_ENABLE_REPORTING variable is present, try to find a reporting library (reportinglib or sonata_reports) and allow its usage. Error if neither is found. * Adapt tests to changes when choosing reporting library * Add population name to the write_spikes * Adapt report.conf file to CLI11 Co-authored-by: Tristan Carel <[email protected]> Co-authored-by: Blanco Alonso Jorge <[email protected]> Co-authored-by: Omar Awile <[email protected]> Co-authored-by: Pramod Kumbhar <[email protected]>
1 parent 6da0f49 commit f6da640

30 files changed

+862
-527
lines changed

CMake/config/CompilerFlagsHelpers.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
100100
set(CMAKE_${COMPILER_LANGUAGE}_GEN_NATIVE "-march=native")
101101
endif()
102102

103+
## CLANG
104+
elseif(CMAKE_${COMPILER_LANGUAGE}_COMPILER_IS_CLANG)
105+
## Force same ld behavior as when called from gcc
106+
## --as-needed forces the linker to check whether a dynamic library mentioned in the command line is actually
107+
## needed by the objects being linked. Symbols needed in shared objects are already linked when building that
108+
## library.
109+
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
110+
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
111+
103112
## rest of the world
104113
else()
105114
set(CMAKE_${COMPILER_LANGUAGE}_WARNING_ALL "-Wall")

CMakeLists.txt

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11)
5656
# =============================================================================
5757
option(CORENRN_ENABLE_OPENMP "Build the CORE NEURON with OpenMP implementation" ON)
5858
option(CORENRN_ENABLE_TIMEOUT "Enable nrn_timeout implementation" ON)
59-
option(CORENRN_ENABLE_REPORTINGLIB "Enable use of ReportingLib for soma reports" OFF)
60-
option(CORENRN_ENABLE_SONATA "Enable SONATA output format" OFF)
59+
option(CORENRN_ENABLE_REPORTING "Enable use of ReportingLib for soma reports" OFF)
6160
option(CORENRN_ENABLE_MPI "Enable MPI-based execution" ON)
6261
option(CORENRN_ENABLE_SOA "Enable SoA Memory Layout" ON)
6362
option(CORENRN_ENABLE_HOC_EXP "Enable wrapping exp with hoc_exp()" OFF)
@@ -158,19 +157,30 @@ if(NOT CORENRN_ENABLE_TIMEOUT)
158157
add_definitions("-DDISABLE_TIMEOUT")
159158
endif()
160159

161-
if ( CORENRN_ENABLE_SONATA AND CORENRN_ENABLE_REPORTINGLIB )
162-
message(FATAL_ERROR "Can't have enabled both SONATA reports and reportinglib")
163-
endif()
164-
165-
if(CORENRN_ENABLE_REPORTINGLIB)
166-
find_package(reportinglib REQUIRED)
160+
if(CORENRN_ENABLE_REPORTING)
161+
find_package(reportinglib)
162+
find_package(sonata)
163+
find_program (H5DUMP_EXECUTABLE h5dump)
164+
if(NOT reportinglib_FOUND AND NOT sonata_FOUND)
165+
message(SEND_ERROR "Neither reportinglib nor SONATA libraries were found")
166+
elseif(reportinglib_FOUND AND sonata_FOUND)
167+
add_definitions("-DENABLE_BIN_REPORTS")
168+
add_definitions("-DENABLE_SONATA_REPORTS")
169+
elseif(reportinglib_FOUND)
170+
add_definitions("-DENABLE_BIN_REPORTS")
171+
set(ENABLE_BIN_REPORTS ON)
172+
else() # sonata_FOUND
173+
if(TARGET sonata::sonata_report)
174+
add_definitions("-DENABLE_SONATA_REPORTS")
175+
set(ENABLE_SONATA_REPORTS ON)
176+
set(reportinglib_INCLUDE_DIR "")
177+
set(reportinglib_LIBRARY "")
178+
else()
179+
message(SEND_ERROR "SONATA library was found but without reporting support")
180+
endif()
181+
endif()
167182
include_directories(${reportinglib_INCLUDE_DIR})
168-
add_definitions("-DENABLE_REPORTING")
169-
endif()
170-
if(CORENRN_ENABLE_SONATA)
171-
find_package(sonata QUIET PATHS ${sonata_DIR}/share/sonata/CMake)
172-
include_directories(${sonatareport_INCLUDE_DIR})
173-
add_definitions("-DENABLE_SONATA_REPORTS -DENABLE_REPORTING")
183+
include_directories(${sonatareport_INCLUDE_DIR})
174184
endif()
175185

176186
if(MINGW)
@@ -297,15 +307,12 @@ if(cmake_generator_tolower MATCHES "makefile")
297307
message(STATUS "Caliper | ${CORENRN_ENABLE_CALIPER_PROFILING}")
298308
message(STATUS "Likwid | ${CORENRN_ENABLE_LIKWID_PROFILING}")
299309
message(STATUS "Unit Tests | ${CORENRN_ENABLE_UNIT_TESTS}")
300-
message(STATUS "ReportingLib | ${CORENRN_ENABLE_REPORTINGLIB}")
301-
message(STATUS " SONATA support | ${CORENRN_ENABLE_SONATA}")
302-
if(CORENRN_ENABLE_REPORTINGLIB)
303-
message(STATUS " INC | ${reportinglib_INCLUDE_DIR}")
304-
message(STATUS " LIB | ${reportinglib_LIBRARY}")
305-
endif()
306-
if(CORENRN_ENABLE_SONATA)
307-
message(STATUS " INC | ${sonatareport_INCLUDE_DIR}")
308-
message(STATUS " LIB | ${sonatareport_LIBRARY}")
310+
message(STATUS "Reporting | ${CORENRN_ENABLE_REPORTING}")
311+
if(CORENRN_ENABLE_REPORTING)
312+
message(STATUS " sonatareport_INC | ${sonatareport_INCLUDE_DIR}")
313+
message(STATUS " sonatareport_LIB | ${sonatareport_LIBRARY}")
314+
message(STATUS " reportinglib_INC | ${reportinglib_INCLUDE_DIR}")
315+
message(STATUS " reportinglib_LIB | ${reportinglib_LIBRARY}")
309316
endif()
310317

311318
message(STATUS "--------------+--------------------------------------------------------------")

coreneuron/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ file(GLOB CORENEURON_CODE_FILES
2424
"apps/corenrn_parameters.cpp"
2525
"gpu/*.cpp"
2626
"io/*.cpp"
27+
"io/reports/*.cpp"
2728
"mechanism/*.cpp"
2829
"mpi/*.cpp"
2930
"network/*.cpp"
@@ -211,12 +212,14 @@ add_dependencies(coreneuron scopmath)
211212
# coreneuron executable
212213
include_directories(${CORENEURON_PROJECT_SOURCE_DIR})
213214
add_executable(nrniv-core "apps/coreneuron.cpp")
215+
214216
target_link_libraries(nrniv-core
215-
corenrnmech
216-
${MPI_C_LIBRARIES}
217-
${MPI_CXX_LIBRARIES}
218-
${reportinglib_LIBRARY}
219-
${sonatareport_LIBRARY})
217+
corenrnmech
218+
${reportinglib_LIBRARY}
219+
${sonatareport_LIBRARY}
220+
${MPI_C_LIBRARIES}
221+
${MPI_CXX_LIBRARIES})
222+
220223
set_target_properties(nrniv-core PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
221224

222225
# =============================================================================

coreneuron/apps/main1.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3434

3535
#include <cstring>
3636
#include <climits>
37+
#include <memory>
3738
#include <vector>
3839

3940
#include "coreneuron/engine.h"
@@ -51,7 +52,10 @@ THE POSSIBILITY OF SUCH DAMAGE.
5152
#include "coreneuron/io/prcellstate.hpp"
5253
#include "coreneuron/utils/nrnmutdec.h"
5354
#include "coreneuron/utils/nrn_stats.h"
54-
#include "coreneuron/io/nrnreport.hpp"
55+
#include "coreneuron/io/reports/nrnreport.hpp"
56+
#include "coreneuron/io/reports/binary_report_handler.hpp"
57+
#include "coreneuron/io/reports/report_handler.hpp"
58+
#include "coreneuron/io/reports/sonata_report_handler.hpp"
5559
#include "coreneuron/gpu/nrn_acc_manager.hpp"
5660
#include "coreneuron/utils/profile/profiler_interface.h"
5761
#include "coreneuron/network/partrans.hpp"
@@ -395,6 +399,22 @@ static void trajectory_return() {
395399
}
396400
}
397401

402+
std::unique_ptr<ReportHandler> create_report_handler(ReportConfiguration& config) {
403+
std::unique_ptr<ReportHandler> report_handler;
404+
if (std::strcmp(config.format, "Bin") == 0) {
405+
report_handler = std::make_unique<BinaryReportHandler>(config);
406+
} else if (std::strcmp(config.format, "SONATA") == 0) {
407+
report_handler = std::make_unique<SonataReportHandler>(config);
408+
}
409+
else {
410+
if (nrnmpi_myid == 0) {
411+
printf(" WARNING : Report name '%s' has unknown format: '%s'.\n", config.name, config.format);
412+
}
413+
return nullptr;
414+
}
415+
return report_handler;
416+
}
417+
398418
} // namespace coreneuron
399419

400420
/// The following high-level functions are marked as "extern C"
@@ -434,6 +454,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
434454
Instrumentor::phase_begin("main");
435455

436456
std::vector<ReportConfiguration> configs;
457+
std::vector<std::unique_ptr<ReportHandler> > report_handlers;
437458
bool reports_needs_finalize = false;
438459

439460
report_mem_usage("After mk_mech");
@@ -514,7 +535,11 @@ extern "C" int run_solve_core(int argc, char** argv) {
514535
// register all reports into reportinglib
515536
double min_report_dt = INT_MAX;
516537
for (size_t i = 0; i < configs.size(); i++) {
517-
register_report(dt, tstop, delay, configs[i]);
538+
std::unique_ptr<ReportHandler> report_handler = create_report_handler(configs[i]);
539+
if(report_handler) {
540+
report_handler->create_report(dt, tstop, delay);
541+
report_handlers.push_back(std::move(report_handler));
542+
}
518543
if (configs[i].report_dt < min_report_dt) {
519544
min_report_dt = configs[i].report_dt;
520545
}

coreneuron/io/nrn_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
4646
#include "coreneuron/io/nrn_checkpoint.hpp"
4747
#include "coreneuron/permute/node_permute.h"
4848
#include "coreneuron/permute/cellorder.hpp"
49-
#include "coreneuron/io/nrnsection_mapping.h"
49+
#include "coreneuron/io/nrnsection_mapping.hpp"
5050
#include "coreneuron/utils/nrnoc_aux.hpp"
5151

5252
// callbacks into nrn/src/nrniv/nrnbbcore_write.cpp

0 commit comments

Comments
 (0)