1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SALOME_ResourcesCatalog_Parser.hxx"
21 #include "utilities.h"
28 unsigned int ResourceDataToSort::_nbOfNodesWanted = NULL_VALUE;
29 unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted = NULL_VALUE;
30 unsigned int ResourceDataToSort::_CPUFreqMHzWanted = NULL_VALUE;
31 unsigned int ResourceDataToSort::_memInMBWanted = NULL_VALUE;
33 ResourceDataToSort::ResourceDataToSort()
36 ResourceDataToSort::ResourceDataToSort(const string& hostname,
37 unsigned int nbOfNodes,
38 unsigned int nbOfProcPerNode,
39 unsigned int CPUFreqMHz,
40 unsigned int memInMB):
42 _nbOfNodes(nbOfNodes),
43 _nbOfProcPerNode(nbOfProcPerNode),
44 _CPUFreqMHz(CPUFreqMHz),
48 //! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
49 bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
51 unsigned int nbPts = GetNumberOfPoints();
52 return nbPts < other.GetNumberOfPoints();
55 unsigned int ResourceDataToSort::GetNumberOfPoints() const
58 //priority 1 : Nb of nodes
60 if (_nbOfNodesWanted != NULL_VALUE)
62 if (_nbOfNodes == _nbOfNodesWanted)
64 else if (_nbOfNodes > _nbOfNodesWanted)
70 //priority 2 : Nb of proc by node
71 if (_nbOfProcPerNodeWanted != NULL_VALUE)
73 if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
75 else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
81 //priority 3 : Cpu freq
82 if (_CPUFreqMHzWanted != NULL_VALUE)
84 if (_CPUFreqMHz == _CPUFreqMHzWanted)
86 else if (_CPUFreqMHz > _CPUFreqMHzWanted)
93 if (_memInMBWanted != NULL_VALUE)
95 if (_memInMB == _memInMBWanted)
97 else if (_memInMB > _memInMBWanted)
106 //! Method used for debug
107 void ResourceDataToSort::Print() const
110 SCRUTE(_nbOfProcPerNode);
115 void ParserResourcesType::Print() const
119 "HostName : " << DataForSort._hostName << endl <<
120 "Alias : " << Alias << endl <<
121 "NbOfNodes : " << DataForSort._nbOfNodes << endl <<
122 "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << endl <<
123 "CPUFreqMHz : " << DataForSort._CPUFreqMHz << endl <<
124 "MemInMB : " << DataForSort._memInMB << endl <<
125 "Protocol : " << Protocol << endl <<
126 "Mode : " << Mode << endl <<
127 "Batch : " << Batch << endl <<
128 "mpi : " << mpi << endl <<
129 "UserName : " << UserName << endl <<
130 "AppliPath : " << AppliPath << endl <<
131 "OS : " << OS << endl <<
132 "Modules : " << endl;
134 for(int i=0;i<ModulesList.size();i++)
135 oss << "Module " << i+1 << " called : " << ModulesList[i] << endl;
141 void ParserResourcesType::Clear()
143 DataForSort._hostName = "";
144 DataForSort._nbOfNodes = 1;
145 DataForSort._nbOfProcPerNode = 1;
146 DataForSort._CPUFreqMHz = 0;
147 DataForSort._memInMB = 0;