1 // Copyright (C) 2007-2008 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
22 #include "SALOME_ResourcesCatalog_Parser.hxx"
30 unsigned int ResourceDataToSort::_nbOfProcWanted = NULL_VALUE;
31 unsigned int ResourceDataToSort::_nbOfNodesWanted = NULL_VALUE;
32 unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted = NULL_VALUE;
33 unsigned int ResourceDataToSort::_CPUFreqMHzWanted = NULL_VALUE;
34 unsigned int ResourceDataToSort::_memInMBWanted = NULL_VALUE;
36 ResourceDataToSort::ResourceDataToSort()
39 ResourceDataToSort::ResourceDataToSort(const string& name,
40 unsigned int nbOfNodes,
41 unsigned int nbOfProcPerNode,
42 unsigned int CPUFreqMHz,
43 unsigned int memInMB):
45 _nbOfNodes(nbOfNodes),
46 _nbOfProcPerNode(nbOfProcPerNode),
47 _CPUFreqMHz(CPUFreqMHz),
51 //! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
52 bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
54 unsigned int nbPts = GetNumberOfPoints();
55 return nbPts < other.GetNumberOfPoints();
58 unsigned int ResourceDataToSort::GetNumberOfPoints() const
61 //priority 0 : Nb of proc
63 if (_nbOfProcWanted != NULL_VALUE)
65 unsigned int nb_proc = _nbOfNodes * _nbOfProcPerNode;
66 if (nb_proc == _nbOfProcWanted)
68 else if (nb_proc > _nbOfProcWanted)
74 //priority 1 : Nb of nodes
76 if (_nbOfNodesWanted != NULL_VALUE)
78 if (_nbOfNodes == _nbOfNodesWanted)
80 else if (_nbOfNodes > _nbOfNodesWanted)
86 //priority 2 : Nb of proc by node
87 if (_nbOfProcPerNodeWanted != NULL_VALUE)
89 if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
91 else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
97 //priority 3 : Cpu freq
98 if (_CPUFreqMHzWanted != NULL_VALUE)
100 if (_CPUFreqMHz == _CPUFreqMHzWanted)
102 else if (_CPUFreqMHz > _CPUFreqMHzWanted)
108 //priority 4 : memory
109 if (_memInMBWanted != NULL_VALUE)
111 if (_memInMB == _memInMBWanted)
113 else if (_memInMB > _memInMBWanted)
119 //RES_MESSAGE("[GetNumberOfPoints] points number for resource: " << _Name << " " << ret);
123 //! Method used for debug
124 void ResourceDataToSort::Print() const
126 cout << _nbOfNodes << endl;
127 cout << _nbOfProcPerNode << endl;
128 cout << _CPUFreqMHz << endl;
129 cout << _memInMB << endl;
132 void ParserResourcesType::Print()
136 "Name : " << Name << endl <<
137 "HostName : " << HostName << endl <<
138 "NbOfNodes : " << DataForSort._nbOfNodes << endl <<
139 "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << endl <<
140 "CPUFreqMHz : " << DataForSort._CPUFreqMHz << endl <<
141 "MemInMB : " << DataForSort._memInMB << endl <<
142 "Protocol : " << Protocol << endl <<
143 "ClusterInternalProtocol : " << ClusterInternalProtocol << endl <<
144 "Mode : " << Mode << endl <<
145 "Batch : " << Batch << endl <<
146 "mpi : " << mpi << endl <<
147 "UserName : " << UserName << endl <<
148 "AppliPath : " << AppliPath << endl <<
149 "OS : " << OS << endl <<
150 "batchQueue : " << batchQueue << endl <<
151 "userCommands : " << userCommands << endl <<
152 "use : " << use << endl <<
153 "NbOfProc : " << nbOfProc << endl <<
154 "Modules : " << endl <<
155 "Components : " << endl;
157 for(int i=0;i<ComponentsList.size();i++)
158 oss << "Component " << i+1 << " called : " << ComponentsList[i] << endl;
161 std::list<ParserResourcesClusterMembersType>::iterator it;
162 for(it = ClusterMembersList.begin();
163 it != ClusterMembersList.end();
166 oss << "Cluster member called : " << (*it).HostName << endl;
168 cout << oss.str() << endl;
172 ParserResourcesType::PrintAccessProtocolType() const
181 ParserResourcesType::PrintClusterInternalProtocol() const
183 if (ClusterInternalProtocol == rsh)
190 ParserResourcesType::PrintAccessModeType() const
192 if (Mode == interactive)
193 return "interactive";
199 ParserResourcesType::PrintBatchType() const
203 else if (Batch == pbs)
205 else if (Batch == lsf)
207 else if (Batch == sge)
214 ParserResourcesType::PrintMpiImplType() const
220 else if (mpi == mpich1)
222 else if (mpi == mpich2)
224 else if (mpi == openmpi)
226 else if (mpi == slurm)
232 void ParserResourcesType::Clear()
237 ClusterInternalProtocol = rsh;
245 ComponentsList.clear();
248 ClusterMembersList.clear();
251 DataForSort._Name = "";
252 DataForSort._nbOfNodes = 1;
253 DataForSort._nbOfProcPerNode = 1;
254 DataForSort._CPUFreqMHz = 0;
255 DataForSort._memInMB = 0;