seapodym-parallel
Fish dynamics models with parameter estimations
Loading...
Searching...
No Matches
DistDataCollector Class Reference

DistDataCollector is a class that collects data stored on multiple MPI processes into a large array stored on a designated root rank. More...

#include <DistDataCollector.h>

Public Member Functions

 DistDataCollector (MPI_Comm comm, int numChunks, int numSize, int rootRank=0)
 Constructor.
 ~DistDataCollector ()
 Destructor.
MPI_Win & getWin ()
void fence ()
void startEpoch ()
 Start an epoch for RMA operations.
void flush ()
 Ensure that the RMA operation is completed and the data are visible to the manager.
void endEpoch ()
 End an epoch for RMA operations.
void put (int chunkId, const double *data)
 Put the local data into the collected array.
void putAsync (int chunkId, const double *data)
 Put the local data into the collected array (non-blocking).
void accumulate (int chunkId, const double *data)
 Atomically accumulate (add) local data into a chunk on rootRank. Uses MPI_Accumulate with MPI_SUM under a shared lock, so concurrent calls from different origins are safe. Blocks until the operation is complete and the result is visible at rootRank.
std::vector< double > get (int chunkId)
 Get a slice of the remote, collected array to the local worker.
void get (int chunkId, double *buffer)
 Get a slice of the remote, collected array to the local worker.
void getAsync (int chunkId, double *buffer)
 Get a slice of the remote, collected array to the local worker (non-blocking).
double * getCollectedDataPtr ()
int getNumChunks () const
int getNumSize () const
void free ()
 Free the MPI window and empty the collected data.
 DistDataCollector (const DistDataCollector &)=delete
DistDataCollectoroperator= (const DistDataCollector &)=delete
 DistDataCollector (DistDataCollector &&other) noexcept
DistDataCollectoroperator= (DistDataCollector &&other) noexcept

Public Attributes

const double BAD_VALUE = std::numeric_limits<double>::quiet_NaN()

Detailed Description

DistDataCollector is a class that collects data stored on multiple MPI processes into a large array stored on a designated root rank.

Constructor & Destructor Documentation

◆ DistDataCollector()

DistDataCollector::DistDataCollector ( MPI_Comm comm,
int numChunks,
int numSize,
int rootRank = 0 )

Constructor.

Parameters
commMPI communicator to use for communication
numChunksThe number of array slices on rootRank
numSizeThe size of each slice
rootRankMPI rank that holds the collected data (default: 0)

Member Function Documentation

◆ accumulate()

void DistDataCollector::accumulate ( int chunkId,
const double * data )

Atomically accumulate (add) local data into a chunk on rootRank. Uses MPI_Accumulate with MPI_SUM under a shared lock, so concurrent calls from different origins are safe. Blocks until the operation is complete and the result is visible at rootRank.

Parameters
chunkIdLeading index in the collected array
dataPointer to the values to add (must have numSize elements)

◆ fence()

void DistDataCollector::fence ( )

Active target synchronization

Note
call this before and after a put operation to ensure that the target data are visible. All ranks must call this method.

◆ get() [1/2]

std::vector< double > DistDataCollector::get ( int chunkId)

Get a slice of the remote, collected array to the local worker.

Parameters
chunkIdLeading index in the collected array
Returns
data array
Note
this should be executed on the source process, typically by the worker

◆ get() [2/2]

void DistDataCollector::get ( int chunkId,
double * buffer )

Get a slice of the remote, collected array to the local worker.

Parameters
chunkIdLeading index in the collected array
bufferwill hold the fetched data
Note
this should be executed on the source process, typically by the worker

◆ getAsync()

void DistDataCollector::getAsync ( int chunkId,
double * buffer )
inline

Get a slice of the remote, collected array to the local worker (non-blocking).

Parameters
chunkIdLeading index in the collected array
bufferwill hold the fetched data
Note
this should be executed on the source process, typically by the worker. This is a non-blocking call which relies on startEpoch/flush/endEpoch to complete

◆ getCollectedDataPtr()

double * DistDataCollector::getCollectedDataPtr ( )
inline

Get the pointer to the collected data

Returns
pointer
Note
this returns a null pointer on ranks other than rootRank

◆ getNumChunks()

int DistDataCollector::getNumChunks ( ) const
inline

Get the number of chunks

Returns
number

◆ getNumSize()

int DistDataCollector::getNumSize ( ) const
inline

Get the size of each chunk

Returns
number

◆ getWin()

MPI_Win & DistDataCollector::getWin ( )
inline

Get the MPI window

◆ put()

void DistDataCollector::put ( int chunkId,
const double * data )

Put the local data into the collected array.

Parameters
chunkIdLeading index in the collected array
dataPointer to the local data to inject
Note
this should be executed on the source process, typically by the worker

◆ putAsync()

void DistDataCollector::putAsync ( int chunkId,
const double * data )
inline

Put the local data into the collected array (non-blocking).

Parameters
chunkIdLeading index in the collected array
dataPointer to the local data to inject
Note
this should be executed on the source process, typically by the worker This is a non-blocking call which relies on startEpoch/flush/endEpoch to

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