Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Florian Fischer
emper
Commits
534207e9
Commit
534207e9
authored
Apr 26, 2022
by
Florian Schmaus
Browse files
Merge branch 'improve-pulse' into 'master'
Improve pulse evaluation See merge request
i4/manycore/emper!381
parents
f442e1fd
90fbe73a
Pipeline
#80844
passed with stages
in 17 minutes and 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
emper/Emper.cpp
View file @
534207e9
...
...
@@ -5,6 +5,7 @@
#include
<cassert>
#include
<cerrno>
#include
<cstdint>
#include
<ctime>
#include
<stdexcept>
#include
<utility>
...
...
@@ -182,16 +183,25 @@ void yield() {
runtime
->
yield
();
}
auto
sleep
(
unsigned
int
second
s
)
->
bool
{
static
auto
_
sleep
(
emper
::
io
::
AlarmFuture
::
Timespec
&
t
s
)
->
bool
{
if
constexpr
(
!
emper
::
IO
)
{
DIE_MSG
(
"sleep requires emper::io"
);
}
emper
::
io
::
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
seconds
,
.
tv_nsec
=
0
};
emper
::
io
::
AlarmFuture
alarm
(
ts
);
int32_t
res
=
alarm
.
submitAndWait
();
return
res
==
-
ETIME
;
}
auto
sleep
(
unsigned
int
seconds
)
->
bool
{
emper
::
io
::
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
seconds
,
.
tv_nsec
=
0
};
return
_sleep
(
ts
);
}
auto
nanosleep
(
const
struct
timespec
*
rqtp
)
->
bool
{
emper
::
io
::
AlarmFuture
::
Timespec
ts
=
{.
tv_sec
=
rqtp
->
tv_sec
,
.
tv_nsec
=
rqtp
->
tv_nsec
};
return
_sleep
(
ts
);
}
}
// namespace emper
emper/include/emper.hpp
View file @
534207e9
...
...
@@ -56,5 +56,6 @@ void destroy_runtime();
void
yield
();
auto
sleep
(
unsigned
int
seconds
)
->
bool
;
auto
nanosleep
(
const
struct
timespec
*
rqtp
)
->
bool
;
}
// namespace emper
eval/Pulse.cpp
View file @
534207e9
...
...
@@ -3,7 +3,9 @@
#include
<boost/program_options.hpp>
#include
<chrono>
#include
<compare>
#include
<cstdint>
#include
<cstdlib>
#include
<ctime>
#include
<exception>
#include
<fstream>
// IWYU pragma: keep
#include
<iostream>
...
...
@@ -20,8 +22,8 @@ namespace po = boost::program_options;
using
Clock
=
std
::
chrono
::
high_resolution_clock
;
using
TimePoint
=
std
::
chrono
::
time_point
<
Clock
>
;
// Pulse of new work in seconds
static
unsigned
pulse
=
1
;
// Pulse of new work in
micro
seconds
static
int64_t
pulse
=
1
L
*
1000
*
1000
;
// Number of pulses
static
unsigned
iterations
=
30
;
// Utilization of the runtime in percent
...
...
@@ -39,7 +41,7 @@ class Work {
Work
()
:
start
(
Clock
::
now
())
{}
void
run
()
{
const
auto
deadline
=
Clock
::
now
()
+
std
::
chrono
::
seconds
(
pulse
);
const
auto
deadline
=
Clock
::
now
()
+
std
::
chrono
::
micro
seconds
(
pulse
);
while
(
Clock
::
now
()
<
deadline
)
{
}
...
...
@@ -68,19 +70,16 @@ static void pulser(Runtime& runtime) {
}
// TODO: better calculate the time until the next pulse
emper
::
sleep
(
pulse
);
struct
timespec
ts
{
.
tv_sec
=
0
,
.
tv_nsec
=
pulse
*
1000
};
emper
::
nanosleep
(
&
ts
);
}
cps
.
wait
();
runtime
.
initiateTermination
();
}
static
auto
eval
(
const
po
::
variables_map
&
vm
)
->
int
{
if
(
vm
.
count
(
"pulse"
))
pulse
=
vm
[
"pulse"
].
as
<
unsigned
>
();
if
(
vm
.
count
(
"iterations"
))
iterations
=
vm
[
"iterations"
].
as
<
unsigned
>
();
if
(
vm
.
count
(
"utilization"
))
utilization
=
vm
[
"utilization"
].
as
<
unsigned
>
();
std
::
cerr
<<
"Starting pulse evaluation with pulse="
<<
pulse
;
std
::
cerr
<<
", iterations="
<<
iterations
;
std
::
cerr
<<
" and utilization="
<<
utilization
;
...
...
@@ -129,9 +128,11 @@ auto main(int argc, char* argv[]) -> int {
// clang-format off
desc
.
add_options
()
(
"help"
,
"Show help"
)
(
"pulse"
,
po
::
value
<
unsigned
>
(),
"The pulse of new work"
)
(
"iterations"
,
po
::
value
<
unsigned
>
(),
"The number of pulses"
)
(
"utilization"
,
po
::
value
<
unsigned
>
(),
"The target utilization of the runtime"
)
(
"pulse"
,
po
::
value
<
int64_t
>
(
&
pulse
)
->
default_value
(
pulse
),
"The pulse of new work"
)
(
"iterations"
,
po
::
value
<
unsigned
>
(
&
iterations
)
->
default_value
(
iterations
),
"The number of pulses"
)
(
"utilization"
,
po
::
value
<
unsigned
>
(
&
utilization
)
->
default_value
(
utilization
),
"The target utilization of the runtime"
)
(
"latencies-file"
,
po
::
value
<
std
::
string
>
(),
"File to store all collected latencies"
)
;
// clang-format on
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment