1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 #include "Batch_MpiImpl.hxx"
42 MpiImpl_LAM::MpiImpl_LAM() : MpiImpl()
47 MpiImpl_LAM::~MpiImpl_LAM()
51 string MpiImpl_LAM::size()
56 string MpiImpl_LAM::rank()
61 string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes)
64 oss << "lamboot " << machinefile << endl;
68 string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
71 oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
75 string MpiImpl_LAM::halt()
78 oss << "lamhalt" << endl;
82 // mpich1 implementation
84 MpiImpl_MPICH1::MpiImpl_MPICH1() : MpiImpl()
89 MpiImpl_MPICH1::~MpiImpl_MPICH1()
93 string MpiImpl_MPICH1::size()
95 return "${MPIRUN_NPROCS}";
98 string MpiImpl_MPICH1::rank()
100 return "${MPIRUN_RANK}";
103 string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
108 string MpiImpl_MPICH1::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
111 oss << "mpirun -machinefile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
115 string MpiImpl_MPICH1::halt()
120 // mpich2 implementation
122 MpiImpl_MPICH2::MpiImpl_MPICH2() : MpiImpl()
127 MpiImpl_MPICH2::~MpiImpl_MPICH2()
131 string MpiImpl_MPICH2::size()
133 return "${PMI_SIZE}";
136 string MpiImpl_MPICH2::rank()
138 return "${PMI_RANK}";
141 string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes)
144 oss << "mpdboot" << " -n " << nbnodes;
146 oss << " -f " << machinefile;
151 string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
154 oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
158 string MpiImpl_MPICH2::halt()
161 oss << "mpdallexit" << endl;
165 // openmpi implementation
167 MpiImpl_OPENMPI::MpiImpl_OPENMPI() : MpiImpl()
172 MpiImpl_OPENMPI::~MpiImpl_OPENMPI()
176 string MpiImpl_OPENMPI::size()
178 return "${OMPI_MCA_ns_nds_num_procs}";
181 string MpiImpl_OPENMPI::rank()
183 return "${OMPI_MCA_ns_nds_vpid}";
186 string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes)
191 string MpiImpl_OPENMPI::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
194 oss << "mpirun -hostfile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
198 string MpiImpl_OPENMPI::halt()
203 // slurm implementation
205 MpiImpl_SLURM::MpiImpl_SLURM() : MpiImpl()
210 MpiImpl_SLURM::~MpiImpl_SLURM()
214 string MpiImpl_SLURM::size()
216 return "${SLURM_NPROCS}";
219 string MpiImpl_SLURM::rank()
221 return "${SLURM_PROCID}";
224 string MpiImpl_SLURM::boot(const string machinefile, const unsigned int nbnodes)
229 string MpiImpl_SLURM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
232 oss << "srun " << fileNameToExecute << endl;
236 string MpiImpl_SLURM::halt()
241 // prun implementation
243 MpiImpl_PRUN::MpiImpl_PRUN() : MpiImpl()
248 MpiImpl_PRUN::~MpiImpl_PRUN()
252 string MpiImpl_PRUN::size()
254 return "${RMS_NPROCS}";
257 string MpiImpl_PRUN::rank()
259 return "${RMS_RANK}";
262 string MpiImpl_PRUN::boot(const string machinefile, const unsigned int nbnodes)
267 string MpiImpl_PRUN::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
270 oss << "prun -n " << nbproc << " " << "-p mpi " << fileNameToExecute << endl;
274 string MpiImpl_PRUN::halt()