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

DataProvider is a class that provides shared memory data access to any local-node MPI process. More...

#include <DataProvider.h>

Public Member Functions

 DataProvider (const DataProvider &)=delete
DataProvideroperator= (const DataProvider &)=delete
 DataProvider (MPI_Comm comm, const std::vector< std::pair< std::string, std::size_t > > &nameSizePairs)
 Constructor.
int getShmRank () const
 Get the rank of the calling process in the shared memory communicator.
bool isShmRoot () const
 Check if the calling process is the root of the shared memory communicator (i.e., the one that provides the data).
double * getDataPtr (const std::string &name) const
 Get a pointer to the shared data array.
size_t getNumElements (const std::string &name) const
 Get the number of elements in the shared data array.
MPI_Comm getShmComm () const

Detailed Description

DataProvider is a class that provides shared memory data access to any local-node MPI process.

Constructor & Destructor Documentation

◆ DataProvider()

DataProvider::DataProvider ( MPI_Comm comm,
const std::vector< std::pair< std::string, std::size_t > > & nameSizePairs )

Constructor.

Parameters
commroot MPI communicator, the shared memory communicator will be derived from this
nameSizePairsvector of pairs containing shared array names and their sizes

Member Function Documentation

◆ getDataPtr()

double * DataProvider::getDataPtr ( const std::string & name) const
inline

Get a pointer to the shared data array.

Returns
pointer to the shared data array
Note
the returned pointer is valid only within the same shared memory node, and should not be used for MPI communication across different nodes. Additionally, the caller should ensure that the shared data array is properly synchronized (e.g., using MPI_Barrier) before accessing the data to ensure visibility of the data updates across all ranks on the same node.

◆ getNumElements()

size_t DataProvider::getNumElements ( const std::string & name) const
inline

Get the number of elements in the shared data array.

Returns
number of elements in the shared data array

◆ getShmComm()

MPI_Comm DataProvider::getShmComm ( ) const
inline

Get the MPI shm communicator

Returns
the MPI shm communicator

◆ getShmRank()

int DataProvider::getShmRank ( ) const
inline

Get the rank of the calling process in the shared memory communicator.

Returns
rank of the calling process in the shared memory communicator

◆ isShmRoot()

bool DataProvider::isShmRoot ( ) const
inline

Check if the calling process is the root of the shared memory communicator (i.e., the one that provides the data).

Returns
true if the calling process is the root of the shared memory communicator, false otherwise

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