Hex  2.2
Hydrogen-electron collision solver
Public Member Functions
Parallel Class Reference

MPI info. More...

#include <parallel.h>

Public Member Functions

 Parallel (int *argc, char ***argv, bool active, int groupsize)
 Constructor. More...
 
 ~Parallel ()
 
bool IamMaster () const
 Returns true if this process is the master process. More...
 
bool IamGroupMaster () const
 Returns true if this process is the master process within a group. More...
 
bool isMyWork (int i) const
 Returns true if the work item is assigned to this process. More...
 
bool isMyGroupWork (int i) const
 Returns true if the work item is assigned to this process' group. More...
 
bool active () const
 Returns true if the MPI is active. More...
 
int iproc () const
 Returns the rank of the communicator (process is). More...
 
int igroup () const
 Returns the rank of process group. More...
 
int igroupproc () const
 Returns index of rank within the group. More...
 
int Nproc () const
 Returns the size of the communicator (process count). More...
 
int Ngroup () const
 Returns the number of groups. More...
 
int groupsize () const
 Return group size. More...
 
template<class T >
void bcast (int owner, T *data, std::size_t N) const
 Broadcast array from owner to everyone. More...
 
template<class T >
void bcast (int owner, NumberArray< T > &data) const
 Broadcast array from owner to everyone. More...
 
template<class T >
void bcast_g (int igroup, int groupowner, T *data, std::size_t N) const
 Broadcast array from owner to everyone in the group. More...
 
template<class T >
void send (T const *array, std::size_t size, int origin, int destination) const
 Send data to a process. More...
 
template<class T >
void recv (T *array, std::size_t size, int origin, int destination) const
 Receive data from a process. More...
 
template<class T >
void sync (T *array, std::size_t chunksize, std::size_t Nchunk) const
 Synchronize across processes by composition. More...
 
template<class T >
void sync_m (T *array, std::size_t chunksize, std::size_t Nchunk) const
 
template<class T >
void sum (T *array, std::size_t N, int owner=0) const
 Sum arrays to node. More...
 
template<class T >
void syncsum (T *array, std::size_t N) const
 Synchronize across processes by summing. More...
 
template<class T >
void syncsum_g (T *array, std::size_t N) const
 Synchronize across group's processes by summing. More...
 
template<class T >
void sum_g (T *array, std::size_t N, int destination) const
 Sum array within group to a given process. More...
 
template<class T >
void mastersum (T *array, std::size_t N, int destgroup) const
 Sum array from all group masters to one of the group masters. More...
 
void wait () const
 Wait for completition of all running tasks. More...
 
void wait_g () const
 
void * groupcomm () const
 

Detailed Description

The class Parallel holds some useful MPI data, like the rank and size of the communicator. This class should be used for all parallel communication using MPI.

Constructor & Destructor Documentation

◆ Parallel()

Parallel::Parallel ( int *  argc,
char ***  argv,
bool  active,
int  groupsize 
)
inline

Initializes MPI (using the MPI_Init) function. Also determines the rank and size of the communicator.

Parameters
argcArgc as received by main().
argvArgv as received by main().
activeWhether to turn the MPI on or keep with the computation sequential.

◆ ~Parallel()

Parallel::~Parallel ( )
inline

Member Function Documentation

◆ active()

bool Parallel::active ( ) const
inline

◆ bcast() [1/2]

template<class T >
void Parallel::bcast ( int  owner,
T *  data,
std::size_t  N 
) const
inline

◆ bcast() [2/2]

template<class T >
void Parallel::bcast ( int  owner,
NumberArray< T > &  data 
) const
inline

◆ bcast_g()

template<class T >
void Parallel::bcast_g ( int  igroup,
int  groupowner,
T *  data,
std::size_t  N 
) const
inline

◆ groupcomm()

void* Parallel::groupcomm ( ) const
inline

◆ groupsize()

int Parallel::groupsize ( ) const
inline

◆ IamGroupMaster()

bool Parallel::IamGroupMaster ( ) const
inline

This function returns true if this process is the master process within its, i.e. it has local ID zero.

◆ IamMaster()

bool Parallel::IamMaster ( ) const
inline

This function returns true if this process is the master process, i.e. it has ID zero.

◆ igroup()

int Parallel::igroup ( ) const
inline

◆ igroupproc()

int Parallel::igroupproc ( ) const
inline

◆ iproc()

int Parallel::iproc ( ) const
inline

◆ isMyGroupWork()

bool Parallel::isMyGroupWork ( int  i) const
inline

If there are several work items, i-th one is assigned to the (i % Ngroup)-th group. This function returns true whenever given work item (indexed by "i") is to be processed by the current process' group.

Parameters
iWork item ID.

◆ isMyWork()

bool Parallel::isMyWork ( int  i) const
inline

If there are several work items, i-th one is assigned to the (i % Nproc_)-th process. This function returns true whenever given work item (indexed by "i") is to be processed by the current process.

Parameters
iWork item ID.

◆ mastersum()

template<class T >
void Parallel::mastersum ( T *  array,
std::size_t  N,
int  destgroup 
) const
inline

◆ Ngroup()

int Parallel::Ngroup ( ) const
inline

◆ Nproc()

int Parallel::Nproc ( ) const
inline

◆ recv()

template<class T >
void Parallel::recv ( T *  array,
std::size_t  size,
int  origin,
int  destination 
) const
inline

◆ send()

template<class T >
void Parallel::send ( T const *  array,
std::size_t  size,
int  origin,
int  destination 
) const
inline

◆ sum()

template<class T >
void Parallel::sum ( T *  array,
std::size_t  N,
int  owner = 0 
) const
inline

◆ sum_g()

template<class T >
void Parallel::sum_g ( T *  array,
std::size_t  N,
int  destination 
) const
inline

◆ sync()

template<class T >
void Parallel::sync ( T *  array,
std::size_t  chunksize,
std::size_t  Nchunk 
) const
inline

Synchronize array across processes. It is assumed that i-th chunk of the array is present on the (i % Nproc_)-th process. That process will be used as the broadcast root. This behaviour is compatible with the member function isMyWork.

Parameters
arrayPointer to data array to synchronize.
chunksizeSize of the per-process segment.
NchunkTotal number of chunks in the array. Altogether chunksize*Nchunk elements will be synchronized. If there are some elements more, they will be left untouched (and un-broadcast).

It is expected that the array has length equal or greater than chunksize * Nchunk.

◆ sync_m()

template<class T >
void Parallel::sync_m ( T *  array,
std::size_t  chunksize,
std::size_t  Nchunk 
) const
inline

◆ syncsum()

template<class T >
void Parallel::syncsum ( T *  array,
std::size_t  N 
) const
inline

Synchronize array across processes by summing.

Parameters
arrayPointer to data array to synchronize.
NchunkNumber of elements in the array to sum-synchronize. If there are some elements more, they will be left untouched (and un-broadcast).

◆ syncsum_g()

template<class T >
void Parallel::syncsum_g ( T *  array,
std::size_t  N 
) const
inline

Synchronize array across group's processes by summing.

Parameters
arrayPointer to data array to synchronize.
NchunkNumber of elements in the array to sum-synchronize. If there are some elements more, they will be left untouched (and un-broadcast).

◆ wait()

void Parallel::wait ( ) const
inline

Inserts a MPI BARRIER.

◆ wait_g()

void Parallel::wait_g ( ) const
inline

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