1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __PROCESSORGROUP_HXX__
21 #define __PROCESSORGROUP_HXX__
23 #include "CommInterface.hxx"
30 * Abstract class defining a group of processors (computation nodes) in a parallel run of a code.
32 * See the non-abstract child \ref MPIProcessorGroup-det "MPIProcessorGroup"
38 ProcessorGroup(const CommInterface& interface):_comm_interface(interface) { }
39 ProcessorGroup(const CommInterface& interface, std::set<int> proc_ids):
40 _comm_interface(interface),_proc_ids(proc_ids) { }
41 ProcessorGroup (const ProcessorGroup& proc_group, std::set<int> proc_ids):
42 _comm_interface(proc_group.getCommInterface()),_proc_ids(proc_ids) { }
43 ProcessorGroup (const ProcessorGroup& other):
44 _comm_interface(other.getCommInterface()),_proc_ids(other._proc_ids) { }
45 ProcessorGroup (const CommInterface& interface, int start, int end);
46 virtual ~ProcessorGroup() { }
47 virtual ProcessorGroup *deepCopy() const = 0;
48 virtual ProcessorGroup* fuse (const ProcessorGroup&) const = 0;
49 virtual void intersect (ProcessorGroup&) = 0;
50 bool contains(int rank) const { return _proc_ids.find(rank)!=_proc_ids.end(); }
51 virtual bool containsMyRank() const = 0;
52 int size() const { return (int)_proc_ids.size(); }
53 const CommInterface& getCommInterface()const { return _comm_interface; }
54 virtual int myRank() const = 0;
55 virtual int translateRank(const ProcessorGroup*, int) const = 0;
56 virtual ProcessorGroup* createComplementProcGroup() const = 0;
57 virtual ProcessorGroup* createProcGroup() const = 0;
58 virtual const std::set<int>& getProcIDs()const { return _proc_ids; }
60 const CommInterface _comm_interface;
61 std::set<int> _proc_ids;