NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::StimulationBackend Class Referenceabstract

Abstract base class for all NESTio stimulation backends. More...

#include <stimulation_backend.h>

Inheritance diagram for nest::StimulationBackend:
[legend]

Public Member Functions

 StimulationBackend ()=default
 
virtual ~StimulationBackend () noexcept=default
 
virtual void enroll (StimulationDevice &, const Dictionary &)
 Enroll a StimulationDevice with the StimulationBackend.
 
virtual void disenroll (StimulationDevice &)
 Disenroll a StimulationDevice from the StimulationBackend.
 
virtual void pre_run_hook ()=0
 Initialize global backend-specific data structures.
 
virtual void post_run_hook ()=0
 Clean up the backend at the end of a Run.
 
virtual void initialize ()=0
 
virtual void finalize ()=0
 
virtual void prepare ()=0
 Prepare the backend at the beginning of the NEST Simulate function.
 
virtual void cleanup ()=0
 Clean up the backend at the end of a user level call to the NEST Simulate function.
 
void clear (const StimulationDevice &)
 

Detailed Description

Abstract base class for all NESTio stimulation backends.

This class provides the interface for NESTio stimulation backends with which StimulationDevices can be enrolled for receiving stimulation data that they can use to updating their parameters at the beginning of each run.

Built-in stimulation backends are registered in the constructor of IOManager by inserting an instance of each of them into a std::map under the name of the backend. The default backend, the one using memory, are not registered in this map.

A user level call to Simulate internally executes the sequence Prepare → Run → Cleanup. During Prepare, the prepare() function of each backend is called by the IOManager. This gives the backend an opportunity to prepare itself for being ready to receive the data.

The user level function Run drives the simulation main loop by updating all the stimulation device. At its beginning it calls pre_run_hook() on each stimulation backend via the IOManager. This function is used to receive or read data and update the stimulation devices. At the end of each run, it calls post_run_hook() on each stimulation backend via IOManager.

During the simulation, stimulation backends do nothing. This solution was chosen to avoid complex synchronization, but can be changed in the future if the need shall arise.

Author
Sandra Diaz

Constructor & Destructor Documentation

◆ StimulationBackend()

nest::StimulationBackend::StimulationBackend ( )
default

◆ ~StimulationBackend()

virtual nest::StimulationBackend::~StimulationBackend ( )
virtualdefaultnoexcept

Member Function Documentation

◆ cleanup()

virtual void nest::StimulationBackend::cleanup ( )
pure virtual

Clean up the backend at the end of a user level call to the NEST Simulate function.

This function is called by SimulationManager::cleanup() and allows the backend to close open files, close network connections, etc.

See also
prepare()

Implemented in nest::StimulationBackendMPI.

◆ clear()

void nest::StimulationBackend::clear ( const StimulationDevice &  )
inline

◆ disenroll()

virtual void nest::StimulationBackend::disenroll ( StimulationDevice &  )
inlinevirtual

Disenroll a StimulationDevice from the StimulationBackend.

This function is considered to be the opposite of enroll() in the sense that it cancels the enrollment of a StimulatinDevice from a StimulationBackend by deleting all device specific data. When setting a new stimulation backend for a stimulation device, this function is called for each backend the device is not enrolled with.

Parameters
devicethe StimulationDevice to be disenrolled
See also
enroll()

Reimplemented in nest::StimulationBackendMPI.

◆ enroll()

virtual void nest::StimulationBackend::enroll ( StimulationDevice &  ,
const Dictionary &   
)
inlinevirtual

Enroll a StimulationDevice with the StimulationBackend.

When this function is called by a StimulationDevice device, the StimulationBackend can set up per-device data structures and properties. Individual device instances can be identified using the thread and node_id of the device.

This function is called from the set_initialized_() function of the device and their set_status() function.

A backend needs to be able to cope with multiple calls to this function, as multiple calls to set_status() may occur on the device. For already enrolled devices this usually means that only the parameters in params have to be set, but no further actions are needed.

Each stimulation backend must ensure that enrollment (including all settings made by the user) is persistent over multiple calls to Prepare, while the enrollment of all devices should end with a call to finalize().

A common implementation of this function will create an entry in a thread-local map, associating the device's node ID with the device-specific backend properties and an input facility of some kind.

Parameters
devicethe StimulationDevice to be enrolled
paramsdevice-specific backend parameters
See also
disenroll()

Reimplemented in nest::StimulationBackendMPI.

◆ finalize()

virtual void nest::StimulationBackend::finalize ( )
pure virtual

Implemented in nest::StimulationBackendMPI.

◆ initialize()

virtual void nest::StimulationBackend::initialize ( )
pure virtual

Implemented in nest::StimulationBackendMPI.

◆ post_run_hook()

virtual void nest::StimulationBackend::post_run_hook ( )
pure virtual

Clean up the backend at the end of a Run.

This is called right before SimulationManager::run() terminates. It allows the backend to indicate that the run is ending.

See also
pre_run_hook()

Implemented in nest::StimulationBackendMPI.

◆ pre_run_hook()

virtual void nest::StimulationBackend::pre_run_hook ( )
pure virtual

Initialize global backend-specific data structures.

This function is called on each backend right at the very beginning of SimulationManager::run(). It used for getting the data in order to update the stimulation devices. The update of the device are made only if necessary and repeated at the beginning of every single call to run in a prepare-run-run-...-run-run-cleanup sequence.

See also
post_run_hook()

Implemented in nest::StimulationBackendMPI.

◆ prepare()

virtual void nest::StimulationBackend::prepare ( )
pure virtual

Prepare the backend at the beginning of the NEST Simulate function.

This function is called by KernelManager::prepare() and allows the backend to open files, establish network connections, etc.

See also
cleanup()

Implemented in nest::StimulationBackendMPI.


The documentation for this class was generated from the following file: