Main Page
Namespaces
Classes
Package Documentation
HLTrigger
Timer
plugins
processor_model.cc
Go to the documentation of this file.
1
#include <string>
2
#include <boost/predef/os.h>
3
4
#if BOOST_OS_LINUX
5
// Linux
6
#include <fstream>
7
#include <regex>
8
#endif // BOOST_OS_LINUX
9
10
#if BOOST_OS_BSD || BOOST_OS_MACOS
11
// OSX or BSD
12
#include <sys/types.h>
13
#include <sys/sysctl.h>
14
#endif // BOOST_OS_BSD || BOOST_OS_MACOS
15
16
#include "
processor_model.h
"
17
18
std::string
read_processor_model
()
19
{
20
#if BOOST_OS_LINUX
21
// on Linux, read the processor model from /proc/cpuinfo
22
static
const
std::regex
pattern
(
"^model name\\s*:\\s*(.*)"
, std::regex::optimize);
23
std::smatch
match
;
24
25
std::ifstream cpuinfo(
"/proc/cpuinfo"
,
std::ios::in
);
26
std::string
line
;
27
while
(cpuinfo.good()) {
28
std::getline(cpuinfo, line);
29
if
(std::regex_match(line, match, pattern)) {
30
return
match[1];
31
}
32
}
33
#endif // BOOST_OS_LINUX
34
35
#if BOOST_OS_BSD || BOOST_OS_MACOS
36
// on BSD and OS X, read the processor model via sysctlbyname("machdep.cpu.brand_string", ...)
37
std::string
result
;
38
size_t
len;
39
sysctlbyname(
"machdep.cpu.brand_string"
,
nullptr
, & len,
NULL
, 0);
40
result.resize(len);
41
sysctlbyname(
"machdep.cpu.brand_string"
, result.data(), & len,
NULL
, 0);
42
return
result
;
43
#endif // BOOST_OS_BSD || BOOST_OS_MACOS
44
45
return
"unknown"
;
46
}
47
48
const
std::string
processor_model
=
read_processor_model
();
mps_fire.result
result
Definition:
mps_fire.py:291
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
processor_model.h
NULL
#define NULL
Definition:
scimark2.h:8
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
read_processor_model
std::string read_processor_model()
Definition:
processor_model.cc:18
mps_splice.line
line
Definition:
mps_splice.py:76
processor_model
const std::string processor_model
Definition:
processor_model.cc:48
listBenchmarks.pattern
pattern
Definition:
listBenchmarks.py:26
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
Generated for CMSSW Reference Manual by
1.8.11