diff --git a/.github/workflows/full-test.yml b/.github/workflows/full-test.yml index 1211167a..1e132a9e 100644 --- a/.github/workflows/full-test.yml +++ b/.github/workflows/full-test.yml @@ -44,9 +44,9 @@ jobs: if: startsWith(matrix.os, 'ubuntu') run: | python -m pip install cython - wget https://github.com/nest/nest-simulator/archive/refs/tags/v3.6.tar.gz -O nest-simulator-3.6.tar.gz - tar xzf nest-simulator-3.6.tar.gz - cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local -Dwith-mpi=ON ./nest-simulator-3.6 + wget https://github.com/nest/nest-simulator/archive/refs/tags/v3.7.tar.gz -O nest-simulator-3.7.tar.gz + tar xzf nest-simulator-3.7.tar.gz + cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local -Dwith-mpi=ON ./nest-simulator-3.7 make make install - name: Install PyNN itself diff --git a/doc/installation.txt b/doc/installation.txt index dffd7dd0..5271db99 100644 --- a/doc/installation.txt +++ b/doc/installation.txt @@ -96,7 +96,7 @@ Now test that NEURON works with PyNN: Installing NEST and PyNEST ========================== -NEST 3.4-3.6 can be downloaded from ``_. +NEST 3.4-3.7 can be downloaded from ``_. Earlier versions of NEST may not work with this version of PyNN. The full installation instructions are available at ``_. diff --git a/pyNN/nest/extensions/CMakeLists.txt b/pyNN/nest/extensions/CMakeLists.txt index af43b706..4ac329bf 100644 --- a/pyNN/nest/extensions/CMakeLists.txt +++ b/pyNN/nest/extensions/CMakeLists.txt @@ -11,31 +11,23 @@ cmake_minimum_required( VERSION 2.8.12 ) # For more informations on how to extend and use your module see: # https://nest.github.io/nest-simulator/extension_modules -# 1) Name your module here, i.e. add later with -Dexternal-modules=my: -set( SHORT_NAME pynn ) - -# the complete module name is here: +# 1) the complete module name is here: set( MODULE_NAME pynn_extensions ) # 2) Add all your sources here set( MODULE_SOURCES - pynn_extensions.h pynn_extensions.cpp + pynn_extensions.cpp simple_stochastic_synapse.h stochastic_stp_synapse.h stochastic_stp_synapse_impl.h ) -# 3) We require a header name like this: -set( MODULE_HEADER ${MODULE_NAME}.h ) -# containing the class description of the class extending the SLIModule - # 4) Specify your module version set( MODULE_VERSION_MAJOR 1 ) set( MODULE_VERSION_MINOR 0 ) set( MODULE_VERSION "${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}" ) -# 5) Leave the rest as is. All files in `sli` will be installed to -# `share/nest/sli/`, so that NEST will find the during initialization. +# 5) Leave the rest as is. # Leave the call to "project(...)" for after the compiler is determined. @@ -118,20 +110,6 @@ if ( NEST_INCLUDES ) endforeach () endif () -# Get, if NEST is build as a (mostly) static application. If yes, also only build -# static library. -execute_process( - COMMAND ${NEST_CONFIG} --static-libraries - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE NEST_STATIC_LIB - OUTPUT_STRIP_TRAILING_WHITESPACE -) -if ( NEST_STATIC_LIB ) - set( BUILD_SHARED_LIBS OFF ) -else () - set( BUILD_SHARED_LIBS ON ) -endif () - # Get all linked libraries. execute_process( COMMAND ${NEST_CONFIG} --libs @@ -214,38 +192,21 @@ add_custom_target( dist ) -if ( BUILD_SHARED_LIBS ) - # When building shared libraries, also create a module for loading at runtime - # with the `Install` command. - add_library( ${MODULE_NAME}_module MODULE ${MODULE_SOURCES} ) - set_target_properties( ${MODULE_NAME}_module - PROPERTIES - COMPILE_FLAGS "${NEST_CXXFLAGS} -DLTX_MODULE" - LINK_FLAGS "${NEST_LIBS}" - PREFIX "" - OUTPUT_NAME ${MODULE_NAME} ) - install( TARGETS ${MODULE_NAME}_module - DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) -endif () - -# Build dynamic/static library for standard linking from NEST. -add_library( ${MODULE_NAME}_lib ${MODULE_SOURCES} ) -if ( BUILD_SHARED_LIBS ) - # Dynamic libraries are initiated by a `global` variable of the `SLIModule`, - # which is included, when the flag `LINKED_MODULE` is set. - target_compile_definitions( ${MODULE_NAME}_lib PRIVATE -DLINKED_MODULE ) -endif () -set_target_properties( ${MODULE_NAME}_lib +# Create a module for loading at runtime +# with the `Install` command. +add_library( ${MODULE_NAME}_module MODULE ${MODULE_SOURCES} ) +target_link_libraries(${MODULE_NAME}_module ${USER_LINK_LIBRARIES}) +set_target_properties( ${MODULE_NAME}_module PROPERTIES - COMPILE_FLAGS "${NEST_CXXFLAGS}" + COMPILE_FLAGS "${NEST_CXXFLAGS} -DLTX_MODULE" LINK_FLAGS "${NEST_LIBS}" + PREFIX "" OUTPUT_NAME ${MODULE_NAME} ) +install( TARGETS ${MODULE_NAME}_module + DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) # Install library, header and sli init files. -install( TARGETS ${MODULE_NAME}_lib DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install( FILES ${MODULE_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install( DIRECTORY sli DESTINATION ${CMAKE_INSTALL_DATADIR} ) message( "" ) message( "-------------------------------------------------------" ) @@ -253,7 +214,6 @@ message( "${MODULE_NAME} Configuration Summary" ) message( "-------------------------------------------------------" ) message( "" ) message( "C++ compiler : ${CMAKE_CXX_COMPILER}" ) -message( "Build static libs : ${NEST_STATIC_LIB}" ) message( "C++ compiler flags : ${CMAKE_CXX_FLAGS}" ) message( "NEST compiler flags : ${NEST_CXXFLAGS}" ) message( "NEST include dirs : ${NEST_INCLUDES}" ) diff --git a/pyNN/nest/extensions/pynn_extensions.cpp b/pyNN/nest/extensions/pynn_extensions.cpp index 27b7e59c..e3f736c4 100644 --- a/pyNN/nest/extensions/pynn_extensions.cpp +++ b/pyNN/nest/extensions/pynn_extensions.cpp @@ -5,32 +5,12 @@ */ -#include "pynn_extensions.h" - // include headers with your own stuff #include "simple_stochastic_synapse.h" #include "stochastic_stp_synapse.h" #include "stochastic_stp_synapse_impl.h" -// Includes from nestkernel: -#include "connection_manager_impl.h" -#include "connector_model_impl.h" -#include "dynamicloader.h" -#include "exceptions.h" -#include "genericmodel.h" -#include "kernel_manager.h" -#include "model.h" -#include "model_manager_impl.h" -#include "nest.h" -#include "nest_impl.h" -#include "nestmodule.h" -#include "target_identifier.h" - -// Includes from sli: -#include "booldatum.h" -#include "integerdatum.h" -#include "sliexceptions.h" -#include "tokenarray.h" +#include "nest_extension_interface.h" // -- Interface to dynamic module loader --------------------------------------- @@ -54,42 +34,25 @@ * registration will take place in the file `static_modules.h`, which is * generated by cmake. */ -#if defined( LTX_MODULE ) | defined( LINKED_MODULE ) -pynn::PyNNExtensions pynn_extensions_LTX_mod; -#endif -// -- DynModule functions ------------------------------------------------------ - -pynn::PyNNExtensions::PyNNExtensions() -{ -#ifdef LINKED_MODULE - // register this module at the dynamic loader - // this is needed to allow for linking in this module at compile time - // all registered modules will be initialized by the main app's dynamic loader - nest::DynamicLoaderModule::registerLinkedModule( this ); -#endif -} -pynn::PyNNExtensions::~PyNNExtensions() +namespace pynn { + class PyNNExtensions : public nest::NESTExtensionInterface + { + public: + PyNNExtensions() {} + ~PyNNExtensions() {} + + void initialize() override; + }; } -const std::string -pynn::PyNNExtensions::name( void ) const -{ - return std::string( "PyNN extensions for NEST" ); // Return name of the module -} - -const std::string -pynn::PyNNExtensions::commandstring( void ) const -{ - // Instruct the interpreter to load pynn_extensions-init.sli - return std::string( "(pynn_extensions-init) run" ); -} +pynn::PyNNExtensions pynn_extensions_LTX_module; //------------------------------------------------------------------------------------- void -pynn::PyNNExtensions::init( SLIInterpreter* i ) +pynn::PyNNExtensions::initialize() { /* Register a neuron or device model. Give node type as template argument and the name as second argument. diff --git a/pyNN/nest/extensions/pynn_extensions.h b/pyNN/nest/extensions/pynn_extensions.h deleted file mode 100644 index ff9ad5b2..00000000 --- a/pyNN/nest/extensions/pynn_extensions.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - -:copyright: Copyright 2006-2024 by the PyNN team, see AUTHORS. -:license: CeCILL, see LICENSE for details. - -*/ - -#ifndef PYNNEXTENSIONS_H -#define PYNNEXTENSIONS_H - -// Includes from sli: -#include "slifunction.h" -#include "slimodule.h" - -// Put your stuff into your own namespace. -namespace pynn -{ - -/** - * Class defining your model. - * @note For each model, you must define one such class, with a unique name. - */ -class PyNNExtensions : public SLIModule -{ -public: - // Interface functions ------------------------------------------ - - /** - * @note The constructor registers the module with the dynamic loader. - * Initialization proper is performed by the init() method. - */ - PyNNExtensions(); - - /** - * @note The destructor does not do much in modules. - */ - ~PyNNExtensions(); - - /** - * Initialize module. - * @param SLIInterpreter* SLI interpreter - */ - void init( SLIInterpreter* ); - - /** - * Return the name of your model. - */ - const std::string name( void ) const; - - /** - * Return the name of a sli file to execute when the module is loaded. - * This mechanism can be used to define SLI commands associated with your - * module, in particular, set up type tries for functions you have defined. - */ - const std::string commandstring( void ) const; -}; -} // namespace pynn - -#endif diff --git a/pyNN/nest/extensions/simple_stochastic_synapse.h b/pyNN/nest/extensions/simple_stochastic_synapse.h index 4ac71221..6c0fc169 100644 --- a/pyNN/nest/extensions/simple_stochastic_synapse.h +++ b/pyNN/nest/extensions/simple_stochastic_synapse.h @@ -149,7 +149,7 @@ class simple_stochastic_synapse : public nest::Connection< targetidentifierT > * @param t Thread * @param cp Common properties to all synapses. */ - void send( nest::Event& e, size_t t, const CommonPropertiesType& cp ); + bool send( nest::Event& e, size_t t, const CommonPropertiesType& cp ); // The following methods contain mostly fixed code to forward the // corresponding tasks to corresponding methods in the base class and the w_ @@ -182,13 +182,13 @@ template < typename targetidentifierT > constexpr nest::ConnectionModelProperties simple_stochastic_synapse< targetidentifierT >::properties; template < typename targetidentifierT > -inline void +inline bool simple_stochastic_synapse< targetidentifierT >::send( nest::Event& e, size_t t, const CommonPropertiesType& props ) { if ( nest::get_vp_specific_rng( t )->drand() < (1 - p_) ) // drop spike - return; + return false; // Even time stamp, we send the spike using the normal sending mechanism // send the spike to the target @@ -197,6 +197,7 @@ simple_stochastic_synapse< targetidentifierT >::send( nest::Event& e, e.set_receiver( *ConnectionBase::get_target( t ) ); e.set_rport( ConnectionBase::get_rport() ); e(); // this sends the event + return true; } template < typename targetidentifierT > diff --git a/pyNN/nest/extensions/sli/pynn_extensions-init.sli b/pyNN/nest/extensions/sli/pynn_extensions-init.sli deleted file mode 100644 index c884555b..00000000 --- a/pyNN/nest/extensions/sli/pynn_extensions-init.sli +++ /dev/null @@ -1,13 +0,0 @@ -/* - -:copyright: Copyright 2006-2024 by the PyNN team, see AUTHORS. -:license: CeCILL, see LICENSE for details. - -*/ - -/* - * Initialization file for PyNNExtensions module. - * Run automatically when PyNNExtensions module is loaded. - */ - -M_DEBUG (pynn_extensions.sli) (Initializing SLI support for PyNNExtensions.) message diff --git a/pyNN/nest/extensions/stochastic_stp_synapse.h b/pyNN/nest/extensions/stochastic_stp_synapse.h index 80d473bc..b7acf4d2 100644 --- a/pyNN/nest/extensions/stochastic_stp_synapse.h +++ b/pyNN/nest/extensions/stochastic_stp_synapse.h @@ -106,7 +106,7 @@ class stochastic_stp_synapse : public nest::Connection< targetidentifierT > * \param e The event to send * \param cp Common properties to all synapses (empty). */ - void send( nest::Event& e, size_t t, const CommonPropertiesType& cp ); + bool send( nest::Event& e, size_t t, const CommonPropertiesType& cp ); class ConnTestDummyNode : public nest::ConnTestDummyNodeBase { @@ -159,7 +159,7 @@ constexpr nest::ConnectionModelProperties stochastic_stp_synapse< targetidentifi * \param cp Common properties object, containing the stochastic_stp parameters. */ template < typename targetidentifierT > -inline void +inline bool stochastic_stp_synapse< targetidentifierT >::send( nest::Event& e, size_t thr, const CommonPropertiesType& ) @@ -212,6 +212,7 @@ stochastic_stp_synapse< targetidentifierT >::send( nest::Event& e, } t_lastspike_ = t_spike; + return release; } } // namespace