Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-codegen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Heinigk
dune-codegen
Commits
fc8408b6
Commit
fc8408b6
authored
7 years ago
by
Dominic Kempf
Browse files
Options
Downloads
Patches
Plain Diff
Provide TSC frequency regardless of dmesg availability
parent
30b24c52
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/perftool/common/tsc.cc
+38
-2
38 additions, 2 deletions
dune/perftool/common/tsc.cc
dune/perftool/common/tsc.hh
+4
-0
4 additions, 0 deletions
dune/perftool/common/tsc.hh
with
42 additions
and
2 deletions
dune/perftool/common/tsc.cc
+
38
−
2
View file @
fc8408b6
...
...
@@ -23,7 +23,7 @@ namespace Dune {
#if __linux__
TSC
::
Counter
get_tsc_frequency
()
TSC
::
Counter
get_tsc_frequency
_from_dmesg
()
{
int
pipe_fds
[
2
];
if
(
pipe
(
pipe_fds
)
<
0
)
...
...
@@ -99,7 +99,7 @@ namespace Dune {
DUNE_THROW
(
TSCError
,
"Child process failed with return status "
<<
WEXITSTATUS
(
status
));
if
(
result
<
0
)
DUNE_THROW
(
TSC
Error
,
"Could not find TSC frequency information in kernel log"
);
DUNE_THROW
(
TSC
NotInKernelLog
,
"Could not find TSC frequency information in kernel log"
);
}
...
...
@@ -109,6 +109,42 @@ namespace Dune {
}
TSC
::
Counter
get_tsc_frequency_from_cpuinfo
()
{
double
result
=
-
1.0
;
try
{
auto
cpuinfo
=
std
::
ifstream
(
"/proc/cpuinfo"
);
auto
re
=
std
::
regex
(
"bogomips
\\
s:
\\
s(
\\
d+
\\
.
\\
d+)$"
);
using
std
::
getline
;
for
(
std
::
string
line
;
getline
(
cpuinfo
,
line
)
;
)
{
if
(
auto
match
=
std
::
smatch
()
;
std
::
regex_match
(
line
,
match
,
re
))
{
result
=
5e5
*
std
::
stod
(
match
[
1
].
str
());
break
;
}
}
}
catch
(
std
::
exception
&
e
)
{
DUNE_THROW
(
TSCError
,
"error getting TSC frequency from /proc/cpuinfo: "
<<
e
.
what
());
}
if
(
result
<
0
)
DUNE_THROW
(
TSCError
,
"could not find bogomips value in /proc/cpuinfo"
);
return
result
;
}
TSC
::
Counter
get_tsc_frequency
()
{
try
{
return
get_tsc_frequency_from_dmesg
();
}
catch
(
TSCNotInKernelLog
&
)
{
return
get_tsc_frequency_from_cpuinfo
();
}
}
#elif __APPLE__
...
...
This diff is collapsed.
Click to expand it.
dune/perftool/common/tsc.hh
+
4
−
0
View file @
fc8408b6
...
...
@@ -11,6 +11,10 @@ namespace Dune {
:
public
Exception
{};
class
TSCNotInKernelLog
:
public
TSCError
{};
class
TSC
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment