Hex  1.0
Hydrogen-electron collision solver
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions
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 

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

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

Member Function Documentation

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

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

int Parallel::iproc ( ) const
bool Parallel::isMyWork ( int  i) const

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.

iWork item ID.
int Parallel::Nproc ( ) const
template<class T >
void Parallel::sync ( ArrayView< T >  array,
size_t  chunksize,
size_t  Nchunk 
) const

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.

arrayArray 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).
void Parallel::wait ( ) const

Inserts a MPI BARRIER.

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