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
23 #include "SALOME_ResourcesCatalog_Parser.hxx"
29 unsigned int ResourceDataToSort::_nbOfProcWanted = NULL_VALUE;
30 unsigned int ResourceDataToSort::_nbOfNodesWanted = NULL_VALUE;
31 unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted = NULL_VALUE;
32 unsigned int ResourceDataToSort::_CPUFreqMHzWanted = NULL_VALUE;
33 unsigned int ResourceDataToSort::_memInMBWanted = NULL_VALUE;
35 ResourceDataToSort::ResourceDataToSort()
38 ResourceDataToSort::ResourceDataToSort(const std::string& name,
39 unsigned int nbOfNodes,
40 unsigned int nbOfProcPerNode,
41 unsigned int CPUFreqMHz,
42 unsigned int memInMB):
44 _nbOfNodes(nbOfNodes),
45 _nbOfProcPerNode(nbOfProcPerNode),
46 _CPUFreqMHz(CPUFreqMHz),
50 //! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
51 bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
53 unsigned int nbPts = GetNumberOfPoints();
54 return nbPts < other.GetNumberOfPoints();
57 unsigned int ResourceDataToSort::GetNumberOfPoints() const
60 //priority 0 : Nb of proc
62 if (_nbOfProcWanted != NULL_VALUE)
64 unsigned int nb_proc = _nbOfNodes * _nbOfProcPerNode;
65 if (nb_proc == _nbOfProcWanted)
67 else if (nb_proc > _nbOfProcWanted)
73 //priority 1 : Nb of nodes
75 if (_nbOfNodesWanted != NULL_VALUE)
77 if (_nbOfNodes == _nbOfNodesWanted)
79 else if (_nbOfNodes > _nbOfNodesWanted)
85 //priority 2 : Nb of proc by node
86 if (_nbOfProcPerNodeWanted != NULL_VALUE)
88 if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
90 else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
96 //priority 3 : Cpu freq
97 if (_CPUFreqMHzWanted != NULL_VALUE)
99 if (_CPUFreqMHz == _CPUFreqMHzWanted)
101 else if (_CPUFreqMHz > _CPUFreqMHzWanted)
107 //priority 4 : memory
108 if (_memInMBWanted != NULL_VALUE)
110 if (_memInMB == _memInMBWanted)
112 else if (_memInMB > _memInMBWanted)
118 //RES_MESSAGE("[GetNumberOfPoints] points number for resource: " << _Name << " " << ret);
122 //! Method used for debug
123 void ResourceDataToSort::Print() const
125 std::cout << _nbOfNodes << std::endl;
126 std::cout << _nbOfProcPerNode << std::endl;
127 std::cout << _CPUFreqMHz << std::endl;
128 std::cout << _memInMB << std::endl;
131 void ParserResourcesType::Print()
133 std::ostringstream oss;
135 "Name : " << Name << std::endl <<
136 "HostName : " << HostName << std::endl <<
137 "NbOfNodes : " << DataForSort._nbOfNodes << std::endl <<
138 "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << std::endl <<
139 "CPUFreqMHz : " << DataForSort._CPUFreqMHz << std::endl <<
140 "MemInMB : " << DataForSort._memInMB << std::endl <<
141 "Protocol : " << Protocol << std::endl <<
142 "ClusterInternalProtocol : " << ClusterInternalProtocol << std::endl <<
143 "Mode : " << Mode << std::endl <<
144 "Batch : " << Batch << std::endl <<
145 "mpi : " << mpi << std::endl <<
146 "UserName : " << UserName << std::endl <<
147 "AppliPath : " << AppliPath << std::endl <<
148 "OS : " << OS << std::endl <<
149 "batchQueue : " << batchQueue << std::endl <<
150 "userCommands : " << userCommands << std::endl <<
151 "use : " << use << std::endl <<
152 "NbOfProc : " << nbOfProc << std::endl <<
153 "Modules : " << std::endl <<
154 "Components : " << std::endl;
156 for(unsigned int i=0;i<ComponentsList.size();i++)
157 oss << "Component " << i+1 << " called : " << ComponentsList[i] << std::endl;
160 std::list<ParserResourcesClusterMembersType>::iterator it;
161 for(it = ClusterMembersList.begin();
162 it != ClusterMembersList.end();
165 oss << "Cluster member called : " << (*it).HostName << std::endl;
167 std::cout << oss.str() << std::endl;
171 ParserResourcesType::PrintAccessProtocolType() const
180 ParserResourcesType::PrintClusterInternalProtocol() const
182 if (ClusterInternalProtocol == rsh)
189 ParserResourcesType::PrintAccessModeType() const
191 if (Mode == interactive)
192 return "interactive";
198 ParserResourcesType::PrintBatchType() const
202 else if (Batch == pbs)
204 else if (Batch == lsf)
206 else if (Batch == sge)
213 ParserResourcesType::PrintMpiImplType() const
219 else if (mpi == mpich1)
221 else if (mpi == mpich2)
223 else if (mpi == openmpi)
225 else if (mpi == slurm)
231 void ParserResourcesType::Clear()
236 ClusterInternalProtocol = rsh;
244 ComponentsList.clear();
247 ClusterMembersList.clear();
250 DataForSort._Name = "";
251 DataForSort._nbOfNodes = 1;
252 DataForSort._nbOfProcPerNode = 1;
253 DataForSort._CPUFreqMHz = 0;
254 DataForSort._memInMB = 0;