geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
geopm::MPIComm Class Reference

Implementation of the Comm interface using MPI as the underlying communication mechanism. More...

#include <MPIComm.hpp>

Inheritance diagram for geopm::MPIComm:
Inheritance graph
[legend]
Collaboration diagram for geopm::MPIComm:
Collaboration graph
[legend]

Public Member Functions

 MPIComm ()
 
 MPIComm (const MPIComm &other)=delete
 
MPICommoperator= (const MPIComm &other)=delete
 
 MPIComm (MPI_Comm in_comm)
 
 MPIComm (const MPIComm *in_comm)
 
 MPIComm (const MPIComm *in_comm, std::vector< int > dimension, std::vector< int > periods, bool is_reorder)
 
 MPIComm (const MPIComm *in_comm, int color, int key)
 
 MPIComm (const MPIComm *in_comm, const std::string &tag, bool &is_ctl)
 
 MPIComm (const MPIComm *in_comm, const std::string &tag)
 
 MPIComm (const MPIComm *in_comm, const std::string &tag, int split_type)
 
virtual ~MPIComm ()
 
virtual std::shared_ptr< Commsplit () const override
 
virtual std::shared_ptr< Commsplit (int color, int key) const override
 
virtual std::shared_ptr< Commsplit (const std::string &tag, int split_type) const override
 
virtual std::shared_ptr< Commsplit (std::vector< int > dimensions, std::vector< int > periods, bool is_reorder) const override
 
virtual std::shared_ptr< Commsplit_cart (std::vector< int > dimensions) const override
 
virtual bool comm_supported (const std::string &description) const override
 
virtual int cart_rank (const std::vector< int > &coords) const override
 Process rank within Cartesian communicator. More...
 
virtual int rank (void) const override
 Process rank within communicator. More...
 
virtual int num_rank (void) const override
 Number of ranks in the communicator. More...
 
virtual void dimension_create (int num_ranks, std::vector< int > &dimension) const override
 Populate vector of optimal dimensions given the number of ranks the communicator. More...
 
virtual void alloc_mem (size_t size, void **base) override
 Allocate memory for message passing and RMA. More...
 
virtual void free_mem (void *base) override
 Free memory that was allocated for message passing and RMA. More...
 
virtual size_t window_create (size_t size, void *base) override
 Create window for message passing and RMA. More...
 
virtual void window_destroy (size_t window_id) override
 Destroy window for message passing and RMA. More...
 
virtual void coordinate (int rank, std::vector< int > &coord) const override
 Coordinate in Cartesian grid for specified rank. More...
 
virtual std::vector< int > coordinate (int rank) const override
 
virtual void window_lock (size_t window_id, bool is_exclusive, int rank, int assert) const override
 Begin epoch for message passing and RMA. More...
 
virtual void window_unlock (size_t window_id, int rank) const override
 End epoch for message passing and RMA. More...
 
virtual void barrier (void) const override
 Barrier for all ranks. More...
 
virtual void broadcast (void *buffer, size_t size, int root) const override
 Broadcast a message to all ranks. More...
 
virtual bool test (bool is_true) const override
 Test whether or not all ranks in the communicator present the same input and return true/false accordingly. More...
 
virtual void reduce_max (double *send_buf, double *recv_buf, size_t count, int root) const override
 Reduce distributed messages across all ranks using specified operation, store result on all ranks. More...
 
virtual void gather (const void *send_buf, size_t send_size, void *recv_buf, size_t recv_size, int root) const override
 Gather bytes from all processes. More...
 
virtual void gatherv (const void *send_buf, size_t send_size, void *recv_buf, const std::vector< size_t > &recv_sizes, const std::vector< off_t > &rank_offset, int root) const override
 Gather bytes into specified location from all processes. More...
 
virtual void window_put (const void *send_buf, size_t send_size, int rank, off_t disp, size_t window_id) const override
 Perform message passing or RMA. More...
 
void tear_down (void) override
 Clean up resources held by the comm. This allows static global objects to be cleaned up before the destructor is called. More...
 
- Public Member Functions inherited from geopm::Comm
 Comm ()=default
 Constructor for global communicator. More...
 
 Comm (const Comm &other)=default
 
Commoperator= (const Comm &other)=default
 
virtual ~Comm ()=default
 Default destructor. More...
 

Static Public Member Functions

static std::string plugin_name (void)
 
static std::unique_ptr< Commmake_plugin (void)
 
static MPICommcomm_world (void)
 
- Static Public Member Functions inherited from geopm::Comm
static std::vector< std::string > comm_names (void)
 
static std::unique_ptr< Commmake_unique (const std::string &comm_name)
 
static std::unique_ptr< Commmake_unique (void)
 

Protected Member Functions

void check_window (size_t window_id) const
 
bool is_valid () const
 

Protected Attributes

MPI_Comm m_comm
 
size_t m_maxdims
 
std::set< size_t > m_windows
 
const std::string m_name
 
bool m_is_torn_down = false
 

Additional Inherited Members

- Public Types inherited from geopm::Comm
enum  m_comm_split_type_e { M_COMM_SPLIT_TYPE_PPN1 , M_COMM_SPLIT_TYPE_SHARED , M_NUM_COMM_SPLIT_TYPE }
 
enum  m_split_color_e { M_SPLIT_COLOR_UNDEFINED = -16 }
 
- Static Public Attributes inherited from geopm::Comm
static const std::string M_PLUGIN_PREFIX = "libgeopmcomm_"
 

Detailed Description

Implementation of the Comm interface using MPI as the underlying communication mechanism.

Constructor & Destructor Documentation

◆ MPIComm() [1/9]

geopm::MPIComm::MPIComm ( )

◆ MPIComm() [2/9]

geopm::MPIComm::MPIComm ( const MPIComm other)
delete

◆ MPIComm() [3/9]

geopm::MPIComm::MPIComm ( MPI_Comm  in_comm)

◆ MPIComm() [4/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm)

◆ MPIComm() [5/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm,
std::vector< int >  dimension,
std::vector< int >  periods,
bool  is_reorder 
)

◆ MPIComm() [6/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm,
int  color,
int  key 
)

◆ MPIComm() [7/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm,
const std::string &  tag,
bool &  is_ctl 
)

◆ MPIComm() [8/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm,
const std::string &  tag 
)

◆ MPIComm() [9/9]

geopm::MPIComm::MPIComm ( const MPIComm in_comm,
const std::string &  tag,
int  split_type 
)

◆ ~MPIComm()

geopm::MPIComm::~MPIComm ( )
virtual

Member Function Documentation

◆ alloc_mem()

void geopm::MPIComm::alloc_mem ( size_t  size,
void **  base 
)
overridevirtual

Allocate memory for message passing and RMA.

Parameters
[in]sizeSize of the desired memory allocation.
[out]baseAddress of allocated memory.

Implements geopm::Comm.

◆ barrier()

void geopm::MPIComm::barrier ( void  ) const
overridevirtual

Barrier for all ranks.

Implements geopm::Comm.

◆ broadcast()

void geopm::MPIComm::broadcast ( void *  buffer,
size_t  size,
int  root 
) const
overridevirtual

Broadcast a message to all ranks.

Parameters
[in,out]bufferStarting address of buffer to be broadcasted.
[in]sizeSize of the buffer.
[in]rootRank of the broadcast root (target).

Implements geopm::Comm.

◆ cart_rank()

int geopm::MPIComm::cart_rank ( const std::vector< int > &  coords) const
overridevirtual

Process rank within Cartesian communicator.

Parameters
[in]coordsCoordinate of Cartesian communicator member whose rank we wish to know.

Implements geopm::Comm.

◆ check_window()

void geopm::MPIComm::check_window ( size_t  window_id) const
protected

◆ comm_supported()

bool geopm::MPIComm::comm_supported ( const std::string &  description) const
overridevirtual

Implements geopm::Comm.

◆ comm_world()

MPIComm & geopm::MPIComm::comm_world ( void  )
static

◆ coordinate() [1/2]

std::vector< int > geopm::MPIComm::coordinate ( int  rank) const
overridevirtual

Implements geopm::Comm.

◆ coordinate() [2/2]

void geopm::MPIComm::coordinate ( int  rank,
std::vector< int > &  coord 
) const
overridevirtual

Coordinate in Cartesian grid for specified rank.

Parameters
[in]rankRank for which coordinates should be calculated
[in,out]coordCartesian coordinates of specified rank. The size of this vector should equal the number of dimensions that the Cartesian communicator was created with.

Implements geopm::Comm.

◆ dimension_create()

void geopm::MPIComm::dimension_create ( int  num_ranks,
std::vector< int > &  dimension 
) const
overridevirtual

Populate vector of optimal dimensions given the number of ranks the communicator.

Parameters
[in]num_ranksNumber of ranks that must fit in Cartesian grid.
[in,out]dimensionNumber of ranks per dimension. The size of this vector dictates the number of dimensions in the grid. Fill indices with 0 for API to fill with suitable value.

Implements geopm::Comm.

◆ free_mem()

void geopm::MPIComm::free_mem ( void *  base)
overridevirtual

Free memory that was allocated for message passing and RMA.

Parameters
[in]baseAddress of memory to be released.

Implements geopm::Comm.

◆ gather()

void geopm::MPIComm::gather ( const void *  send_buf,
size_t  send_size,
void *  recv_buf,
size_t  recv_size,
int  root 
) const
overridevirtual

Gather bytes from all processes.

Parameters
[in]send_bufStart address of memory buffer to be transmitted.
[in]send_sizeSize of buffer to be sent.
[out]recv_bufStart address of memory buffer to receive data.
[in]recv_sizeThe size of the buffer to be received.
[in]rootRank of the target for the transmission.

Implements geopm::Comm.

◆ gatherv()

void geopm::MPIComm::gatherv ( const void *  send_buf,
size_t  send_size,
void *  recv_buf,
const std::vector< size_t > &  recv_sizes,
const std::vector< off_t > &  rank_offset,
int  root 
) const
overridevirtual

Gather bytes into specified location from all processes.

Parameters
[in]send_bufStart address of memory buffer to be transmitted.
[in]send_sizeSize of buffer to be sent.
[out]recv_bufStart address of memory buffer to receive data.
[in]recv_sizesVector describing the buffer size per rank to be received.
[in]rank_offsetOffset per rank into target buffer for transmitted data.
[in]rootRank of the target for the transmission.

Implements geopm::Comm.

◆ is_valid()

bool geopm::MPIComm::is_valid ( ) const
protected

◆ make_plugin()

std::unique_ptr< Comm > geopm::MPIComm::make_plugin ( void  )
static

◆ num_rank()

int geopm::MPIComm::num_rank ( void  ) const
overridevirtual

Number of ranks in the communicator.

Implements geopm::Comm.

◆ operator=()

MPIComm& geopm::MPIComm::operator= ( const MPIComm other)
delete

◆ plugin_name()

std::string geopm::MPIComm::plugin_name ( void  )
static

◆ rank()

int geopm::MPIComm::rank ( void  ) const
overridevirtual

Process rank within communicator.

Implements geopm::Comm.

◆ reduce_max()

void geopm::MPIComm::reduce_max ( double *  send_buf,
double *  recv_buf,
size_t  count,
int  root 
) const
overridevirtual

Reduce distributed messages across all ranks using specified operation, store result on all ranks.

Parameters
[in]send_bufStart address of memory buffer to be transmitted.
[out]recv_bufStart address of memory buffer to receive data.
[in]countSize of buffer in bytes to be transmitted.

Implements geopm::Comm.

◆ split() [1/4]

std::shared_ptr< Comm > geopm::MPIComm::split ( void  ) const
overridevirtual

Implements geopm::Comm.

◆ split() [2/4]

std::shared_ptr< Comm > geopm::MPIComm::split ( const std::string &  tag,
int  split_type 
) const
overridevirtual

Implements geopm::Comm.

◆ split() [3/4]

std::shared_ptr< Comm > geopm::MPIComm::split ( int  color,
int  key 
) const
overridevirtual

Implements geopm::Comm.

◆ split() [4/4]

std::shared_ptr< Comm > geopm::MPIComm::split ( std::vector< int >  dimensions,
std::vector< int >  periods,
bool  is_reorder 
) const
overridevirtual

Implements geopm::Comm.

◆ split_cart()

std::shared_ptr< Comm > geopm::MPIComm::split_cart ( std::vector< int >  dimensions) const
overridevirtual

Implements geopm::Comm.

◆ tear_down()

void geopm::MPIComm::tear_down ( void  )
overridevirtual

Clean up resources held by the comm. This allows static global objects to be cleaned up before the destructor is called.

Implements geopm::Comm.

◆ test()

bool geopm::MPIComm::test ( bool  is_true) const
overridevirtual

Test whether or not all ranks in the communicator present the same input and return true/false accordingly.

Parameters
[in]is_trueBoolean value to be reduced from all ranks.

Implements geopm::Comm.

◆ window_create()

size_t geopm::MPIComm::window_create ( size_t  size,
void *  base 
)
overridevirtual

Create window for message passing and RMA.

Returns
window handle for subsequent operations on the window.
Parameters
[in]sizeSize of the memory area backing the RMA window.
[in]baseAddress of memory that has been allocated for the window.

Implements geopm::Comm.

◆ window_destroy()

void geopm::MPIComm::window_destroy ( size_t  window_id)
overridevirtual

Destroy window for message passing and RMA.

Parameters
[in]window_idThe window handle for the target window.

Implements geopm::Comm.

◆ window_lock()

void geopm::MPIComm::window_lock ( size_t  window_id,
bool  is_exclusive,
int  rank,
int  assert 
) const
overridevirtual

Begin epoch for message passing and RMA.

Parameters
[in]window_idThe window handle for the target window.
[in]is_exclusiveLock type for the window, true for exclusive lock, false for shared.
[in]rankRank of the locked window.
[in]assertUsed to optimize call.

Implements geopm::Comm.

◆ window_put()

void geopm::MPIComm::window_put ( const void *  send_buf,
size_t  send_size,
int  rank,
off_t  disp,
size_t  window_id 
) const
overridevirtual

Perform message passing or RMA.

Parameters
[in]send_bufStarting address of buffer to be transmitted via window.
[in]send_sizeSize in bytes of buffer to be sent.
[in]rankTarget rank of the transmission.
[in]dispDisplacement from start of window.
[in]window_idThe window handle for the target window.

Implements geopm::Comm.

◆ window_unlock()

void geopm::MPIComm::window_unlock ( size_t  window_id,
int  rank 
) const
overridevirtual

End epoch for message passing and RMA.

Parameters
[in]window_idThe window handle for the target window.
[in]rankRank of the locked window.

Implements geopm::Comm.

Member Data Documentation

◆ m_comm

MPI_Comm geopm::MPIComm::m_comm
protected

◆ m_is_torn_down

bool geopm::MPIComm::m_is_torn_down = false
protected

◆ m_maxdims

size_t geopm::MPIComm::m_maxdims
protected

◆ m_name

const std::string geopm::MPIComm::m_name
protected

◆ m_windows

std::set<size_t> geopm::MPIComm::m_windows
protected

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