Abstract base class for all NESTio stimulation backends. More...
#include <stimulation_backend.h>
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 &) |
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.
|
default |
|
virtualdefaultnoexcept |
|
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.
Implemented in nest::StimulationBackendMPI.
|
inline |
|
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.
| device | the StimulationDevice to be disenrolled |
Reimplemented in nest::StimulationBackendMPI.
|
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.
| device | the StimulationDevice to be enrolled |
| params | device-specific backend parameters |
Reimplemented in nest::StimulationBackendMPI.
|
pure virtual |
Implemented in nest::StimulationBackendMPI.
|
pure virtual |
Implemented in nest::StimulationBackendMPI.
|
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.
Implemented in nest::StimulationBackendMPI.
|
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.
Implemented in nest::StimulationBackendMPI.
|
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.
Implemented in nest::StimulationBackendMPI.