Feel++ 0.111.0-preview.14
Finite Element Embedded Library in C++
Feel::WorldComm Class Reference

Provides interface to MPI Communicators. More...

+ Inheritance diagram for Feel::WorldComm:
+ Collaboration diagram for Feel::WorldComm:

Public Types

typedef boost::mpi::communicator communicator_type
 underlying MPI communicator type
 
typedef std::shared_ptr< WorldComm > self_ptrtype
 std::shared_ptr type
 
typedef WorldComm self_type
 self type
 
using worldcomm_ptr_t = std::shared_ptr< WorldComm >
 
using worldcomm_t = WorldComm
 
using worldscomm_ptr_t = std::vector< worldcomm_ptr_t >
 

Public Member Functions

std::vector< int > const & activityOnWorld () const
 Returns the vector of activity in this world.
 
void applyActivityOnlyOn (int _localColor) const
 
worldcomm_ptr_t clone () const
 
communicator_type const & comm () const
 Returns the local WorldComm,. More...
 
communicator_type const & globalComm () const
 Returns the current WorldComm.
 
rank_type globalRank () const
 Returns the rank in the global WorldComm.
 
rank_type globalSize () const
 
communicator_type const & godComm () const
 
rank_type godRank () const
 Returns the rank in the God WorldComm.
 
rank_type godSize () const
 
boost::tuple< bool, std::set< int > > hasMultiLocalActivity () const
 
bool hasSubWorlds (int n) const
 
void init (int color=0, bool colormap=false)
 
bool isActive () const
 Returns true if current worldcomm is active in God worldcomm.
 
bool isActive (int rank) const
 Returns true if worldcomm rank is active in God worldcomm.
 
bool isMasterRank () const
 Returns true if process has master rank, false otherwise.
 
rank_type localColorToGlobalRank (int _color, int _localRank) const
 
communicator_type const & localComm () const
 Returns the local WorldComm.
 
rank_type localRank () const
 Returns the rank in the local WorldComm.
 
rank_type localSize () const
 
std::vector< int > const & mapColorWorld () const
 the colormap of the worldcomm by default the colormap set all processes to the same color 0 More...
 
int mapColorWorld (int k) const
 the k-th entry of the colormap More...
 
std::vector< rank_type > const & mapGlobalRankToGodRank () const
 vector that translates the global rank ids to god rank ids More...
 
rank_type mapGlobalRankToGodRank (int k) const
 
std::vector< rank_type > const & mapLocalRankToGlobalRank () const
 vector that translates the local rank ids to global rank ids More...
 
rank_type mapLocalRankToGlobalRank (int k) const
 
rank_type masterRank () const
 get the master rank The master rank is set to be the process with the minimal rank in the worldcomm More...
 
worldcomm_t & masterWorld (int n)
 
int numberOfSubWorlds () const
 
worldcomm_ptr_t operator+ (WorldComm const &_worldComm) const
 
WorldComm & operator= (WorldComm const &wc)
 copy a worldcomm
 
bool operator== (WorldComm const &wc) const
 comparison of worldcomm
 
void print (std::string const &text, bool sync=false, bool print_to_cout=false, bool flush=false)
 print text on the worldcomm More...
 
void registerSubWorlds (int n) const
 register sub worlds associated to worldmap
 
void registerSubWorldsGroupBySubspace (int n)
 
communicator_type const & selfComm () const
 
void setColorMap (std::vector< int > const &colormap)
 
void setIsActive (std::vector< int > const &_isActive) const
 
void showMe (std::ostream &__out=std::cout) const
 prints information on out on the WorldComm
 
std::tuple< int, worldcomm_ptr_t, worldcomm_ptr_t > split (int n) const
 split the worldcomm into n sub worldcomm More...
 
worldcomm_ptr_t subWorld (int n)
 
worldcomm_ptr_t subWorld (int n) const
 
worldcomm_t & subWorldComm ()
 get the sub worldcomm associated to color globalRank() in the colormap More...
 
worldcomm_t const & subWorldComm () const
 get the sub worldcomm associated to color globalRank() in the colormap More...
 
worldcomm_ptr_t subWorldComm (int color) const
 get the sub worldcomm shared_ptr associated to color color in the colormap More...
 
worldcomm_ptr_t subWorldComm (int color, std::vector< int > const &colormap)
 get the sub worldcomm shared_ptr associated to color color in the colormap More...
 
worldcomm_t & subWorldComm (std::vector< int > const &colormap)
 get the sub worldcomm shared_ptr associated to color globalRank() in the colormap More...
 
worldcomm_ptr_t subWorldCommPtr ()
 get the sub worldcomm shared_ptr associated to color globalRank() in the colormap More...
 
WorldComm & subWorldCommSeq ()
 Returns the sequential sub worldcomm.
 
WorldComm const & subWorldCommSeq () const
 Returns the sequential sub worldcomm.
 
worldcomm_ptr_t & subWorldCommSeqPtr ()
 Returns the sequential sub worldcomm.
 
worldcomm_ptr_t const & subWorldCommSeqPtr () const
 Returns the sequential sub worldcomm.
 
int subWorldId (int n) const
 
worldscomm_ptr_t & subWorlds (int n)
 
worldscomm_ptr_t const & subWorlds (int n) const
 
worldscomm_ptr_t & subWorldsGroupBySubspace (int n)
 
 WorldComm ()
 Default constructor.
 
 WorldComm (communicator_type const &_globalComm, communicator_type const &_godComm, int _localColor, int localRank, std::vector< int > const &isActive)
 
 WorldComm (communicator_type const &_globalComm, communicator_type const &_localComm, communicator_type const &_godComm, int _localColor, std::vector< int > const &isActive)
 
 WorldComm (communicator_type const &_globalComm, int _color, bool _isActive)
 
 WorldComm (int _color)
 build a sub WorldComm from a _color a colormap is set based on the globalRank() of the processes More...
 
 WorldComm (int _colorLocal, int localRank, int _colorGlobal, int globalRank, communicator_type const &_godComm, bool _isActive, bool _doInitActiveMap=true)
 
 WorldComm (std::vector< int > const &_colorWorld)
 Creates a sub WorldComm from a set of colors _colorWorld. More...
 
 WorldComm (std::vector< int > const &_colorWorld, int localRank, communicator_type const &_globalComm=communicator_type(), communicator_type const &_godComm=communicator_type())
 
 WorldComm (super const &)
 constructor from an boost::mpi::communicator
 
 WorldComm (WorldComm const &_wc)
 

Static Public Member Functions

static self_ptrtype New ()
 
static self_ptrtype New (super const &s)
 

Detailed Description

Provides interface to MPI Communicators.

Todo:
define global, local and god WorldComm
auto world = Environment::worldComm();
std::vector<int> mapColorWorld;
for( int rank : irange( world.size() ) )
mapColorWorld.push_back( rank % 2 );
// Creates a WorldComm where we have split the processes into two sets
WorldComm worldColored( mapColorWorld );
static WorldComm & worldComm()
return the worldcomm (static)
Definition: environment.hpp:309
WorldComm()
Default constructor.
Definition: worldcomm.cpp:41
std::vector< int > const & mapColorWorld() const
the colormap of the worldcomm by default the colormap set all processes to the same color 0
Definition: worldcomm.hpp:210
auto rank(C const &c)
Definition: rank.hpp:37

Constructor & Destructor Documentation

◆ WorldComm() [1/2]

Feel::WorldComm::WorldComm ( int  _color)
explicit

build a sub WorldComm from a _color a colormap is set based on the globalRank() of the processes

Warning
do not use directly this WorldComm to get the sub WorldComm, rather use member function subWorldComm( _color ) on this WorldComm
auto subwc = WorldComm( 1 ).subWorldComm( 1 );
Parameters
_colorcolor to use to generate the WorldComm:

◆ WorldComm() [2/2]

Feel::WorldComm::WorldComm ( std::vector< int > const &  _colorWorld)

Creates a sub WorldComm from a set of colors _colorWorld.

Warning
do not use directly this WorldComm to get the sub WorldComm, rather use member function subWorldComm( _color ) on this WorldComm
std::vector<int> cmap( Environment::worldComm().size(), 1 );
cmap[0] = 0; // set a different color for process 0
auto subwc = WorldComm( cmap ).subWorldComm( 1 );

Member Function Documentation

◆ comm()

communicator_type const & Feel::WorldComm::comm ( ) const

Returns the local WorldComm,.

See also
localComm

◆ mapColorWorld() [1/2]

std::vector< int > const & Feel::WorldComm::mapColorWorld ( ) const

the colormap of the worldcomm by default the colormap set all processes to the same color 0

Returns
the colormap

Referenced by operator==(), showMe(), split(), subWorldComm(), and subWorldCommPtr().

◆ mapColorWorld() [2/2]

int Feel::WorldComm::mapColorWorld ( int  k) const

the k-th entry of the colormap

Parameters
kthe index of the process
Returns
the color of the process in the colormap

◆ mapGlobalRankToGodRank()

std::vector< rank_type > const & Feel::WorldComm::mapGlobalRankToGodRank ( ) const

vector that translates the global rank ids to god rank ids

Returns
the translation table

Referenced by operator==(), showMe(), and subWorldComm().

◆ mapLocalRankToGlobalRank()

std::vector< rank_type > const & Feel::WorldComm::mapLocalRankToGlobalRank ( ) const

vector that translates the local rank ids to global rank ids

Returns
the translation table

Referenced by operator==(), showMe(), and subWorldComm().

◆ masterRank()

rank_type Feel::WorldComm::masterRank ( ) const

get the master rank The master rank is set to be the process with the minimal rank in the worldcomm

Returns
the master rank id in the worldcomm

Referenced by Feel::PsLogger::log(), operator==(), and showMe().

◆ print()

void Feel::WorldComm::print ( std::string const &  text,
bool  sync = false,
bool  print_to_cout = false,
bool  flush = false 
)

print text on the worldcomm

Parameters
texttext to print
syncwhether to synchronize the worldcomm before printing and after
print_to_coutprint to standard output
flushflush log files

◆ split()

std::tuple< int, worldcomm_ptr_t, worldcomm_ptr_t > Feel::WorldComm::split ( int  n) const

split the worldcomm into n sub worldcomm

Parameters
nnumber of sub worldcomm
Returns
tuple containing the current color and current worldcomm as well as the global worldcomm

References mapColorWorld(), and Feel::rank().

◆ subWorldComm() [1/5]

worldcomm_t & Feel::WorldComm::subWorldComm ( )

get the sub worldcomm associated to color globalRank() in the colormap

Returns
the worldcomm with local and global communicator being the same

References globalRank(), mapColorWorld(), and subWorldComm().

Referenced by subWorldComm(), and subWorldCommPtr().

◆ subWorldComm() [2/5]

worldcomm_t const & Feel::WorldComm::subWorldComm ( ) const

get the sub worldcomm associated to color globalRank() in the colormap

Returns
the worldcomm with local and global communicator being the same

References globalRank(), mapColorWorld(), and subWorldComm().

◆ subWorldComm() [3/5]

worldcomm_ptr_t Feel::WorldComm::subWorldComm ( int  color) const

get the sub worldcomm shared_ptr associated to color color in the colormap

Parameters
colorcolor (in the worldcomm colormap) to be used to generate the worldcomm
Returns
the worldcomm shared_ptr with local and global communicator being the same

References globalRank(), isActive(), localComm(), mapColorWorld(), mapGlobalRankToGodRank(), and mapLocalRankToGlobalRank().

◆ subWorldComm() [4/5]

worldcomm_ptr_t Feel::WorldComm::subWorldComm ( int  color,
std::vector< int > const &  colormap 
)

get the sub worldcomm shared_ptr associated to color color in the colormap

Parameters
colorcolor in the colormap to be used to generate the worldcomm
colormapcolormap to be set in worlcomm to generate the sub worldcomm
Returns
the worldcomm shared_ptr with local and global communicator being the same

References subWorldComm().

◆ subWorldComm() [5/5]

worldcomm_t & Feel::WorldComm::subWorldComm ( std::vector< int > const &  colormap)

get the sub worldcomm shared_ptr associated to color globalRank() in the colormap

Parameters
colormapcolormap to be set in worlcomm to generate the sub worldcomm
Returns
the worldcomm shared_ptr with local and global communicator being the same

References subWorldComm().

◆ subWorldCommPtr()

worldcomm_ptr_t Feel::WorldComm::subWorldCommPtr ( )

get the sub worldcomm shared_ptr associated to color globalRank() in the colormap

Returns
the worldcomm shared_ptr with local and global communicator being the same

References globalRank(), mapColorWorld(), and subWorldComm().