Skip to content

Commit

Permalink
Merge pull request #2990 from heplesser/models_no_module
Browse files Browse the repository at this point in the history
Models no longer wrapped in SLI Module, model registration and thread-setting in managers revised
  • Loading branch information
heplesser authored Dec 13, 2023
2 parents 61b5d40 + cd7b8cd commit f3e67a5
Show file tree
Hide file tree
Showing 48 changed files with 488 additions and 609 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ include( CheckIncludesSymbols )

# These includes publish function names.
include( ProcessOptions )
include( WriteStaticModules_h )
include( CheckExtraCompilerFeatures )
include( ConfigureSummary )
include( GetTriple )
Expand Down Expand Up @@ -170,8 +169,6 @@ nest_get_color_flags()
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NEST_C_COLOR_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NEST_CXX_COLOR_FLAGS}" )

nest_write_static_module_header( "${PROJECT_BINARY_DIR}/nest/static_modules.h" )

# check additionals
nest_check_exitcode_abort()
nest_check_exitcode_segfault()
Expand Down
1 change: 0 additions & 1 deletion build_support/check_copyright_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def eprint(*args, **kwargs):
exclude_files = [
"doc/copyright_header.cpp",
"doc/copyright_header.py",
"nest/static_modules.h",
"pynest/pynestkernel.cpp",
"get-pip.py",
]
Expand Down
36 changes: 3 additions & 33 deletions build_support/generate_modelsmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,12 @@ def generate_modelsmodule():
with open(fname, "r") as file:
copyright_header = file.read()

fname = "modelsmodule.cpp"
fname = "models.cpp"
modeldir = Path(blddir) / "models"
modeldir.mkdir(parents=True, exist_ok=True)
with open(modeldir / fname, "w") as file:
file.write(copyright_header.replace("{{file_name}}", fname))
file.write(
dedent(
"""
#include "modelsmodule.h"
// Generated includes
#include "config.h"
"""
)
)
file.write('\n#include "models.h"\n\n// Generated includes\n#include "config.h"\n')

for model_type, guards_fnames in includes.items():
file.write(f"\n// {model_type.capitalize()} models\n")
Expand All @@ -265,28 +256,7 @@ def generate_modelsmodule():
file.write(f'#include "{fname}"\n')
file.write(end_guard(guards))

file.write(
dedent(
"""
nest::ModelsModule::ModelsModule()
{
}
nest::ModelsModule::~ModelsModule()
{
}
const std::string
nest::ModelsModule::name() const
{
return std::string( "NEST standard models module" );
}
void
nest::ModelsModule::init( SLIInterpreter* )
{"""
)
)
file.write("\nvoid nest::register_models()\n{")

for model_type, guards_mnames in models.items():
file.write(f"\n // {model_type.capitalize()} models\n")
Expand Down
68 changes: 0 additions & 68 deletions cmake/WriteStaticModules_h.cmake

This file was deleted.

1 change: 0 additions & 1 deletion doc/htmldoc/developer_space/workflows/nest_with_ides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ Also add the generated files:
<somebase>/NEST/build/libnestutil/config.h
<somebase>/NEST/build/libnestutil/sliconfig.h
<somebase>/NEST/build/nest/static_modules.h
1. On the left panel select the newly created project ``NEST-fork``, then select the created target.
Expand Down
3 changes: 2 additions & 1 deletion models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

set(models_sources
modelsmodule.h ${PROJECT_BINARY_DIR}/models/modelsmodule.cpp
models.h ${PROJECT_BINARY_DIR}/models/models.cpp
binary_neuron.h
weight_recorder.h weight_recorder.cpp # Required by CommonSynapseProperties
cm_compartmentcurrents.h cm_compartmentcurrents.cpp
cm_tree.h cm_tree.cpp
rate_neuron_ipn.h rate_neuron_ipn_impl.h
Expand Down
41 changes: 11 additions & 30 deletions models/modelsmodule.h → models/models.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* modelsmodule.h
* models.h
*
* This file is part of NEST.
*
Expand All @@ -20,40 +20,21 @@
*
*/

#ifndef MODELSMODULE_H
#define MODELSMODULE_H
#ifndef MODELS_H
#define MODELS_H

// C++ includes:
#include <string>

// Includes from sli:
#include "slimodule.h"
// Includes from nestkernel:
#include "nest.h"

namespace nest
{
/**
* Module supplying all models that are included in the NEST release.
*
* First Version: June 2006
*
* @todo Should this be a dynamic module?
* Function to register all node and connection models that were
* selected for compilation either by using the cmake switch
* -Dwith-models=<model;list> or as specified in the modelset given to
* the option -Dwith-modelset=<modelset>
*/
class ModelsModule : public SLIModule
{
public:
ModelsModule();
~ModelsModule() override;

/**
* Initialize module by registering models with the network.
* @param SLIInterpreter* SLI interpreter
*/
void init( SLIInterpreter* ) override;

const std::string name() const override;
};


} // namespace
void register_models();
}

#endif
4 changes: 0 additions & 4 deletions nest/neststartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

// Generated includes:
#include "config.h"
#include "static_modules.h"

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

// now add static modules providing components.
add_static_modules( engine );

/*
* The following section concerns shared user modules and is thus only
* included if we built with libtool and libltdl.
Expand Down
6 changes: 3 additions & 3 deletions nestkernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ set ( nestkernel_sources
recording_device.h recording_device.cpp
pseudo_recording_device.h
ring_buffer.h ring_buffer_impl.h ring_buffer.cpp
secondary_event.h
secondary_event.h secondary_event_impl.h
slice_ring_buffer.cpp slice_ring_buffer.h
spikecounter.h spikecounter.cpp
stimulation_device.h stimulation_device.cpp
Expand Down Expand Up @@ -134,7 +134,7 @@ if ( HAVE_MPI )
endif ()


# Prevent problems with Conda path substitution (see #2348)
# Prevent problems with Conda path substitution (see #2348)
set_source_files_properties( dynamicloader.cpp PROPERTIES COMPILE_OPTIONS "-O0" )


Expand All @@ -145,7 +145,7 @@ set_target_properties( nestkernel
)

target_link_libraries( nestkernel
nestutil sli_lib
nestutil sli_lib models
${LTDL_LIBRARIES} ${MPI_CXX_LIBRARIES} ${MUSIC_LIBRARIES} ${SIONLIB_LIBRARIES} ${LIBNEUROSIM_LIBRARIES} ${HDF5_LIBRARIES}
)

Expand Down
5 changes: 3 additions & 2 deletions nestkernel/conn_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ nest::ConnBuilder::connect()
// classes are fully constructed when the test is executed
for ( auto synapse_model_id : synapse_model_id_ )
{
const ConnectorModel& synapse_model = kernel().model_manager.get_connection_model( synapse_model_id );
const ConnectorModel& synapse_model =
kernel().model_manager.get_connection_model( synapse_model_id, /* thread */ 0 );
const bool requires_symmetric = synapse_model.has_property( ConnectionModelProperties::REQUIRES_SYMMETRIC );

if ( requires_symmetric and not( is_symmetric() or make_symmetric_ ) )
Expand Down Expand Up @@ -421,7 +422,7 @@ nest::ConnBuilder::set_synapse_model_( DictionaryDatum syn_params, size_t synaps
synapse_model_id_[ synapse_indx ] = synapse_model_id;

// We need to make sure that Connect can process all synapse parameters specified.
const ConnectorModel& synapse_model = kernel().model_manager.get_connection_model( synapse_model_id );
const ConnectorModel& synapse_model = kernel().model_manager.get_connection_model( synapse_model_id, /* thread */ 0 );
synapse_model.check_synapse_params( syn_params );
}

Expand Down
Loading

0 comments on commit f3e67a5

Please sign in to comment.