00001 // Copyright (C) 2007-2011 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 virtual ~MPIProcessorGroup(); 00040 virtual ProcessorGroup* fuse (const ProcessorGroup&) const; 00041 void intersect (ProcessorGroup&) { } 00042 int myRank() const; 00043 bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED); } 00044 int translateRank(const ProcessorGroup* group, int rank) const; 00045 const MPI_Comm* getComm() const { return &_comm; } 00046 ProcessorGroup* createComplementProcGroup() const; 00047 ProcessorGroup* createProcGroup() const; 00048 MPI_Comm getWorldComm() { return _world_comm; } 00049 private: 00050 const MPI_Comm _world_comm; 00051 MPI_Group _group; 00052 MPI_Comm _comm; 00053 }; 00054 } 00055 00056 #endif