Back to index

salome-med  6.5.0
MPIProcessorGroup.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __MPIPROCESSORGROUP_HXX__
00021 #define __MPIPROCESSORGROUP_HXX__
00022 
00023 #include "ProcessorGroup.hxx"
00024 
00025 #include <set>
00026 #include <mpi.h>
00027 
00028 namespace ParaMEDMEM
00029 {
00030   class CommInterface;
00031 
00032   class MPIProcessorGroup : public ProcessorGroup
00033   {
00034   public:
00035     MPIProcessorGroup(const CommInterface& interface);
00036     MPIProcessorGroup(const CommInterface& interface, std::set<int> proc_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD);
00037     MPIProcessorGroup (const ProcessorGroup& proc_group, std::set<int> proc_ids);
00038     MPIProcessorGroup(const CommInterface& interface,int pstart, int pend, const MPI_Comm& world_comm=MPI_COMM_WORLD);
00039     MPIProcessorGroup(const MPIProcessorGroup& other);
00040     virtual ~MPIProcessorGroup();
00041     virtual ProcessorGroup *deepCpy() const;
00042     virtual ProcessorGroup* fuse (const ProcessorGroup&) const;
00043     void intersect (ProcessorGroup&) { }
00044     int myRank() const;
00045     bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED); }
00046     int translateRank(const ProcessorGroup* group, int rank) const;
00047     const MPI_Comm* getComm() const { return &_comm; }
00048     ProcessorGroup* createComplementProcGroup() const;
00049     ProcessorGroup* createProcGroup() const;
00050     MPI_Comm getWorldComm() { return _world_comm; }
00051   private:
00052     void updateMPISpecificAttributes();
00053   private:
00054     const MPI_Comm _world_comm;
00055     MPI_Group _group;
00056     MPI_Comm _comm;
00057   };
00058 }
00059 
00060 #endif