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

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 33 of file CPU.cc.

Constructor & Destructor Documentation

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

Definition at line 108 of file CPU.cc.

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

108  :
109  totalNumberCPUs_(0),
110  averageCoreSpeed_(0.0),
111  reportCPUProperties_(iPS.getUntrackedParameter<bool>("reportCPUProperties"))
112  {
113  iRegistry.watchPostEndJob(this,&CPU::postEndJob);
114  }
double averageCoreSpeed_
Definition: CPU.cc:42
void postEndJob()
Definition: CPU.cc:128
bool reportCPUProperties_
Definition: CPU.cc:43
int totalNumberCPUs_
Definition: CPU.cc:41
edm::service::CPU::~CPU ( )

Definition at line 117 of file CPU.cc.

118  {
119  }

Member Function Documentation

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

Definition at line 121 of file CPU.cc.

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

121  {
123  desc.addUntracked<bool>("reportCPUProperties", false);
124  descriptions.add("CPU", desc);
125  }
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 128 of file CPU.cc.

References averageCoreSpeed_, edm::service::d2str(), edm::service::i2str(), reportCPUProperties_, AlCaHLTBitMon_QueryRunRegistry::string, unpackBuffers-CaloStage2::token, totalNumberCPUs_, and relativeConstraints::value.

Referenced by CPU().

129  {
130  Service<JobReport> reportSvc;
131 
132  std::map<std::string, std::string> reportCPUProperties; // Summary
133  std::map<std::string, std::string> currentCoreProperties; // Module(s)
134 
135  std::ifstream fcpuinfo ("/proc/cpuinfo");
136 
137  if(fcpuinfo.is_open()){
138 
139  std::string buf;
140  std::string currentCore;
141  std::string CPUModels;
142 
143  std::set<std::string> models;
144 
145  while(!fcpuinfo.eof()){
146 
147  std::getline(fcpuinfo, buf);
148 
149  std::istringstream iss(buf);
151  std::string property;
153 
154  int time = 1;
155 
156  while(std::getline(iss, token, ':')) {
157  switch(time){
158  case 1:
159  property = token;
160  break;
161  case 2:
162  value = token;
163  break;
164  default:
165  value += token;
166  break;
167  }
168  time++;
169  }
170  trim(property);
171  trim(value);
172 
173  if(!property.empty()){
174  if(property == "processor") {
176  if(currentCore.empty()) { // first core
177  currentCore = value;
178  }
179  else{
180  reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties);
181  currentCoreProperties.clear();
182  currentCore = value;
183  }
184  }
186  }
187  else {
189  currentCoreProperties.insert(std::make_pair(property, value));
190  }
191  if(property == "cpu MHz"){
192  averageCoreSpeed_ += str2d(value);
193  }
194  if(property == "model name"){
195  models.insert(eraseExtraSpaces(value));
196  }
197  }
198  }
199  } //while
200 
201  fcpuinfo.close();
202 
203  if(!currentCore.empty() && reportCPUProperties_) {
204  reportSvc->reportPerformanceForModule("SystemCPU", "CPU-"+currentCore, currentCoreProperties);
205  }
206 
207  reportCPUProperties.insert(std::make_pair("totalCPUs", i2str(totalNumberCPUs_)));
208 
209  if(totalNumberCPUs_ == 0){
210  averageCoreSpeed_ = 0.0;
211  }
212  else{
214  }
215 
216  reportCPUProperties.insert(std::make_pair("averageCoreSpeed", d2str(averageCoreSpeed_)));
217 
218  int model = 0;
219  for(std::set<std::string>::const_iterator iter = models.begin(); iter != models.end(); iter++){
220  if(model == 0)
221  CPUModels += *iter;
222  else
223  CPUModels += ", " + *iter;
224  model++;
225  }
226  reportCPUProperties.insert(std::make_pair("CPUModels", CPUModels));
227 
228 
229  reportSvc->reportPerformanceSummary("SystemCPU", reportCPUProperties);
230 
231  } //if
232  } //postEndJob
static std::string i2str(int i)
double averageCoreSpeed_
Definition: CPU.cc:42
bool reportCPUProperties_
Definition: CPU.cc:43
int totalNumberCPUs_
Definition: CPU.cc:41
static std::string d2str(double d)

Member Data Documentation

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

Definition at line 42 of file CPU.cc.

Referenced by postEndJob().

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

Definition at line 43 of file CPU.cc.

Referenced by postEndJob().

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

Definition at line 41 of file CPU.cc.

Referenced by postEndJob().