#include <recording_backend_sionlib.h>
Classes | |
| struct | DeviceEntry |
| struct | DeviceInfo |
| struct | FileEntry |
| struct | Parameters_ |
| class | SIONBuffer |
Public Member Functions | |
| RecordingBackendSIONlib () | |
| ~RecordingBackendSIONlib () throw () | |
| void | initialize () override |
| void | finalize () override |
| void | enroll (const RecordingDevice &device, const Dictionary ¶ms) override |
Enroll a RecordingDevice with the RecordingBackend. | |
| void | disenroll (const RecordingDevice &device) override |
Disenroll a RecordingDevice from the RecordingBackend. | |
| void | set_value_names (const RecordingDevice &device, const std::vector< std::string > &double_value_names, const std::vector< std::string > &long_value_names) override |
To make the names of recorded quantities known to the RecordingBackend, the vectors double_value_names and long_value_names can be set appropriately. | |
| void | prepare () override |
| Prepare the backend at begin of the NEST Simulate function. | |
| void | cleanup () override |
| Clean up the backend at the end of a user level call to the NEST Simulate function. | |
| void | write (const RecordingDevice &device, const Event &event, const std::vector< double > &double_values, const std::vector< long > &long_values) override |
| Write the data from the event to the backend specific channel together with the values given. | |
| void | set_status (const Dictionary &) override |
| Set the status of the recording backend using the key-value pairs contained in the params dictionary. | |
| void | get_status (Dictionary &) const override |
| Return the status of the recording backend by writing it to the given params dictionary. | |
| void | pre_run_hook () override |
| Initialize global backend-specific data structures. | |
| void | post_run_hook () override |
| Clean up the backend at the end of a Run. | |
| void | post_step_hook () override |
| Do work required at the end of each simulation step. | |
| void | check_device_status (const Dictionary &) const override |
| Check if the given per-device properties are valid and usable by the backend. | |
| void | get_device_defaults (Dictionary &) const override |
| Return the per-device defaults by writing it to the given params dictionary. | |
| void | get_device_status (const RecordingDevice &device, Dictionary ¶ms_dictionary) const override |
| Return the per-device status of the given recording device by writing it to the given params dictionary. | |
Public Member Functions inherited from nest::RecordingBackend | |
| RecordingBackend () | |
| virtual | ~RecordingBackend () throw () |
Static Public Attributes | |
| static const unsigned int | SIONLIB_REC_BACKEND_VERSION = 2 |
| static const unsigned int | DEV_NAME_BUFFERSIZE = 32 |
| static const unsigned int | DEV_LABEL_BUFFERSIZE = 32 |
| static const unsigned int | VALUE_NAME_BUFFERSIZE = 16 |
| static const unsigned int | NEST_VERSION_BUFFERSIZE = 128 |
Static Public Attributes inherited from nest::RecordingBackend | |
| static const std::vector< std::string > | NO_DOUBLE_VALUE_NAMES |
| static const std::vector< std::string > | NO_LONG_VALUE_NAMES |
| static const std::vector< double > | NO_DOUBLE_VALUES |
| static const std::vector< long > | NO_LONG_VALUES |
Private Types | |
| typedef std::vector< std::map< size_t, DeviceEntry > > | device_map |
| typedef std::map< size_t, FileEntry > | file_map |
Private Member Functions | |
| void | open_files_ () |
| void | close_files_ () |
| const std::string | build_filename_ () const |
Private Attributes | |
| bool | files_opened_ |
| size_t | num_enrolled_devices_ |
| device_map | devices_ |
| file_map | files_ |
| std::string | filename_ |
| MPI_Comm | local_comm_ |
| double | t_start_ |
| Parameters_ | P_ |
|
private |
|
private |
| nest::RecordingBackendSIONlib::RecordingBackendSIONlib | ( | ) |
| nest::RecordingBackendSIONlib::~RecordingBackendSIONlib | ( | ) | ||
| throw | ( | |||
| ) | ||||
|
private |
References nest::RecordingBackendSIONlib::Parameters_::filename_, nest::IOManager::get_data_path(), nest::IOManager::get_data_prefix(), nest::KernelManager::io_manager, nest::kernel(), and P_.
Referenced by open_files_().
|
overridevirtual |
Check if the given per-device properties are valid and usable by the backend.
This function is used to validate properties when SetDefaults is called on a recording device. If the properties are found to be valid, they will be cached in the recording device and set for individual instances by means of the call to enroll from the device's set_initialized_() function. In case the properties are invalid, this function is expected to throw BadProperty.
| params | the parameter dictionary to validate |
Implements nest::RecordingBackend.
|
overridevirtual |
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 or network connections or take similar action.
Implements nest::RecordingBackend.
References close_files_().
Referenced by ~RecordingBackendSIONlib().
|
private |
References nest::RecordingBackendSIONlib::FileEntry::buffer, nest::RecordingBackendSIONlib::SIONBuffer::clear(), DEV_NAME_BUFFERSIZE, devices_, nest::RecordingBackendSIONlib::DeviceInfo::double_value_names, files_, files_opened_, nest::Time::get_ms(), nest::Time::get_resolution(), nest::RecordingBackendSIONlib::SIONBuffer::get_size(), nest::VPManager::get_thread_id(), nest::SimulationManager::get_time(), nest::kernel(), nest::RecordingBackendSIONlib::DeviceInfo::label, nest::RecordingBackendSIONlib::DeviceInfo::long_value_names, nest::RecordingBackendSIONlib::DeviceInfo::n_rec, nest::RecordingBackendSIONlib::DeviceInfo::name, NEST_VERSION_BUFFERSIZE, nest::RecordingBackendSIONlib::DeviceInfo::node_id, nest::RecordingBackendSIONlib::DeviceInfo::origin, nest::RecordingBackendSIONlib::SIONBuffer::read(), nest::RecordingBackendSIONlib::FileEntry::sid, nest::KernelManager::simulation_manager, SIONLIB_REC_BACKEND_VERSION, nest::RecordingBackendSIONlib::DeviceInfo::t_start, t_start_, nest::RecordingBackendSIONlib::DeviceInfo::t_stop, nest::VPManager::thread_to_vp(), nest::RecordingBackendSIONlib::DeviceInfo::type, VALUE_NAME_BUFFERSIZE, and nest::KernelManager::vp_manager.
Referenced by cleanup().
|
overridevirtual |
Disenroll a RecordingDevice from the RecordingBackend.
This function is considered to be the opposite of enroll() in the sense that it cancels the enrollment of a RecordingDevice from a RecordingBackend by deleting all device specific data. When setting a new recording backend for a recording device, this function is called for each backend the device is not enrolled with.
| device | the RecordingDevice to be disenrolled |
Implements nest::RecordingBackend.
References devices_, nest::Node::get_node_id(), and nest::Node::get_thread().
|
overridevirtual |
Enroll a RecordingDevice with the RecordingBackend.
When this function is called by a RecordingDevice device, the RecordingBackend 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. The companion function set_value_names() is called from Node::pre_run_hook() and makes the names of values to be recorded known.
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 recording 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 output facility of some kind.
| device | the RecordingDevice to be enrolled |
| params | device-specific backend parameters |
Implements nest::RecordingBackend.
References devices_, nest::RecordingDevice::get_label(), nest::Node::get_name(), nest::Node::get_node_id(), nest::Device::get_origin(), nest::Device::get_start(), nest::Time::get_steps(), nest::Device::get_stop(), nest::Node::get_thread(), nest::RecordingDevice::get_type(), nest::RecordingBackendSIONlib::DeviceEntry::info, nest::RecordingBackendSIONlib::DeviceInfo::label, nest::RecordingBackendSIONlib::DeviceInfo::name, nest::RecordingBackendSIONlib::DeviceInfo::node_id, num_enrolled_devices_, nest::RecordingBackendSIONlib::DeviceInfo::origin, nest::RecordingBackendSIONlib::DeviceInfo::t_start, nest::RecordingBackendSIONlib::DeviceInfo::t_stop, and nest::RecordingBackendSIONlib::DeviceInfo::type.
|
overridevirtual |
Implements nest::RecordingBackend.
|
overridevirtual |
Return the per-device defaults by writing it to the given params dictionary.
| params | the dictionary to add device-specific backend parameters to |
Implements nest::RecordingBackend.
|
overridevirtual |
Return the per-device status of the given recording device by writing it to the given params dictionary.
Please note that a corresponding setter function does not exist. Device-specific backend parameters are given in the call to enroll.
| device | the recording device for which the status is returned |
| params | the dictionary to add device-specific backend parameters to |
Implements nest::RecordingBackend.
|
overridevirtual |
Return the status of the recording backend by writing it to the given params dictionary.
| params | the status of the recording backend |
Implements nest::RecordingBackend.
References nest::names::filename(), filename_, nest::RecordingBackendSIONlib::Parameters_::get(), and P_.
|
overridevirtual |
Implements nest::RecordingBackend.
References devices_, and nest::kernel().
|
private |
References nest::RecordingBackendSIONlib::FileEntry::buffer, nest::RecordingBackendSIONlib::Parameters_::buffer_size_, build_filename_(), nest::RecordingBackendSIONlib::SIONBuffer::clear(), devices_, nest::ERROR, filename_, files_, files_opened_, nest::Time::get_ms(), nest::MPIManager::get_rank(), nest::VPManager::get_thread_id(), nest::SimulationManager::get_time(), nest::kernel(), local_comm_, LOG, nest::KernelManager::mpi_manager, num_enrolled_devices_, P_, nest::RecordingBackendSIONlib::SIONBuffer::reserve(), nest::RecordingBackendSIONlib::FileEntry::sid, nest::KernelManager::simulation_manager, nest::RecordingBackendSIONlib::Parameters_::sion_chunksize_, nest::RecordingBackendSIONlib::Parameters_::sion_collective_, nest::RecordingBackendSIONlib::Parameters_::sion_n_files_, t_start_, nest::VPManager::thread_to_vp(), and nest::KernelManager::vp_manager.
Referenced by prepare().
|
overridevirtual |
Clean up the backend at the end of a Run.
This is called right before SimulationManager::run() terminates. It allows the backend to flush open files, write remaining data to the screen, or perform similar operations that make sure that the user has access to all data from the previous simulation run.
Implements nest::RecordingBackend.
|
overridevirtual |
Do work required at the end of each simulation step.
This is called at the very end of each simulation step. It can for example be used to carry out writing to files in a synchronized way, all threads on all MPI processes performing it at the same time.
Implements nest::RecordingBackend.
References nest::RecordingBackendSIONlib::FileEntry::buffer, nest::RecordingBackendSIONlib::SIONBuffer::clear(), files_, files_opened_, nest::RecordingBackendSIONlib::SIONBuffer::get_size(), nest::VPManager::get_thread_id(), nest::kernel(), P_, nest::RecordingBackendSIONlib::SIONBuffer::read(), nest::RecordingBackendSIONlib::FileEntry::sid, nest::RecordingBackendSIONlib::Parameters_::sion_collective_, nest::VPManager::thread_to_vp(), and nest::KernelManager::vp_manager.
|
overridevirtual |
Initialize global backend-specific data structures.
This function is called on each backend right at the very beginning of SimulationManager::run(). It can be used for initializations which have to be repeated at the beginning of every single call to run in a prepare-run-run-...-run-run-cleanup sequence.
Implements nest::RecordingBackend.
|
overridevirtual |
Prepare the backend at begin of the NEST Simulate function.
This function is called by KernelManager::prepare() and allows the backend to open files or establish network connections or take similar action.
Implements nest::RecordingBackend.
References open_files_().
|
overridevirtual |
Set the status of the recording backend using the key-value pairs contained in the params dictionary.
| params | the status of the recording backend |
Implements nest::RecordingBackend.
References P_, and nest::RecordingBackendSIONlib::Parameters_::set().
|
overridevirtual |
To make the names of recorded quantities known to the RecordingBackend, the vectors double_value_names and long_value_names can be set appropriately.
If no values of a certain type (or none at all) will be recorded by device, the constants NO_DOUBLE_VALUE_NAMES and NO_LONG_VALUE_NAMES can be used. Please note that the lengths of the value names vectors must correspond to the length of the data vectors written during calls to write(), although this is not enforced by the API.
| device | the device to set the value names for |
| double_value_names | the names for double values to be recorded |
| long_value_names | the names for long values to be recorded |
Implements nest::RecordingBackend.
References devices_, nest::RecordingBackendSIONlib::DeviceInfo::double_value_names, nest::Node::get_node_id(), nest::Node::get_thread(), and nest::RecordingBackendSIONlib::DeviceInfo::long_value_names.
|
overridevirtual |
Write the data from the event to the backend specific channel together with the values given.
This function needs to respect the time_in_steps property of the device and should return as quickly as possible if the RecordingDevice device is not enrolled with the backend.
| device | the RecordingDevice, backend-specific channel to write to |
| event | the event |
| double_values | vector of double valued to be written |
| long_values | vector of long values to be written |
Implements nest::RecordingBackend.
References nest::RecordingBackendSIONlib::FileEntry::buffer, nest::RecordingBackendSIONlib::SIONBuffer::clear(), devices_, nest::RecordingBackendSIONlib::DeviceInfo::double_value_names, nest::RecordingBackendSIONlib::SIONBuffer::ensure_space(), files_, nest::find(), nest::RecordingBackendSIONlib::SIONBuffer::get_capacity(), nest::RecordingBackendSIONlib::SIONBuffer::get_free(), nest::Node::get_node_id(), nest::RecordingBackendSIONlib::SIONBuffer::get_size(), nest::Node::get_thread(), nest::Node::get_vp(), nest::RecordingBackendSIONlib::DeviceInfo::long_value_names, nest::RecordingBackendSIONlib::DeviceInfo::n_rec, P_, nest::RecordingBackendSIONlib::SIONBuffer::read(), nest::RecordingBackendSIONlib::FileEntry::sid, and nest::RecordingBackendSIONlib::Parameters_::sion_collective_.
Referenced by nest::RecordingBackendSIONlib::SIONBuffer::operator<<().
|
static |
|
static |
Referenced by close_files_().
|
private |
Referenced by close_files_(), disenroll(), enroll(), initialize(), open_files_(), set_value_names(), and write().
|
private |
|
private |
Referenced by close_files_(), open_files_(), post_step_hook(), and write().
|
private |
Referenced by close_files_(), open_files_(), and post_step_hook().
|
private |
Referenced by open_files_().
|
static |
Referenced by close_files_().
|
private |
Referenced by enroll(), and open_files_().
|
private |
Referenced by build_filename_(), get_status(), open_files_(), post_step_hook(), set_status(), and write().
|
static |
Referenced by close_files_().
|
private |
Referenced by close_files_(), and open_files_().
|
static |
Referenced by close_files_().