Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting MPI port names of MPI recording and stimulation backends from device labels #2585

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion nestkernel/recording_backend_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,27 @@ nest::RecordingBackendMPI::set_status( const DictionaryDatum& )
void
nest::RecordingBackendMPI::get_port( const RecordingDevice* device, std::string* port_name )
{
get_port( device->get_node_id(), device->get_label(), port_name );
const std::string& label = device->get_label();
std::size_t colon_position;

// The MPI address can be provided by two different means:
// a) the address is taken from the device's label, which then has to be in the format: endpoint_address:address
// b) the address is provided via a file: {data_path}/{data_prefix}{device_label}/{node_id}.txt

// Case a: device label is the endpoint address in the following format:
// endpoint_address:address string
colon_position = label.find( ":", 0 );

// check if string start with "endpoint_address:" and a colon is found
if ( label.find( "endpoint_address:" ) == 0 )
{
*port_name = label.substr( colon_position + 1 );
}
// Case b: fallback to get_port implementation that reads the address from file
else
{
get_port( device->get_node_id(), label, port_name );
}
}

void
Expand Down
9 changes: 9 additions & 0 deletions nestkernel/recording_backend_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ Description

The `mpi` recording backend sends collected data to a remote process
using MPI.
There are two ways to set the MPI port (if both are set, option A has precedence):

A)
The label of the recording device has the pattern:

::

endpoint_address:port_name

B)
The name of the MPI port to send data to is read from a file for each
device configured to use this backend. The file needs to be named
according to the following pattern:
Expand Down
22 changes: 21 additions & 1 deletion nestkernel/stimulation_backend_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,27 @@ nest::StimulationBackendMPI::cleanup()
void
nest::StimulationBackendMPI::get_port( nest::StimulationDevice* device, std::string* port_name )
{
get_port( device->get_node_id(), device->get_label(), port_name );
const std::string& label = device->get_label();
std::size_t colon_position;

// The MPI address can be provided by two different means:
// a) the address is given by the label in the format: endpoint_address:address
// b) the file is provided via a file: {data_path}/{data_prefix}{label}/{node_id}.txt

// Case a: label is the endpoint address in the following format:
// endpoint_address:address string
colon_position = label.find( ":", 0 );

// check if string start with "endpoint_address:" and a colon is found
if ( label.find( "endpoint_address:" ) == 0 )
{
*port_name = label.substr( colon_position + 1 );
}
// Case b: fallback to get_port implementation that reads the address from file
else
{
get_port( device->get_node_id(), label, port_name );
}
}

void
Expand Down
9 changes: 9 additions & 0 deletions nestkernel/stimulation_backend_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ The `mpi` stimulation backend collects data from MPI channels and
updates stimulation devices just before each run. This is useful for
co-simulation or for receiving stimuli from external software.

There are two ways to set the MPI port (if both are set, option A has precedence):

A)
The label of the recording device has the pattern:

::
endpoint_address:port_name

B)
The name of the MPI port to receive data on is read from a file for
each device configured to use this backend. The file needs to be
named according to the following pattern:
Expand Down