Back to index

salome-med  6.5.0
Functions
Processor Groups

Functions

 ParaMEDMEM::MPIProcessorGroup::MPIProcessorGroup (const CommInterface &interface)
 Creates a processor group that is based on all the MPI_COMM_WORLD processor.This routine must be called by all processors in MPI_COMM_WORLD.
 ParaMEDMEM::MPIProcessorGroup::MPIProcessorGroup (const CommInterface &interface, std::set< int > proc_ids, const MPI_Comm &world_comm=MPI_COMM_WORLD)
 Creates a processor group that is based on the processors included in proc_ids.
void ParaMEDMEM::MPIProcessorGroup::updateMPISpecificAttributes ()
 ParaMEDMEM::MPIProcessorGroup::MPIProcessorGroup (const CommInterface &interface, int pstart, int pend, const MPI_Comm &world_comm=MPI_COMM_WORLD)
 Creates a processor group that is based on the processors between pstart and pend.
int ParaMEDMEM::MPIProcessorGroup::translateRank (const ProcessorGroup *group, int rank) const
 Translation of the rank id between two processor groups.
ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::createComplementProcGroup () const
 Creates a processor group that is the complement of the current group inside MPI_COMM_WORLD.
virtual ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::deepCpy () const
virtual ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::fuse (const ProcessorGroup &) const
 Adding processors of group group to local group.
int ParaMEDMEM::MPIProcessorGroup::myRank () const

Detailed Description

Overview

The MPIProcessorGroup class is used to set up processor groups that help to define the MPI topology of the couplings. They can be set up in various ways, the most common being the use of the MPIProcessorGroup(Comminterface, int pfirst, int plast) constructor.

The following code excerpt creates two processor groups on respectively 3 and 2 processors.

 int main()
 {
 MPI_Init(&argc,&argv);
 CommInterface comm_interface;
 MPIProcessorGroup codeA_group(comm_interface, 0, 2);
 MPIProcessorGroup codeB_group(comm_interface, 3, 4);
   
 ...
 }

Function Documentation

ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::createComplementProcGroup ( ) const [virtual]

Creates a processor group that is the complement of the current group inside MPI_COMM_WORLD.

Returns:
pointer to the new ProcessorGroup structure.

Implements ParaMEDMEM::ProcessorGroup.

Definition at line 201 of file MPIProcessorGroup.cxx.

  {
    set <int> procs;
    int world_size=_comm_interface.worldSize();
    for (int i=0; i<world_size; i++)
      procs.insert(i);
    for (set<int>::const_iterator iter=_proc_ids.begin(); iter!= _proc_ids.end(); iter++)
      procs.erase(*iter);
    
    return new MPIProcessorGroup(_comm_interface, procs, _world_comm);
    
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::deepCpy ( ) const [virtual]

Implements ParaMEDMEM::ProcessorGroup.

Definition at line 214 of file MPIProcessorGroup.cxx.

  {
    return new MPIProcessorGroup(*this);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ProcessorGroup * ParaMEDMEM::MPIProcessorGroup::fuse ( const ProcessorGroup group) const [virtual]

Adding processors of group group to local group.

Parameters:
groupgroup that is to be fused with current group
Returns:
new group formed by the fusion of local group and group.

Implements ParaMEDMEM::ProcessorGroup.

Definition at line 223 of file MPIProcessorGroup.cxx.

  {
    set <int> procs = _proc_ids;
    const set<int>& distant_proc_ids = group.getProcIDs();
    for (set<int>::const_iterator iter=distant_proc_ids.begin(); iter!=distant_proc_ids.end(); iter++)
      {
        procs.insert(*iter);
      }
    return new MPIProcessorGroup(_comm_interface, procs, _world_comm);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Creates a processor group that is based on all the MPI_COMM_WORLD processor.This routine must be called by all processors in MPI_COMM_WORLD.

Parameters:
interfaceCommInterface object giving access to the MPI communication layer

Definition at line 68 of file MPIProcessorGroup.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

ParaMEDMEM::MPIProcessorGroup::MPIProcessorGroup ( const CommInterface interface,
std::set< int >  proc_ids,
const MPI_Comm &  world_comm = MPI_COMM_WORLD 
)

Creates a processor group that is based on the processors included in proc_ids.

This routine must be called by all processors in MPI_COMM_WORLD.

Parameters:
interfaceCommInterface object giving access to the MPI communication layer
proc_idsset of ids that are to be integrated in the group. The ids number are to be understood in terms of MPI_COMM_WORLD ranks.

Definition at line 89 of file MPIProcessorGroup.cxx.

Here is the call graph for this function:

ParaMEDMEM::MPIProcessorGroup::MPIProcessorGroup ( const CommInterface comm_interface,
int  pstart,
int  pend,
const MPI_Comm &  world_comm = MPI_COMM_WORLD 
)

Creates a processor group that is based on the processors between pstart and pend.

This routine must be called by all processors in MPI_COMM_WORLD.

Parameters:
comm_interfaceCommInterface object giving access to the MPI communication layer
pstartid in MPI_COMM_WORLD of the first processor in the group
pendid in MPI_COMM_WORLD of the last processor in the group

Definition at line 129 of file MPIProcessorGroup.cxx.

                                                                                                                            : ProcessorGroup(comm_interface,pstart,pend),_world_comm(world_comm)
  {
    //Creation of a communicator 
    MPI_Group group_world;
  
    int size_world;
    _comm_interface.commSize(_world_comm,&size_world);
    int rank_world;
    _comm_interface.commRank(_world_comm,&rank_world);
    _comm_interface.commGroup(_world_comm, &group_world);

    if (pend>size_world-1 || pend <pstart || pstart<0)
      throw INTERP_KERNEL::Exception("invalid argument in MPIProcessorGroup constructor (comm,pfirst,plast)");
    int nprocs=pend-pstart+1;
    int* ranks=new int[nprocs];
    for (int i=pstart; i<=pend;i++)
      {
        ranks[i-pstart]=i;
      }

    _comm_interface.groupIncl(group_world, nprocs, ranks, &_group);
  
    _comm_interface.commCreate(_world_comm, _group, &_comm);
    delete[] ranks;
  }

Here is the call graph for this function:

int ParaMEDMEM::MPIProcessorGroup::myRank ( ) const [virtual]

Implements ParaMEDMEM::ProcessorGroup.

Definition at line 234 of file MPIProcessorGroup.cxx.

  { 
    int rank;
    MPI_Comm_rank(_comm,&rank);
    return rank;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

int ParaMEDMEM::MPIProcessorGroup::translateRank ( const ProcessorGroup group,
int  rank 
) const [virtual]

Translation of the rank id between two processor groups.

This method translates rank rank on the current processor group to the rank on group pointed by group.

Parameters:
groupgroup from which the rank is expected
rankrank on group group of the processor which is to be translated
Returns:
rank on local group

Implements ParaMEDMEM::ProcessorGroup.

Definition at line 189 of file MPIProcessorGroup.cxx.

  {
    const MPIProcessorGroup* targetgroup=dynamic_cast<const MPIProcessorGroup*>(group);
    int local_rank;
    MPI_Group_translate_ranks(targetgroup->_group, 1, &rank, _group, &local_rank);
    return local_rank;
  }

Here is the caller graph for this function:

Definition at line 96 of file MPIProcessorGroup.cxx.

  {
    //Creation of a communicator 
    MPI_Group group_world;
  
    int size_world;
    _comm_interface.commSize(_world_comm,&size_world);
    int rank_world;
    _comm_interface.commRank(_world_comm,&rank_world);
    _comm_interface.commGroup(_world_comm, &group_world);

    int* ranks=new int[_proc_ids.size()];
   
    // copying proc_ids in ranks
    copy<set<int>::const_iterator,int*> (_proc_ids.begin(), _proc_ids.end(), ranks);
    for (int i=0; i< (int)_proc_ids.size();i++)
      if (ranks[i]>size_world-1)
        throw INTERP_KERNEL::Exception("invalid rank in set<int> argument of MPIProcessorGroup constructor");
      
    _comm_interface.groupIncl(group_world, _proc_ids.size(), ranks, &_group);
  
    _comm_interface.commCreate(_world_comm, _group, &_comm);
    delete[] ranks;
  }

Here is the call graph for this function:

Here is the caller graph for this function: