Skip to content

Commit

Permalink
Merge pull request #796 from NeuralEnsemble/nest-dev
Browse files Browse the repository at this point in the history
Run test suite with NEST 3.7-rc1
  • Loading branch information
apdavison authored Apr 17, 2024
2 parents cfae3a6 + 7ae7d69 commit 1bdaa5a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 183 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/full-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Now test that NEURON works with PyNN:
Installing NEST and PyNEST
==========================

NEST 3.4-3.6 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
NEST 3.4-3.7 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
Earlier versions of NEST may not work with this version of PyNN.
The full installation instructions are available at `<https://nest-simulator.readthedocs.io/en/v3.4/installation/index.html/>`_.

Expand Down
66 changes: 13 additions & 53 deletions pyNN/nest/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -214,46 +192,28 @@ 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( "-------------------------------------------------------" )
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}" )
Expand Down
61 changes: 12 additions & 49 deletions pyNN/nest/extensions/pynn_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------

Expand All @@ -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.
Expand Down
59 changes: 0 additions & 59 deletions pyNN/nest/extensions/pynn_extensions.h

This file was deleted.

7 changes: 4 additions & 3 deletions pyNN/nest/extensions/simple_stochastic_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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
Expand All @@ -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 >
Expand Down
13 changes: 0 additions & 13 deletions pyNN/nest/extensions/sli/pynn_extensions-init.sli

This file was deleted.

5 changes: 3 additions & 2 deletions pyNN/nest/extensions/stochastic_stp_synapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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& )
Expand Down Expand Up @@ -212,6 +212,7 @@ stochastic_stp_synapse< targetidentifierT >::send( nest::Event& e,
}

t_lastspike_ = t_spike;
return release;
}

} // namespace
Expand Down

0 comments on commit 1bdaa5a

Please sign in to comment.