CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::service::CPU Class Reference

#include <CPU.h>

Public Member Functions

 CPU (ParameterSet const &, ActivityRegistry &)
 
 ~CPU ()
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void postEndJob ()
 

Private Attributes

double averageCoreSpeed_
 
bool reportCPUProperties_
 
int totalNumberCPUs_
 

Detailed Description

Definition at line 21 of file CPU.h.

Constructor & Destructor Documentation

edm::service::CPU::CPU ( ParameterSet const &  iPS,
ActivityRegistry iRegistry 
)

Definition at line 82 of file CPU.cc.

References postEndJob(), and edm::ActivityRegistry::watchPostEndJob().

82  :
84  averageCoreSpeed_(0.0),
85  reportCPUProperties_(iPS.getUntrackedParameter<bool>("reportCPUProperties"))
86  {
87  iRegistry.watchPostEndJob(this,&CPU::postEndJob);
88  }
double averageCoreSpeed_
Definition: CPU.h:30
void postEndJob()
Definition: CPU.cc:102
bool reportCPUProperties_
Definition: CPU.h:31
int totalNumberCPUs_
Definition: CPU.h:29
edm::service::CPU::~CPU ( )

Definition at line 91 of file CPU.cc.

92  {
93  }

Member Function Documentation

void edm::service::CPU::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 95 of file CPU.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().

95  {
97  desc.addUntracked<bool>("reportCPUProperties", false);
98  descriptions.add("CPU", desc);
99  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void edm::service::CPU::postEndJob ( )
private

Definition at line 102 of file CPU.cc.

References averageCoreSpeed_, edm::service::d2str(), edm::service::i2str(), getDQMSummary::iter, reportCPUProperties_, AlCaHLTBitMon_QueryRunRegistry::string, cond::rpcobgas::time, totalNumberCPUs_, and relativeConstraints::value.

Referenced by CPU().

103  {
104  Service<JobReport> reportSvc;
105 
106  std::map<std::string, std::string> reportCPUProperties; // Summary
107  std::map<std::string, std::string> currentCoreProperties; // Module(s)
108 
109  std::ifstream fcpuinfo ("/proc/cpuinfo");
110 
111  if(fcpuinfo.is_open()){
112 
113  std::string buf;
114  std::string currentCore;
115  std::string CPUModels;
116 
117  std::set<std::string> models;
118 
119  while(!fcpuinfo.eof()){
120 
121  std::getline(fcpuinfo, buf);
122 
123  std::istringstream iss(buf);
124  std::string token;
125  std::string property;
127 
128  int time = 1;
129 
130  while(std::getline(iss, token, ':')) {
131  switch(time){
132  case 1:
133  property = token;
134  break;
135  case 2:
136  value = token;
137  break;
138  default:
139  value += token;
140  break;
141  }
142  time++;
143  }
144  trim(property);
145  trim(value);
146 
147  if(!property.empty()){
148  if(property == "processor") {
150  if(currentCore.empty()) { // first core
151  currentCore = value;
152  }
153  else{
154  reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties);
155  currentCoreProperties.clear();
156  currentCore = value;
157  }
158  }
160  }
161  else {
163  currentCoreProperties.insert(std::make_pair(property, value));
164  }
165  if(property == "cpu MHz"){
166  averageCoreSpeed_ += str2d(value);
167  }
168  if(property == "model name"){
169  models.insert(eraseExtraSpaces(value));
170  }
171  }
172  }
173  } //while
174 
175  fcpuinfo.close();
176 
177  if(!currentCore.empty() && reportCPUProperties_) {
178  reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties);
179  }
180 
181  reportCPUProperties.insert(std::make_pair("totalCPUs", i2str(totalNumberCPUs_)));
182 
183  if(totalNumberCPUs_ == 0){
184  averageCoreSpeed_ = 0.0;
185  }
186  else{
188  }
189 
190  reportCPUProperties.insert(std::make_pair("averageCoreSpeed", d2str(averageCoreSpeed_)));
191 
192  int model = 0;
193  for(std::set<std::string>::const_iterator iter = models.begin(); iter != models.end(); iter++){
194  if(model == 0)
195  CPUModels += *iter;
196  else
197  CPUModels += ", " + *iter;
198  model++;
199  }
200  reportCPUProperties.insert(std::make_pair("CPUModels", CPUModels));
201 
202 
203  reportSvc->reportPerformanceSummary("SystemCPU", reportCPUProperties);
204 
205  } //if
206  } //postEndJob
static std::string i2str(int i)
Definition: Memory.cc:68
double averageCoreSpeed_
Definition: CPU.h:30
bool reportCPUProperties_
Definition: CPU.h:31
int totalNumberCPUs_
Definition: CPU.h:29
static std::string d2str(double d)
Definition: Memory.cc:62

Member Data Documentation

double edm::service::CPU::averageCoreSpeed_
private

Definition at line 30 of file CPU.h.

Referenced by postEndJob().

bool edm::service::CPU::reportCPUProperties_
private

Definition at line 31 of file CPU.h.

Referenced by postEndJob().

int edm::service::CPU::totalNumberCPUs_
private

Definition at line 29 of file CPU.h.

Referenced by postEndJob().