NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::RecordingBackendMPI Class Reference

A recording backend for sending information with MPI. More...

#include <recording_backend_mpi.h>

Inheritance diagram for nest::RecordingBackendMPI:
[legend]
Collaboration diagram for nest::RecordingBackendMPI:
[legend]

Public Member Functions

 RecordingBackendMPI ()
 
 ~RecordingBackendMPI () throw ()
 
void initialize () override
 
void finalize () override
 
void enroll (const RecordingDevice &device, const Dictionary &params) 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 cleanup () override
 Clean up the backend at the end of a user level call to the NEST Simulate function.
 
void prepare () override
 Prepare the backend at begin of the NEST Simulate function.
 
void write (const RecordingDevice &, const Event &, const std::vector< double > &, const std::vector< long > &) 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 &params_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 ()
 

Private Types

typedef std::vector< std::map< size_t, std::tuple< int, MPI_Comm *, const RecordingDevice * > > > device_map
 A map for the enrolled devices.
 
typedef std::map< std::string, std::tuple< int, MPI_Comm *, int > > comm_map
 A map of MPI communicators used by the master thread for the MPI communication.
 

Private Member Functions

void get_port (const RecordingDevice *device, std::string *port_name)
 
void get_port (size_t index_node, const std::string &label, std::string *port_name)
 
void send_data (const MPI_Comm *comm, const double data[], int size)
 

Private Attributes

bool enrolled_
 
bool prepared_
 
std::vector< std::vector< std::vector< std::array< double, 3 > > > > buffer_
 Buffer for saving events before they are sent.
 
device_map devices_
 
comm_map commMap_
 
std::string mpi_address_
 

Additional Inherited Members

- 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
 

Detailed Description

A recording backend for sending information with MPI.

Communication protocol diagram:

General state machine diagram of NEST communication with the MPI backend:

Example of state machine diagram for the communication with NEST:

Member Typedef Documentation

◆ comm_map

typedef std::map< std::string, std::tuple< int, MPI_Comm*, int > > nest::RecordingBackendMPI::comm_map
private

A map of MPI communicators used by the master thread for the MPI communication.

The values of the map are tuples containing the index of the MPI communicator, the MPI communicator itself, and the number of devices linked to that MPI communicator.

◆ device_map

typedef std::vector< std::map< size_t, std::tuple< int, MPI_Comm*, const RecordingDevice* > > > nest::RecordingBackendMPI::device_map
private

A map for the enrolled devices.

We have a vector with one map per local thread.

The map associates the node ID of a device on a given thread with its MPI index and device. Only the master thread has a valid MPI communicator pointer.

Constructor & Destructor Documentation

◆ RecordingBackendMPI()

nest::RecordingBackendMPI::RecordingBackendMPI ( )

◆ ~RecordingBackendMPI()

nest::RecordingBackendMPI::~RecordingBackendMPI ( )
throw (
)

Member Function Documentation

◆ check_device_status()

void nest::RecordingBackendMPI::check_device_status ( const Dictionary &  params) const
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.

Parameters
paramsthe parameter dictionary to validate
See also
get_device_defaults(), get_device_status()

Implements nest::RecordingBackend.

◆ cleanup()

void nest::RecordingBackendMPI::cleanup ( )
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.

See also
prepare()

Implements nest::RecordingBackend.

References buffer_, commMap_, devices_, nest::VPManager::get_thread_id(), nest::kernel(), and nest::KernelManager::vp_manager.

Here is the call graph for this function:

◆ disenroll()

void nest::RecordingBackendMPI::disenroll ( const RecordingDevice &  device)
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.

Parameters
devicethe RecordingDevice to be disenrolled
See also
enroll()

Implements nest::RecordingBackend.

References devices_, nest::Node::get_node_id(), and nest::Node::get_thread().

Here is the call graph for this function:

◆ enroll()

void nest::RecordingBackendMPI::enroll ( const RecordingDevice &  device,
const Dictionary &  params 
)
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.

Parameters
devicethe RecordingDevice to be enrolled
paramsdevice-specific backend parameters
See also
set_value_names(), disenroll(), write(),

Implements nest::RecordingBackend.

References devices_, enrolled_, nest::Node::get_node_id(), nest::Node::get_thread(), nest::RecordingDevice::get_type(), nest::names::mpi_address(), mpi_address_, and nest::RecordingDevice::SPIKE_RECORDER.

Here is the call graph for this function:

◆ finalize()

void nest::RecordingBackendMPI::finalize ( )
overridevirtual

Implements nest::RecordingBackend.

References buffer_, commMap_, and devices_.

◆ get_device_defaults()

void nest::RecordingBackendMPI::get_device_defaults ( Dictionary &  params) const
overridevirtual

Return the per-device defaults by writing it to the given params dictionary.

Parameters
paramsthe dictionary to add device-specific backend parameters to
See also
check_device_status(), get_device_status()

Implements nest::RecordingBackend.

◆ get_device_status()

void nest::RecordingBackendMPI::get_device_status ( const RecordingDevice &  device,
Dictionary &  params 
) const
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.

Parameters
devicethe recording device for which the status is returned
paramsthe dictionary to add device-specific backend parameters to
See also
enroll(), check_device_status(), get_device_defaults()

Implements nest::RecordingBackend.

◆ get_port() [1/2]

void nest::RecordingBackendMPI::get_port ( const RecordingDevice *  device,
std::string *  port_name 
)
private

References nest::RecordingDevice::get_label(), nest::Node::get_node_id(), get_port(), and mpi_address_.

Referenced by get_port(), and prepare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_port() [2/2]

void nest::RecordingBackendMPI::get_port ( size_t  index_node,
const std::string &  label,
std::string *  port_name 
)
private

References nest::IOManager::get_data_path(), nest::IOManager::get_data_prefix(), nest::KernelManager::io_manager, and nest::kernel().

Here is the call graph for this function:

◆ get_status()

void nest::RecordingBackendMPI::get_status ( Dictionary &  params) const
overridevirtual

Return the status of the recording backend by writing it to the given params dictionary.

Parameters
paramsthe status of the recording backend
See also
set_status()

Implements nest::RecordingBackend.

◆ initialize()

void nest::RecordingBackendMPI::initialize ( )
overridevirtual

Implements nest::RecordingBackend.

References buffer_, devices_, nest::VPManager::get_num_threads(), nest::kernel(), and nest::KernelManager::vp_manager.

Here is the call graph for this function:

◆ post_run_hook()

void nest::RecordingBackendMPI::post_run_hook ( )
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.

See also
pre_run_hook()

Implements nest::RecordingBackend.

References buffer_, commMap_, and send_data().

Here is the call graph for this function:

◆ post_step_hook()

void nest::RecordingBackendMPI::post_step_hook ( )
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.

See also
pre_run_hook()

Implements nest::RecordingBackend.

◆ pre_run_hook()

void nest::RecordingBackendMPI::pre_run_hook ( )
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.

See also
post_run_hook()

Implements nest::RecordingBackend.

References commMap_.

◆ prepare()

void nest::RecordingBackendMPI::prepare ( )
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.

See also
cleanup()

Implements nest::RecordingBackend.

References buffer_, commMap_, devices_, enrolled_, get_port(), nest::VPManager::get_thread_id(), nest::INFO, nest::kernel(), LOG, prepared_, and nest::KernelManager::vp_manager.

Here is the call graph for this function:

◆ send_data()

void nest::RecordingBackendMPI::send_data ( const MPI_Comm *  comm,
const double  data[],
int  size 
)
private

Referenced by post_run_hook().

Here is the caller graph for this function:

◆ set_status()

void nest::RecordingBackendMPI::set_status ( const Dictionary &  params)
overridevirtual

Set the status of the recording backend using the key-value pairs contained in the params dictionary.

Parameters
paramsthe status of the recording backend
See also
get_status()

Implements nest::RecordingBackend.

◆ set_value_names()

void nest::RecordingBackendMPI::set_value_names ( const RecordingDevice &  device,
const std::vector< std::string > &  double_value_names,
const std::vector< std::string > &  long_value_names 
)
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.

Parameters
devicethe device to set the value names for
double_value_namesthe names for double values to be recorded
long_value_namesthe names for long values to be recorded
See also
enroll(), disenroll(), write(),

Implements nest::RecordingBackend.

◆ write()

void nest::RecordingBackendMPI::write ( const RecordingDevice &  device,
const Event &  event,
const std::vector< double > &  double_values,
const std::vector< long > &  long_values 
)
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.

Parameters
devicethe RecordingDevice, backend-specific channel to write to
eventthe event
double_valuesvector of double valued to be written
long_valuesvector of long values to be written

Implements nest::RecordingBackend.

References buffer_, devices_, nest::KernelManager::get_kernel_manager(), nest::Time::get_ms(), nest::Node::get_node_id(), nest::VPManager::get_thread_id(), nest::kernel(), and nest::KernelManager::vp_manager.

Here is the call graph for this function:

Member Data Documentation

◆ buffer_

std::vector< std::vector< std::vector< std::array< double, 3 > > > > nest::RecordingBackendMPI::buffer_
private

Buffer for saving events before they are sent.

The buffer has 3 dimensions: thread_id, MPI_communicator_index and number of events elements. The events elements are described as an array with three components: id of device, id of neurons and data ( one double )

Referenced by cleanup(), finalize(), initialize(), post_run_hook(), prepare(), and write().

◆ commMap_

comm_map nest::RecordingBackendMPI::commMap_
private

◆ devices_

device_map nest::RecordingBackendMPI::devices_
private

◆ enrolled_

bool nest::RecordingBackendMPI::enrolled_
private

Referenced by enroll(), and prepare().

◆ mpi_address_

std::string nest::RecordingBackendMPI::mpi_address_
private

Referenced by enroll(), and get_port().

◆ prepared_

bool nest::RecordingBackendMPI::prepared_
private

Referenced by prepare().


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