C++ mpi module for stochmagnet_main Package
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
MPI_CanonicalGridEnvironment< N > Class Template Reference

This class is a grid Environment of templated dimension N=1,2,3. More...

#include <MPI_CanonicalGridEnvironment.h>

Inheritance diagram for MPI_CanonicalGridEnvironment< N >:
Inheritance graph
[legend]
Collaboration diagram for MPI_CanonicalGridEnvironment< N >:
Collaboration graph
[legend]

Public Member Functions

virtual tMemSize getMemorySize () const override
 return the memory size of the class
 
virtual tMemSize getContentsMemorySize () const override
 return the memory size of the included associations More...
 
virtual void initialize ()
 initialize the environment More...
 
const tMPICoreId & getFaceNeighbor (const tUCInt &f) const
 get the neighbor core More...
 
void getFaceNeighbors (const tUCInt &k, tMPICoreId &previousNeighbor, tMPICoreId &nextNeighbor) const
 get the neighbor cores More...
 
const std::array< tMPICoreId, 2 *N > & getFaceNeighbors () const
 get the face neighbor cores More...
 
- Public Member Functions inherited from MPI_GridEnvironment< N >
template<typename Q >
void setGridSize (const std::array< Q, N > &Ns)
 get the grids number More...
 
const std::array< tMPICoreId, N > & getGridSize () const
 get the grids number
 
template<typename Q >
void setIndices (const std::array< Q, N > &indices)
 set the indices of the current core More...
 
const std::array< tMPICoreId, N > & getIndices () const
 get the indices of the current core within the grid environment
 
const std::array< tBoolean, N > & getGridPeriodicity () const
 return the periodicity of the grid
 
const tBoolean & isPeriodic (const tUCInt &k) const
 return true if the grid is periodic in direction k More...
 
template<typename Q >
void setGridPeriodicity (const std::array< Q, N > &Ts)
 set grid periodicity More...
 
tMPIError getCoreIdAtIndices (const std::array< tMPICoreId, N > &indices, tMPICoreId &coreId) const
 the core id within the grid at indices More...
 
tMPIError getCoreIndices (const tMPICoreId &coreId, std::array< tMPICoreId, N > &indices) const
 get the indices of the core with coreId More...
 
- Public Member Functions inherited from MPI_Environment
const tMPIComm & getWorld () const
 get the world of the environment for reading
 
tMPIComm & getWorld ()
 get the world of the environment for reading
 
const tMPICoreId & getCoresNumber () const
 get the number of cores of this environment of common environment More...
 
const tMPICoreId & getCoreId () const
 get the id of the current process of this environment More...
 
tMPIError abort (const tMPIError &errCode) const
 abort the process on all cores with the error code More...
 
tBoolean synchronize () const
 wait that all the cores has finished her job
 
tBoolean isMessageAvaliable (tMPICoreId &source, tMPITag &tag, tMPIBoolean &isAvailable, tMPIStatus &status) const
 test if the message is available frm the environment this More...
 
- Public Member Functions inherited from CORE_Object
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 
virtual tString toString () const
 return the string representation of the object node More...
 

Static Public Member Functions

static CORE_UniquePointer< SelfClassNew (const std::array< tMPICoreId, N > &nCoresPerDirection, const std::array< tBoolean, N > &isPeriodicPerDirection, int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a new cart environment More...
 
static CORE_UniquePointer< SelfClassNew (const MPI_Environment &parent, const std::array< tMPICoreId, N > &nCoresPerDirection)
 create a new cart grid environment More...
 
static CORE_UniquePointer< SelfClassNew (const MPI_Environment &parent, const std::array< tMPICoreId, N > &nCoresPerDirection, const std::array< tMPIBoolean, N > &isPeriodicPerDirection, const int &canCoreIdBeChanged)
 create a new cart grid environment More...
 
static CORE_UniquePointer< SelfClassNew (const MPI_Environment &parent, const std::array< tMPICoreId, N > &nCoresPerDirection, const std::array< tBoolean, N > &isPeriodicPerDirection, const int &canCoreIdBeChanged)
 create a new cart grid environment More...
 
static CORE_UniquePointer< SelfClassNew (const MPI_CanonicalGridEnvironment< N+1 > &parent, const tUCInt &dir)
 create a hyper plan of the grids perpendicular to dir More...
 
- Static Public Member Functions inherited from MPI_GridEnvironment< N >
static CORE_UniquePointer< SelfClassNew (const std::array< tMPICoreId, N > &nCoresPerDirection, int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a new cart environment More...
 
static tMPIError ComputeGridSize (const MPI_Environment &parent, std::array< tMPICoreId, N > &coresNumber)
 get the cores number per direction if possible More...
 
static tMPIError ComputeGridSize (const tMPICoreId &nAvailableCores, std::array< tMPICoreId, N > &coresNumber)
 get the cores number per direction if possible More...
 
static tBoolean ComputeGridSize (const std::array< tReal, N > &Hs, const std::array< tInteger, N > &Ns, const tMPICoreId &nCores, std::array< tMPICoreId, N > &Gs)
 compute the grid size in order to minimize the ratio S/V where S is the surface of 1 cpu block and V the volume on 1 cpu block More...
 
- Static Public Member Functions inherited from MPI_Environment
static CORE_UniquePointer< MPI_EnvironmentNew (int argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a test class More...
 
static CORE_UniquePointer< MPI_EnvironmentNew (int argc, char *argv[])
 create a test class More...
 
static void GetCoresNumber (tMPICoreId &coresNumber)
 get the number of cores More...
 
static void GetCoresNumber (const MPI_Environment &env, tMPICoreId &coresNumber)
 get the number of cores More...
 
static void GetCoreId (tMPICoreId &id)
 get the id of the current process of common environment More...
 
static void GetCoreId (const MPI_Environment &env, tMPICoreId &id)
 get the id of the current process of common environment More...
 
static tReal GetTime ()
 get the time More...
 
static tMPIError Abort (const MPI_Environment &env, const tMPIError &errCode)
 abort the process on all cores of the environment with the eroor code More...
 
static tMPIError Abort (const tMPIError &errCode)
 abort the process on all cores with the error code More...
 
static tBoolean Synchronize (const MPI_Environment &env)
 wait that all the core of an environment has finished her job More...
 
static tBoolean Synchronize ()
 wait that all the cores has finished her job
 
static tBoolean Wait (tMPIRequest &request, tMPIStatus &status)
 wait the end the the communication by blocking More...
 
static tBoolean Wait (tMPIRequest &request)
 wait for the request is finished More...
 
static tBoolean WaitAll (const tMPICount &nRequests, tMPIRequest requests[], tMPIStatus statuses[])
 wait the end the the communication by blocking More...
 
static tBoolean WaitAll (std::valarray< tMPIRequest > &requests)
 wait for all the requests are finished More...
 
template<size_t D>
static tBoolean WaitAll (std::array< tMPIRequest, D > &requests)
 wait for all the requests are finished More...
 
static tBoolean WaitAll (const tMPICount &nRequests, tMPIRequest *requests)
 wait for all the requests are finished More...
 
static tBoolean IsFinished (tMPIRequest &request, tMPIInteger &isFinished)
 test if the requets is finished More...
 
static tBoolean IsAllFinished (std::valarray< tMPIRequest > &requests, tMPIInteger &isFinished)
 test if the requets is finished More...
 
static tBoolean IsFinished (tMPIRequest &request, tMPIStatus &status, tMPIInteger &isFinished)
 return true if the communication is finished More...
 
static tBoolean IsMessageAvaliable (const MPI_Environment &env, tMPICoreId &source, tMPITag &tag, tMPIBoolean &isAvailable, tMPIStatus &status)
 test if a message is available form any tag and any source More...
 
static tBoolean IsMessageAvaliable (const MPI_Environment &env, const tMPITag &tag, const tMPICoreId &source, tMPIBoolean &isAvailable)
 test if the message with tag from source is available More...
 
static tBoolean IsTagMessageAvaliable (const MPI_Environment &env, const tMPITag &tag, tMPICoreId &source, tMPIBoolean &isAvailable, tMPIStatus &status)
 test if the message with tag is avalaible More...
 
template<typename T >
static tBoolean GetCount (const tMPIStatus &status, tMPICount &nElements)
 get the number of element of the message More...
 
- Static Public Member Functions inherited from CORE_Object
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack
 
static void DisableMemoryStack ()
 disable the memory stack
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Protected Member Functions

 MPI_CanonicalGridEnvironment ()
 create a root environment
 
 MPI_CanonicalGridEnvironment (int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a root environment More...
 
virtual ~MPI_CanonicalGridEnvironment (void)
 destroy
 
void setFaceNeighbors (const std::array< tMPICoreId, N > &nGrids, const std::array< tMPICoreId, N > &indices, const std::array< tBoolean, N > &isPeriodic)
 set the face neighbors from directional neighbors More...
 
- Protected Member Functions inherited from MPI_GridEnvironment< N >
 MPI_GridEnvironment ()
 create a root environment
 
 MPI_GridEnvironment (int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a root environment More...
 
virtual ~MPI_GridEnvironment (void)
 destroy
 
- Protected Member Functions inherited from MPI_Environment
 MPI_Environment ()
 create a root environment
 
 MPI_Environment (int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a root environment More...
 
virtual ~MPI_Environment (void)
 destroy
 
void setIsRootEnvironment (const tBoolean &isRoot)
 set true when the environemnt created is a root one but not a common world
 
- Protected Member Functions inherited from MPI_Object
 MPI_Object (void)
 create
 
virtual ~MPI_Object (void)
 destroy
 
- Protected Member Functions inherited from CORE_Object
 CORE_Object ()
 build an instance of the object
 
virtual ~CORE_Object ()
 destroy the instance of object std

 

Detailed Description

template<tUCInt N>
class MPI_CanonicalGridEnvironment< N >

This class is a grid Environment of templated dimension N=1,2,3.

Template Parameters
N: size of the space N=1,2,3

To create a grid from a pranet environment call MPI_GridEnvironment::New(const MPI_Environment& parent,const std::array<tMPICoreId,N>& nCoresPerDirections,const std::array<tBoolean,N>& isPeriodicPerDirections,const tBoolean& canCoreIdBeChanged) .

the nCoresPerDirections array can be set to 0 and it can be built by the method GetGridsNumber(parent.getCoresNumber(),nCoresPerDirections).

To get the indices & thge coreId of the current process per direction, call the method getCoreId(std::array<tMPICoreId,N>& indices,tMPICoreId& coreId) :

To get the coordinates of a process within the grid, call the method getIndices(std::array<tMPICoreId,N>& indices

To create an hyperplan of the grid call New(onst MPI_GridEnvironment<N>& parent,const tUCInt& dir) where dir is the normal of the hyperplan

Author
Stephane Despreaux
Version
2.0

Constructor & Destructor Documentation

◆ MPI_CanonicalGridEnvironment()

template<tUCInt N>
MPI_CanonicalGridEnvironment< N >::MPI_CanonicalGridEnvironment ( int &  argc,
char *  argv[],
const tBoolean &  isOpenMPEnabled 
)
inlineprotected

create a root environment

Parameters
[in]argc: number of arguments
[in]argv: values of arguments
[in]isOpenMPEnabledenable both OpenMP & MPI

It choose MPI_THREAD_FUNNELED by default.

  • MPI_THREAD_SINGLE: Only one thread will execute.
  • MPI_THREAD_FUNNELED: The process may be multi-threaded, but only the main thread will make MPI calls.
  • MPI_THREAD_SERIALIZED: The process may be multi-threaded, and multiple threads may make MPI calls, but only one at a time: MPI calls are not made concurrently from two distinct threads.
  • MPI_THREAD_MULTIPLE: Multiple threads may call MPI, with no restrictions.

Member Function Documentation

◆ getContentsMemorySize()

template<tUCInt N>
virtual tMemSize MPI_CanonicalGridEnvironment< N >::getContentsMemorySize ( ) const
inlineoverridevirtual

return the memory size of the included associations

Returns
the memory size of the storage in bytes 1 Kb = 1024 bytes 1 Mb = 1024 Kb 1 Gb = 1024 Mb 1 Tb = 1024 Gb 1 Hb = 1024 Tb

Reimplemented from MPI_GridEnvironment< N >.

◆ getFaceNeighbor()

template<tUCInt N>
const tMPICoreId& MPI_CanonicalGridEnvironment< N >::getFaceNeighbor ( const tUCInt &  f) const
inline

get the neighbor core

Parameters
[in]findex of the face in [0,2*N[
Returns
the core id next to face

◆ getFaceNeighbors() [1/2]

template<tUCInt N>
const std::array<tMPICoreId,2*N>& MPI_CanonicalGridEnvironment< N >::getFaceNeighbors ( ) const
inline

get the face neighbor cores

Returns
the neighbors of all faces

◆ getFaceNeighbors() [2/2]

template<tUCInt N>
void MPI_CanonicalGridEnvironment< N >::getFaceNeighbors ( const tUCInt &  k,
tMPICoreId &  previousNeighbor,
tMPICoreId &  nextNeighbor 
) const
inline

get the neighbor cores

Parameters
[in]kindex of the direction in [0,N[
[out]previousNeighbor: neighbor in the direction -e_k
[out]nextNeighbor: neighbor in the direction +e_k

◆ initialize()

template<tUCInt N>
virtual void MPI_CanonicalGridEnvironment< N >::initialize ( )
inlinevirtual

initialize the environment

  • Sets the cores number & core id of the core
  • Sets the grid size , the indice of the core within the grid size
  • Sets the periodicity of the grid

Reimplemented from MPI_GridEnvironment< N >.

◆ New() [1/5]

template<tUCInt N>
static CORE_UniquePointer<SelfClass> MPI_CanonicalGridEnvironment< N >::New ( const MPI_CanonicalGridEnvironment< N+1 > &  parent,
const tUCInt &  dir 
)
inlinestatic

create a hyper plan of the grids perpendicular to dir

Parameters
[in]parent: parent grid
[in]dirnormal of the hyper plan
Returns
an hyperplan environment

◆ New() [2/5]

template<tUCInt N>
static CORE_UniquePointer<SelfClass> MPI_CanonicalGridEnvironment< N >::New ( const MPI_Environment parent,
const std::array< tMPICoreId, N > &  nCoresPerDirection 
)
inlinestatic

create a new cart grid environment

Parameters
[in]parent: parent environment
[in]nCoresPerDirection: an array of size nDirections with the number of cores per direction
Returns
a new grid environment

◆ New() [3/5]

template<tUCInt N>
static CORE_UniquePointer<SelfClass> MPI_CanonicalGridEnvironment< N >::New ( const MPI_Environment parent,
const std::array< tMPICoreId, N > &  nCoresPerDirection,
const std::array< tBoolean, N > &  isPeriodicPerDirection,
const int &  canCoreIdBeChanged 
)
inlinestatic

create a new cart grid environment

Parameters
[in]parent: parent environment
[in]nCoresPerDirection: an array of size nDirections with the number of cores per direction
[in]isPeriodicPerDirection: an array of size nDirections to indicates the peridicity of direction
[in]canCoreIdBeChanged: true to modify the core id
Returns
a new grid environment

◆ New() [4/5]

template<tUCInt N>
static CORE_UniquePointer<SelfClass> MPI_CanonicalGridEnvironment< N >::New ( const MPI_Environment parent,
const std::array< tMPICoreId, N > &  nCoresPerDirection,
const std::array< tMPIBoolean, N > &  isPeriodicPerDirection,
const int &  canCoreIdBeChanged 
)
inlinestatic

create a new cart grid environment

Parameters
[in]parent: parent environment
[in]nCoresPerDirection: an array of size nDirections with the number of cores per direction
[in]isPeriodicPerDirection: an array of size nDirections to indicates the peridicity of direction
[in]canCoreIdBeChanged: true to modify the core id
Returns
a new grid environment

◆ New() [5/5]

template<tUCInt N>
static CORE_UniquePointer<SelfClass> MPI_CanonicalGridEnvironment< N >::New ( const std::array< tMPICoreId, N > &  nCoresPerDirection,
const std::array< tBoolean, N > &  isPeriodicPerDirection,
int &  argc,
char *  argv[],
const tBoolean &  isOpenMPEnabled 
)
inlinestatic

create a new cart environment

Parameters
[in]nCoresPerDirection: an array of size nDirections with the number of cores per direction
[in]isPeriodicPerDirection: periodicity of the grid
[in]argc: number of arguments
[in]argv: values of arguments
[in]isOpenMPEnabledenable both OpenMP & MPI
Returns
a new grid environment

◆ setFaceNeighbors()

template<tUCInt N>
void MPI_CanonicalGridEnvironment< N >::setFaceNeighbors ( const std::array< tMPICoreId, N > &  nGrids,
const std::array< tMPICoreId, N > &  indices,
const std::array< tBoolean, N > &  isPeriodic 
)
inlineprotected

set the face neighbors from directional neighbors

Parameters
[in]dirNeighborsneighbor per dierction
[out]faceNeighborsneighbor core per face Buils the faceNeighbors by taking the neighbor core within the dirNeighbors

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