Skip to content

Commit

Permalink
Merge pull request #3103 from heplesser/fix-3064
Browse files Browse the repository at this point in the history
Create NEST Extension Interface for NEST compatible with new registration scheme and unloading
  • Loading branch information
abigailm authored Mar 19, 2024
2 parents 90ad974 + e17951e commit 3ee7f98
Show file tree
Hide file tree
Showing 33 changed files with 497 additions and 545 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ set( with-modelset "full" CACHE STRING "The modelset to include. Sample configur
set( with-models OFF CACHE STRING "The models to include as a semicolon-separated list of model headers (without the .h extension). This option is mutually exclusive with -Dwith-modelset. [default=OFF]." )
set( tics_per_ms "1000.0" CACHE STRING "Specify elementary unit of time [default=1000 tics per ms]." )
set( tics_per_step "100" CACHE STRING "Specify resolution [default=100 tics per step]." )
set( external-modules OFF CACHE STRING "External NEST modules to be linked in, separated by ';', [default=OFF]." )
set( with-detailed-timers OFF CACHE STRING "Build with detailed internal time measurements [default=OFF]. Detailed timers can affect the performance." )
set( target-bits-split "standard" CACHE STRING "Split of the 64-bit target neuron identifier type [default='standard']. 'standard' is recommended for most users. If running on more than 262144 MPI processes or more than 512 threads, change to 'hpc'." )

Expand Down Expand Up @@ -136,7 +135,6 @@ nest_process_with_libraries()
nest_process_with_includes()
nest_process_with_defines()
nest_process_static_libraries()
nest_process_external_modules()
nest_process_tics_per_ms()
nest_process_tics_per_step()
nest_process_with_libltdl()
Expand Down
12 changes: 0 additions & 12 deletions cmake/ConfigureSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ function( NEST_PRINT_CONFIG_SUMMARY )
message( "Built-in modelset : ${with-modelset}" )
endif ()

message( "" )
if ( external-modules )
message( "User modules : ${external-modules}" )
foreach ( mod ${external-modules} )
message( " ${mod}:" )
message( " Header : ${${mod}_EXT_MOD_INCLUDE}" )
message( " Library : ${${mod}_EXT_MOD_LIBRARY}" )
endforeach ()
else ()
message( "User modules : None" )
endif ()

message( "" )
if ( HAVE_PYTHON )
message( "Python bindings : Yes (Python ${Python_VERSION}: ${PYTHON})" )
Expand Down
51 changes: 7 additions & 44 deletions cmake/ProcessOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,43 +222,6 @@ function( NEST_PROCESS_STATIC_LIBRARIES )
endif ()
endfunction()

function( NEST_PROCESS_EXTERNAL_MODULES )
if ( external-modules )
# headers from external modules will be installed here
include_directories( "${CMAKE_INSTALL_FULL_INCLUDEDIR}" )

# put all external libs into this variable
set( EXTERNAL_MODULE_LIBRARIES )
# put all external headers into this variable
set( EXTERNAL_MODULE_INCLUDES )
foreach ( mod ${external-modules} )
# find module header
find_file( ${mod}_EXT_MOD_INCLUDE
NAMES ${mod}module.h
HINTS "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${mod}module"
)
if ( ${mod}_EXT_MOD_INCLUDE STREQUAL "${mod}_EXT_MOD_INCLUDE-NOTFOUND" )
printError( "Cannot find header for external module '${mod}'. "
"Should be '${CMAKE_INSTALL_FULL_INCLUDEDIR}/${mod}module/${mod}module.h' ." )
endif ()
list( APPEND EXTERNAL_MODULE_INCLUDES ${${mod}_EXT_MOD_INCLUDE} )

# find module library
find_library( ${mod}_EXT_MOD_LIBRARY
NAMES ${mod}module
HINTS "${CMAKE_INSTALL_FULL_LIBDIR}/nest"
)
if ( ${mod}_EXT_MOD_LIBRARY STREQUAL "${mod}_EXT_MOD_LIBRARY-NOTFOUND" )
printError( "Cannot find library for external module '${mod}'." )
endif ()
list( APPEND EXTERNAL_MODULE_LIBRARIES "${${mod}_EXT_MOD_LIBRARY}" )
endforeach ()

set( EXTERNAL_MODULE_LIBRARIES ${EXTERNAL_MODULE_LIBRARIES} PARENT_SCOPE )
set( EXTERNAL_MODULE_INCLUDES ${EXTERNAL_MODULE_INCLUDES} PARENT_SCOPE )
endif ()
endfunction()

function( NEST_PROCESS_TICS_PER_MS )
# Set tics per ms / step
if ( tics_per_ms )
Expand All @@ -280,7 +243,7 @@ function( NEST_PROCESS_WITH_LIBLTDL )
if ( with-ltdl AND NOT static-libraries )
if ( NOT ${with-ltdl} STREQUAL "ON" )
# a path is set
set( LTDL_ROOT_DIR "${with-ltdl}" )
set( LTDL_ROOT "${with-ltdl}" )
endif ()

find_package( LTDL )
Expand All @@ -304,7 +267,7 @@ function( NEST_PROCESS_WITH_READLINE )
if ( with-readline )
if ( NOT ${with-readline} STREQUAL "ON" )
# a path is set
set( READLINE_ROOT_DIR "${with-readline}" )
set( Readline_ROOT "${with-readline}" )
endif ()

find_package( Readline )
Expand All @@ -328,7 +291,7 @@ function( NEST_PROCESS_WITH_GSL )
if ( with-gsl )
if ( NOT ${with-gsl} STREQUAL "ON" )
# if set, use this prefix
set( GSL_ROOT_DIR "${with-gsl}" )
set( GSL_ROOT "${with-gsl}" )
endif ()

find_package( GSL )
Expand Down Expand Up @@ -503,7 +466,7 @@ function( NEST_PROCESS_WITH_LIBNEUROSIM )
if ( with-libneurosim )
if ( NOT ${with-libneurosim} STREQUAL "ON" )
# a path is set
set( LIBNEUROSIM_ROOT ${with-libneurosim} )
set( LibNeurosim_ROOT ${with-libneurosim} )
endif ()

find_package( LibNeurosim )
Expand All @@ -527,7 +490,7 @@ function( NEST_PROCESS_WITH_MUSIC )
if ( with-music )
if ( NOT ${with-music} STREQUAL "ON" )
# a path is set
set( MUSIC_ROOT_DIR "${with-music}" )
set( Music_ROOT "${with-music}" )
endif ()

if ( NOT HAVE_MPI )
Expand All @@ -553,7 +516,7 @@ function( NEST_PROCESS_WITH_SIONLIB )
set( HAVE_SIONLIB OFF )
if ( with-sionlib )
if ( NOT ${with-sionlib} STREQUAL "ON" )
set( SIONLIB_ROOT_DIR "${with-sionlib}" CACHE INTERNAL "sionlib" )
set( SIONlib_ROOT "${with-sionlib}" CACHE INTERNAL "sionlib" )
endif()

if ( NOT HAVE_MPI )
Expand All @@ -576,7 +539,7 @@ function( NEST_PROCESS_WITH_BOOST )
if ( with-boost )
if ( NOT ${with-boost} STREQUAL "ON" )
# a path is set
set( BOOST_ROOT "${with-boost}" )
set( Boost_ROOT "${with-boost}" )
endif ()

set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs
Expand Down
3 changes: 0 additions & 3 deletions doc/htmldoc/installation/cmake_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ NEST properties
+-----------------------------------------------+----------------------------------------------------------------+
| ``-Dtics_per_step=[number]`` | Specify resolution [default=100 tics per step]. |
+-----------------------------------------------+----------------------------------------------------------------+
| ``-Dexternal-modules=[OFF|<list;of;modules>]``| External NEST modules to be linked in, separated by ';', |
| | [default=OFF]. |
+-----------------------------------------------+----------------------------------------------------------------+
| ``-Dwith-detailed-timers=[OFF|ON]`` | Build with detailed internal time measurements [default=OFF]. |
| | Detailed timers can affect the performance. |
+-----------------------------------------------+----------------------------------------------------------------+
Expand Down
5 changes: 2 additions & 3 deletions nest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ set_target_properties( nest_lib

target_link_libraries( nest
nestutil nestkernel sli_lib sli_readline models
${EXTERNAL_MODULE_LIBRARIES} OpenMP::OpenMP_CXX )
OpenMP::OpenMP_CXX )

target_link_libraries( nest_lib
nestutil nestkernel sli_lib models ${EXTERNAL_MODULE_LIBRARIES}
nestutil nestkernel sli_lib models
OpenMP::OpenMP_CXX )

target_include_directories( nest PRIVATE
Expand Down Expand Up @@ -88,7 +88,6 @@ target_include_directories( nest_lib PRIVATE
${Python_INCLUDE_DIRS}
)


if ( HAVE_PYTHON )
target_compile_definitions( nest_lib PRIVATE
-D_IS_PYNEST
Expand Down
24 changes: 0 additions & 24 deletions nest/neststartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "logging_event.h"

// Includes from nestkernel:
#include "dynamicloader.h"
#include "kernel_manager.h"
#include "nest.h"
#include "nestmodule.h"
Expand Down Expand Up @@ -111,29 +110,6 @@ neststartup( int* argc, char*** argv, SLIInterpreter& engine, std::string module
// NestModule extends SLI by commands for neuronal simulations
addmodule< nest::NestModule >( engine );

/*
* The following section concerns shared user modules and is thus only
* included if we built with libtool and libltdl.
*
* One may want to link user modules statically, but for convenience
* they still register themselves with the DyamicLoadModule during static
* initialization. At the same time, we need to create the DynamicLoaderModule,
* since the compiler might otherwise optimize DynamicLoaderModule::registerLinkedModule() away.
*/
#ifdef HAVE_LIBLTDL
// dynamic loader module for managing linked and dynamically loaded extension
// modules
nest::DynamicLoaderModule* pDynLoader = new nest::DynamicLoaderModule( engine );

// initialize all modules that were linked at compile time.
// These modules were registered via DynamicLoader::registerLinkedModule
// from their constructor
pDynLoader->initLinkedModules( engine );

// interpreter will delete module on destruction
engine.addmodule( pDynLoader );
#endif

#ifdef _IS_PYNEST
// add the init-script to the list of module initializers
ArrayDatum* ad = dynamic_cast< ArrayDatum* >( engine.baselookup( engine.commandstring_name ).datum() );
Expand Down
3 changes: 2 additions & 1 deletion nestkernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ set ( nestkernel_sources
deprecation_warning.h deprecation_warning.cpp
device.h device.cpp
device_node.h
dynamicloader.h dynamicloader.cpp
module_manager.h module_manager.cpp
event.h event.cpp
exceptions.h exceptions.cpp
genericmodel.h genericmodel_impl.h
Expand Down Expand Up @@ -116,6 +116,7 @@ set ( nestkernel_sources
spatial.h spatial.cpp
stimulation_backend.h
buffer_resize_log.h buffer_resize_log.cpp
nest_extension_interface.h
)


Expand Down
4 changes: 2 additions & 2 deletions nestkernel/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ nest::ConnectionManager::~ConnectionManager()
}

void
nest::ConnectionManager::initialize( const bool reset_kernel )
nest::ConnectionManager::initialize( const bool adjust_number_of_threads_or_rng_only )
{
if ( reset_kernel )
if ( not adjust_number_of_threads_or_rng_only )
{
keep_source_table_ = true;
connections_have_changed_ = false;
Expand Down
Loading

0 comments on commit 3ee7f98

Please sign in to comment.