Hex  1.0 Hydrogen-electron collision solver
Parallel Class Reference

MPI info. More...

#include <parallel.h>

## Public Member Functions

Parallel (int *argc, char ***argv, bool active)
Constructor. More...

~Parallel ()

bool IamMaster () const
Returns true if this process is the master process. More...

bool isMyWork (int i) const
Returns true if the work item is assigned to this process. 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 Nproc () const
Returns the size of the communicator (process count). More...

template<class T >
void sync (ArrayView< T > array, size_t chunksize, size_t Nchunk) const
Synchronize across processes. More...

void wait () const
Wait for completition of all running tasks. More...

## 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 ( int * argc, char *** argv, bool active )
inline

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

Parameters
 argc Argc as received by main(). argv Argv as received by main(). active Whether to turn the MPI on or keep with the computation sequential.
 Parallel::~Parallel ( )
inline

## Member Function Documentation

 bool Parallel::active ( ) const
inline
 bool Parallel::IamMaster ( ) const
inline

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

 int Parallel::iproc ( ) const
inline
 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 wirk item (indexed by "i") is to be processed by the current process.

Parameters
 i Work item ID.
 int Parallel::Nproc ( ) const
inline
template<class T >
 void Parallel::sync ( ArrayView< T > array, size_t chunksize, 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
 array Array to synchronize, chunksize Size of the per-process segment. Nchunk Total 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).
 void Parallel::wait ( ) const
inline

Inserts a MPI BARRIER.

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