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::_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 string& hostname,
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 1 : Nb of nodes
62 if (_nbOfNodesWanted != NULL_VALUE)
64 if (_nbOfNodes == _nbOfNodesWanted)
66 else if (_nbOfNodes > _nbOfNodesWanted)
72 //priority 2 : Nb of proc by node
73 if (_nbOfProcPerNodeWanted != NULL_VALUE)
75 if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
77 else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
83 //priority 3 : Cpu freq
84 if (_CPUFreqMHzWanted != NULL_VALUE)
86 if (_CPUFreqMHz == _CPUFreqMHzWanted)
88 else if (_CPUFreqMHz > _CPUFreqMHzWanted)
95 if (_memInMBWanted != NULL_VALUE)
97 if (_memInMB == _memInMBWanted)
99 else if (_memInMB > _memInMBWanted)
108 //! Method used for debug
109 void ResourceDataToSort::Print() const
111 cout << _nbOfNodes << endl;
112 cout << _nbOfProcPerNode << endl;
113 cout << _CPUFreqMHz << endl;
114 cout << _memInMB << endl;
117 void ParserResourcesType::Print() const
121 "HostName : " << HostName << endl <<
122 "Alias : " << Alias << endl <<
123 "NbOfNodes : " << DataForSort._nbOfNodes << endl <<
124 "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << endl <<
125 "CPUFreqMHz : " << DataForSort._CPUFreqMHz << endl <<
126 "MemInMB : " << DataForSort._memInMB << endl <<
127 "Protocol : " << Protocol << endl <<
128 "Mode : " << Mode << endl <<
129 "Batch : " << Batch << endl <<
130 "mpi : " << mpi << endl <<
131 "UserName : " << UserName << endl <<
132 "AppliPath : " << AppliPath << endl <<
133 "OS : " << OS << endl <<
134 "batchQueue : " << batchQueue << endl <<
135 "userCommands : " << userCommands << endl <<
136 "Components : " << endl;
138 for(int i=0;i<ComponentsList.size();i++)
139 oss << "Component " << i+1 << " called : " << ComponentsList[i] << endl;
141 cout << oss.str() << endl;
145 void ParserResourcesType::Clear()
147 DataForSort._hostName = "";
148 DataForSort._nbOfNodes = 1;
149 DataForSort._nbOfProcPerNode = 1;
150 DataForSort._CPUFreqMHz = 0;
151 DataForSort._memInMB = 0;
162 ComponentsList.clear();