HLTrigger
Timer
src
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 "
HLTrigger/Timer/interface/processor_model.h
"
17
18
std::string
read_processor_model
() {
19
std::string
result
=
"unknown"
;
20
21
#if BOOST_OS_LINUX
22
// on Linux, read the processor model from /proc/cpuinfo,
23
// and check the status of SMT from /sys/devices/system/cpu/smt/active
24
static
const
std::regex
pattern
(
"^model name\\s*:\\s*(.*)"
, std::regex::optimize);
25
std::smatch
match
;
26
27
std::ifstream cpuinfo(
"/proc/cpuinfo"
,
std::ios::in
);
28
std::string
line
;
29
while
(cpuinfo.good()) {
30
std::getline(cpuinfo,
line
);
31
if
(std::regex_match(
line
,
match
,
pattern
)) {
32
result
=
match
[1];
33
break
;
34
}
35
}
36
37
std::ifstream smtinfo(
"/sys/devices/system/cpu/smt/active"
,
std::ios::in
);
38
if
(smtinfo) {
39
int
status
;
40
smtinfo >>
status
;
41
result
+=
status
?
" with SMT enabled"
:
" with SMT disabled"
;
42
}
43
#endif // BOOST_OS_LINUX
44
45
#if BOOST_OS_BSD || BOOST_OS_MACOS
46
// on BSD and OS X, read the processor model via sysctlbyname("machdep.cpu.brand_string", ...)
47
std::string
result
;
48
size_t
len;
49
sysctlbyname(
"machdep.cpu.brand_string"
,
nullptr
, &len,
NULL
, 0);
50
result
.resize(len);
51
sysctlbyname(
"machdep.cpu.brand_string"
,
result
.data(), &len,
NULL
, 0);
52
#endif // BOOST_OS_BSD || BOOST_OS_MACOS
53
54
return
result
;
55
}
56
57
const
std::string
processor_model
=
read_processor_model
();
mps_fire.result
result
Definition:
mps_fire.py:311
processor_model.h
NULL
#define NULL
Definition:
scimark2.h:8
recoMuon::in
Definition:
RecoMuonEnumerators.h:6
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
read_processor_model
std::string read_processor_model()
Definition:
processor_model.cc:18
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition:
topSingleLeptonDQM_PU_cfi.py:39
mps_splice.line
line
Definition:
mps_splice.py:76
mps_update.status
status
Definition:
mps_update.py:68
processor_model
const std::string processor_model
Definition:
processor_model.cc:57
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.14