C++ mpi module for stochmagnet_main Package
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
MPI_Environment Class Reference

This class is a Environment class to define MPI world. More...

#include <MPI_Environment.h>

Inheritance diagram for MPI_Environment:
Inheritance graph
[legend]
Collaboration diagram for MPI_Environment:
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...
 
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< 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_Environment ()
 create a root environment
 
 MPI_Environment (int &argc, char *argv[], const tBoolean &isOpenMPEnabled)
 create a root environment More...
 
virtual ~MPI_Environment (void)
 destroy
 
virtual void initialize ()
 initialize the environment Sets the cores number and the core id of the environment
 
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

This class is a Environment class to define MPI world.

This class contained

All the cores is defined in this root environment

A program can be stopped by the method MPI_Environment::abort(const tMPIError& err) method.

An environment may be splited in others environment by the method:New(const MPI_Environment& parent,const int& subEnvId,const int& coreId) where subEnvId is the id of the environment where the core is and coreId the new id of the core within the environment defined by subEnvId. Note that to set the core to be the process 0 teh subEnvId must be -1. The new environment call MPI_Comm_split() & MPI_Comm_free() methods.

Author
Stephane Despreaux
Version
2.0

Constructor & Destructor Documentation

◆ MPI_Environment()

MPI_Environment::MPI_Environment ( 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

◆ Abort() [1/2]

static tMPIError MPI_Environment::Abort ( const MPI_Environment env,
const tMPIError &  errCode 
)
inlinestatic

abort the process on all cores of the environment with the eroor code

Parameters
[in]env: mpi environment in which the operation take place
[in]errCodeerror code
Returns
a MPI code

◆ Abort() [2/2]

static tMPIError MPI_Environment::Abort ( const tMPIError &  errCode)
inlinestatic

abort the process on all cores with the error code

Parameters
[in]errCodeerror code
Returns
a MPI code

◆ abort()

tMPIError MPI_Environment::abort ( const tMPIError &  errCode) const
inline

abort the process on all cores with the error code

Parameters
[in]errCodeerror code
Returns
a MPI code

◆ getContentsMemorySize()

virtual tMemSize MPI_Environment::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 CORE_Object.

Reimplemented in MPI_GridEnvironment< N >, MPI_DirectionalGridEnvironment< N, D >, MPI_DirectionalGridEnvironment< N, 1 >, and MPI_CanonicalGridEnvironment< N >.

◆ getCoreId()

const tMPICoreId& MPI_Environment::getCoreId ( ) const
inline

get the id of the current process of this environment

Parameters
[out]idthe id of the current core

◆ GetCoreId() [1/2]

static void MPI_Environment::GetCoreId ( const MPI_Environment env,
tMPICoreId &  id 
)
inlinestatic

get the id of the current process of common environment

Parameters
[in]env: MPI environment to get the attribute
[out]idthe id of the current core

◆ GetCoreId() [2/2]

static void MPI_Environment::GetCoreId ( tMPICoreId &  id)
inlinestatic

get the id of the current process of common environment

Parameters
[out]idthe id of the current core

◆ getCoresNumber()

const tMPICoreId& MPI_Environment::getCoresNumber ( ) const
inline

get the number of cores of this environment of common environment

Returns
number of cores

◆ GetCoresNumber() [1/2]

static void MPI_Environment::GetCoresNumber ( const MPI_Environment env,
tMPICoreId &  coresNumber 
)
inlinestatic

get the number of cores

Parameters
[in]env: MPI environment to get the attribute
[out]coresNumber: number of cores

◆ GetCoresNumber() [2/2]

static void MPI_Environment::GetCoresNumber ( tMPICoreId &  coresNumber)
inlinestatic

get the number of cores

Parameters
[out]coresNumber: number of cores

◆ GetCount()

template<typename T >
static tBoolean MPI_Environment::GetCount ( const tMPIStatus &  status,
tMPICount &  nElements 
)
inlinestatic

get the number of element of the message

Parameters
[in]status:status of the message
[out]nElements: number of elemet of type T

◆ GetTime()

static tReal MPI_Environment::GetTime ( )
inlinestatic

get the time

Returns
the time in seconds

◆ IsAllFinished()

static tBoolean MPI_Environment::IsAllFinished ( std::valarray< tMPIRequest > &  requests,
tMPIInteger &  isFinished 
)
inlinestatic

test if the requets is finished

Parameters
[in,out]requests: requests of communication
[out]isFinished: set it to true if all the requests are finished
Returns
true if the requests are finished

◆ IsFinished() [1/2]

static tBoolean MPI_Environment::IsFinished ( tMPIRequest &  request,
tMPIInteger &  isFinished 
)
inlinestatic

test if the requets is finished

Parameters
[in,out]request: request of communication
[out]isFinished: set it to true if the request is finished
Returns
true if the request is finished

◆ IsFinished() [2/2]

static tBoolean MPI_Environment::IsFinished ( tMPIRequest &  request,
tMPIStatus &  status,
tMPIInteger &  isFinished 
)
inlinestatic

return true if the communication is finished

Parameters
[in]request: request of the communication
[out]statusstatus of the communication
[out]isFinished1: if the communication is finished

◆ IsMessageAvaliable() [1/2]

static tBoolean MPI_Environment::IsMessageAvaliable ( const MPI_Environment env,
const tMPITag &  tag,
const tMPICoreId &  source,
tMPIBoolean &  isAvailable 
)
inlinestatic

test if the message with tag from source is available

Parameters
[in]envenvironment of the message
[in]tag: tag of the message to test
[in]source: source from which the message must be emit
[in,out]isAvailable: flag (0,1) to set if the mesage is available
Returns
true if the message is avalaible

◆ IsMessageAvaliable() [2/2]

static tBoolean MPI_Environment::IsMessageAvaliable ( const MPI_Environment env,
tMPICoreId &  source,
tMPITag &  tag,
tMPIBoolean &  isAvailable,
tMPIStatus &  status 
)
inlinestatic

test if a message is available form any tag and any source

Parameters
[in]envenvironment of the message
[out]source: source from which the message must be emit
[out]tag: tag of the message to test
[out]isAvailable: flag (0,1) to set if the mesage is available
[out]status:status of the message
Returns
true if the message is avalaible

◆ isMessageAvaliable()

tBoolean MPI_Environment::isMessageAvaliable ( tMPICoreId &  source,
tMPITag &  tag,
tMPIBoolean &  isAvailable,
tMPIStatus &  status 
) const
inline

test if the message is available frm the environment this

Parameters
[out]source: source from which the message with tag is emited
[out]tag: tag of the message to receive
[in,out]isAvailable: flag (0,1) to set if the mesage is available
[out]status:status of the message
Returns
true if the message is avaiable

◆ IsTagMessageAvaliable()

static tBoolean MPI_Environment::IsTagMessageAvaliable ( const MPI_Environment env,
const tMPITag &  tag,
tMPICoreId &  source,
tMPIBoolean &  isAvailable,
tMPIStatus &  status 
)
inlinestatic

test if the message with tag is avalaible

Parameters
[in]envenvironment of the message
[in]tag: tag of the message to test
[out]source: source from which the message with tag is emited
[in,out]isAvailable: flag (0,1) to set if the mesage is available
[out]status:status of the message
Returns
true if the message is avalaible

◆ New() [1/2]

static CORE_UniquePointer<MPI_Environment> MPI_Environment::New ( int  argc,
char *  argv[] 
)
inlinestatic

create a test class

Parameters
[in]argc: number of arguments
[in]argv: values of arguments
Returns
a new instance of the class

◆ New() [2/2]

static CORE_UniquePointer<MPI_Environment> MPI_Environment::New ( int  argc,
char *  argv[],
const tBoolean &  isOpenMPEnabled 
)
inlinestatic

create a test class

Parameters
[in]argc: number of arguments
[in]argv: values of arguments
[in]isOpenMPEnabledenable both OpenMP & MPI
Returns
a new instance of the class

◆ Synchronize()

static tBoolean MPI_Environment::Synchronize ( const MPI_Environment env)
inlinestatic

wait that all the core of an environment has finished her job

Parameters
[in]envenvironment of the cores

◆ Wait() [1/2]

static tBoolean MPI_Environment::Wait ( tMPIRequest &  request)
inlinestatic

wait for the request is finished

Returns
true if the wait method has suceeded

◆ Wait() [2/2]

static tBoolean MPI_Environment::Wait ( tMPIRequest &  request,
tMPIStatus &  status 
)
inlinestatic

wait the end the the communication by blocking

Parameters
[in,out]requestrequest of the message
[in,out]statusstatus of the message

◆ WaitAll() [1/4]

static tBoolean MPI_Environment::WaitAll ( const tMPICount &  nRequests,
tMPIRequest *  requests 
)
inlinestatic

wait for all the requests are finished

Parameters
[in]nRequests: number of requests
[in,out]requestsrequests of communications
Returns
true if the wait method has suceeded

◆ WaitAll() [2/4]

static tBoolean MPI_Environment::WaitAll ( const tMPICount &  nRequests,
tMPIRequest  requests[],
tMPIStatus  statuses[] 
)
inlinestatic

wait the end the the communication by blocking

Parameters
[in]nRequests: number of requests to test
[in,out]requestsrequests of communications
[in,out]statusesstatuses of communications

◆ WaitAll() [3/4]

template<size_t D>
static tBoolean MPI_Environment::WaitAll ( std::array< tMPIRequest, D > &  requests)
inlinestatic

wait for all the requests are finished

Template Parameters
D: number of requests
Parameters
[in,out]requestsrequests of communications
Returns
true if the wait method has suceeded

◆ WaitAll() [4/4]

static tBoolean MPI_Environment::WaitAll ( std::valarray< tMPIRequest > &  requests)
inlinestatic

wait for all the requests are finished

Parameters
[in,out]requestsrequests of communications
Returns
true if the wait method has suceeded

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