4d66c5fefaa8a8ae735a394b63eae52226516eea
[ctsim.git] / include / mpiworld.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          mpiworld.h
5 **   Purpose:       MPIWorld classes
6 **   Programmer:    Kevin Rosenberg
7 **   Date Started:  June 6, 2000
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2001 Kevin Rosenberg
11 **
12 **  $Id$
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 #include <mpi++.h>
29 #include <vector.h>
30 #include <string>
31
32 class MPIWorld
33 {
34  public:
35     MPIWorld (int& argc, char* const *& argv);
36
37     void setTotalWorkUnits (int totalUnits);
38
39     int getRank (void) const
40         { return m_myRank; }
41
42     int getNumProcessors (void) const
43         { return m_nProcessors; }
44
45     int getStartWorkUnit (int rank) const
46         { return m_vStartWorkUnit [rank]; }
47
48     int getEndWorkUnit (int rank) const
49       { return m_vEndWorkUnit [rank]; }
50
51     int getLocalWorkUnits (int rank) const
52         { return m_vLocalWorkUnits [rank]; }
53
54     int getMyStartWorkUnit (void) const
55         { return m_vStartWorkUnit [m_myRank]; }
56
57     int getMyEndWorkUnit (void) const
58         { return m_vEndWorkUnit [m_myRank]; }
59
60     int getMyLocalWorkUnits (void) const
61         { return m_vLocalWorkUnits [m_myRank]; }
62
63     MPI::Intracomm& getComm() 
64       { return m_comm; }
65
66     void BcastString (string& str);
67
68 private:
69     int m_myRank;
70     int m_nProcessors;
71     vector<int> m_vLocalWorkUnits;
72     vector<int> m_vStartWorkUnit;
73     vector<int> m_vEndWorkUnit;
74     MPI::Intracomm m_comm;
75 };
76