Skip to content

Commit

Permalink
communications: add getRank and getProcessorCount to DataCommunicator…
Browse files Browse the repository at this point in the history
… class
  • Loading branch information
marcocisternino committed Apr 16, 2024
1 parent 3ae33ab commit 3b2ab1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/communications/communications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,32 @@ DataCommunicator::~DataCommunicator()
}
}

/*!
Gets the rank in the MPI communicator
\return the MPI rank.
*/
int DataCommunicator::getRank() const
{
int rank;
MPI_Comm_rank(m_communicator, &rank);

return rank;
}

/*!
Gets the number of processes in the MPI communicator
\return The number of processes in the MPI communicator.
*/
int DataCommunicator::getProcessorCount() const
{
int nProcs;
MPI_Comm_size(m_communicator, &nProcs);

return nProcs;
}

/*!
Gets the MPI communicator
Expand Down
3 changes: 3 additions & 0 deletions src/communications/communications.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class DataCommunicator

const MPI_Comm & getCommunicator() const;

int getRank() const;
int getProcessorCount() const;

void finalize(bool synchronous = false);

void setTag(int exchangeTag);
Expand Down

0 comments on commit 3b2ab1a

Please sign in to comment.