]> SALOME platform Git repositories - modules/kernel.git/blob - src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx
Salome HOME
PR: merge from tag mergeto_trunk_20Jan05
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesCatalog_Parser.cxx
1 #include "SALOME_ResourcesCatalog_Parser.hxx"
2 #include <iostream>
3
4 #define NULL_VALUE 0
5
6 using namespace std;
7
8 unsigned int ResourceDataToSort::_nbOfNodesWanted=NULL_VALUE;
9 unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted=NULL_VALUE;
10 unsigned int ResourceDataToSort::_CPUFreqMHzWanted=NULL_VALUE;
11 unsigned int ResourceDataToSort::_memInMBWanted=NULL_VALUE;
12
13 ResourceDataToSort::ResourceDataToSort()
14 {
15 }
16
17 ResourceDataToSort::ResourceDataToSort(const string& hostname,unsigned int nbOfNodes,unsigned int nbOfProcPerNode,unsigned int CPUFreqMHz,unsigned int memInMB):_hostName(hostname),_nbOfNodes(nbOfNodes),_nbOfProcPerNode(nbOfProcPerNode),_CPUFreqMHz(CPUFreqMHz),_memInMB(memInMB)
18 {
19 }
20
21 //! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
22 bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
23 {
24   unsigned int nbPts=GetNumberOfPoints();
25   return nbPts<other.GetNumberOfPoints();
26 }
27
28 unsigned int ResourceDataToSort::GetNumberOfPoints() const
29 {
30   unsigned int ret=0;
31   //priority 1 : Nb of nodes
32   if(_nbOfNodesWanted!=NULL_VALUE)
33     {
34       if(_nbOfNodes==_nbOfNodesWanted)
35         ret+=3000;
36       else if(_nbOfNodes>_nbOfNodesWanted)
37         ret+=2000;
38       else
39         ret+=1000;
40     }
41   //priority 2 : Nb of proc by node
42   if(_nbOfProcPerNodeWanted!=NULL_VALUE)
43     {
44       if(_nbOfProcPerNode==_nbOfProcPerNodeWanted)
45         ret+=300;
46       else if(_nbOfProcPerNode > _nbOfProcPerNodeWanted)
47         ret+=200;
48       else
49         ret+=100;
50     }
51   //priority 3 : Cpu freq
52   if(_CPUFreqMHzWanted!=NULL_VALUE)
53     {
54       if(_CPUFreqMHz==_CPUFreqMHzWanted)
55         ret+=30;
56       else if(_CPUFreqMHz > _CPUFreqMHzWanted)
57         ret+=20;
58       else
59         ret+=10;
60     }
61   //priority 4 : memory
62   if(_memInMBWanted!=NULL_VALUE)
63     {
64       if(_memInMB==_memInMBWanted)
65         ret+=3;
66       else if(_memInMB > _memInMBWanted)
67         ret+=2;
68       else
69         ret+=1;
70     }
71   return ret;
72 }
73
74 //! Method used for debug
75 void ResourceDataToSort::Print() const
76 {
77   cout << "Nb of nodes : " << _nbOfNodes << endl;
78   cout << "Nb of proc per node : " <<  _nbOfProcPerNode << endl;
79   cout << "CPU : " << _CPUFreqMHz << endl;
80   cout << "Mem : " << _memInMB << endl;
81 }
82