Salome HOME
A patch from Paul RASCLE for: kernel documentation with doxygen, modification on...
[modules/kernel.git] / src / Batch / MpiImpl.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 /*
21  * BatchManager.cxx : 
22  *
23  * Auteur : Bernard SECHER - CEA/DEN
24  * Date   : Juillet 2007
25  * Projet : SALOME
26  *
27  */
28
29 #include <iostream>
30 #include <sstream>
31 #include <string>
32 #include "utilities.h"
33 #include "MpiImpl.hxx"
34
35 using namespace std;
36
37 // Constructor
38 MpiImpl::MpiImpl()
39 {
40   MESSAGE("MpiImpl constructor");
41 }
42
43 // Destructor
44 MpiImpl::~MpiImpl()
45 {
46   MESSAGE("MpiImpl destructor");
47 }
48
49 // lam implementation
50 // Constructor
51 MpiImpl_LAM::MpiImpl_LAM() : MpiImpl()
52 {
53 }
54
55 // Destructor
56 MpiImpl_LAM::~MpiImpl_LAM()
57 {
58   MESSAGE("MpiImpl_LAM destructor");
59 }
60
61 string MpiImpl_LAM::size()
62 {
63   return "${LAMWORLD}";
64 }
65
66 string MpiImpl_LAM::rank()
67 {
68   return "${LAMRANK}";
69 }
70
71 string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes)
72 {
73   ostringstream oss;
74   oss << "lamboot " << machinefile << endl;
75   return oss.str();
76 }
77
78 string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
79 {
80   ostringstream oss;
81   oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
82   return oss.str();
83 }
84
85 string MpiImpl_LAM::halt()
86 {
87   ostringstream oss;
88   oss << "lamhalt" << endl;
89   return oss.str();
90 }
91
92 // mpich1 implementation
93 // Constructor
94 MpiImpl_MPICH1::MpiImpl_MPICH1() : MpiImpl()
95 {
96 }
97
98 // Destructor
99 MpiImpl_MPICH1::~MpiImpl_MPICH1()
100 {
101   MESSAGE("MpiImpl_MPICH1 destructor");
102 }
103
104 string MpiImpl_MPICH1::size()
105 {
106   throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
107 }
108
109 string MpiImpl_MPICH1::rank()
110 {
111   throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
112 }
113
114 string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
115 {
116   return "";
117 }
118
119 string MpiImpl_MPICH1::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
120 {
121   ostringstream oss;
122   oss << "mpirun -machinefile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
123   return oss.str();
124 }
125
126 string MpiImpl_MPICH1::halt()
127 {
128   return "";
129 }
130
131 // mpich2 implementation
132 // Constructor
133 MpiImpl_MPICH2::MpiImpl_MPICH2() : MpiImpl()
134 {
135 }
136
137 // Destructor
138 MpiImpl_MPICH2::~MpiImpl_MPICH2()
139 {
140   MESSAGE("MpiImpl_MPICH2 destructor");
141 }
142
143 string MpiImpl_MPICH2::size()
144 {
145   return "${PMI_SIZE}";
146 }
147
148 string MpiImpl_MPICH2::rank()
149 {
150   return "${PMI_RANK}";
151 }
152
153 string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes)
154 {
155   ostringstream oss;
156   oss << "mpdboot -n " << nbnodes << " -f " << machinefile << endl;
157   return oss.str();
158 }
159
160 string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
161 {
162   ostringstream oss;
163   oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
164   return oss.str();
165 }
166
167 string MpiImpl_MPICH2::halt()
168 {
169   ostringstream oss;
170   oss << "mpdallexit" << endl;
171   return oss.str();
172 }
173
174 // openmpi implementation
175 // Constructor
176 MpiImpl_OPENMPI::MpiImpl_OPENMPI() : MpiImpl()
177 {
178 }
179
180 // Destructor
181 MpiImpl_OPENMPI::~MpiImpl_OPENMPI()
182 {
183   MESSAGE("MpiImpl_OPENMPI destructor");
184 }
185
186 string MpiImpl_OPENMPI::size()
187 {
188   return "${OMPI_MCA_ns_nds_num_procs}";
189 }
190
191 string MpiImpl_OPENMPI::rank()
192 {
193   return "${OMPI_MCA_ns_nds_vpid}";
194 }
195
196 string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes)
197 {
198   return "";
199 }
200
201 string MpiImpl_OPENMPI::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
202 {
203   ostringstream oss;
204   oss << "mpirun -hostfile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
205   return oss.str();
206 }
207
208 string MpiImpl_OPENMPI::halt()
209 {
210   return "";
211 }
212