Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
7bd8ef7f
Commit
7bd8ef7f
authored
Sep 18, 2017
by
Sebastian Woelke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add output which shows the number of steals
parent
2fa81bb4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
5 deletions
+26
-5
libcaf_core/caf/policy/numa_aware_work_stealing.hpp
libcaf_core/caf/policy/numa_aware_work_stealing.hpp
+6
-2
libcaf_core/caf/policy/scheduler_policy.hpp
libcaf_core/caf/policy/scheduler_policy.hpp
+3
-0
libcaf_core/caf/policy/work_sharing.hpp
libcaf_core/caf/policy/work_sharing.hpp
+3
-1
libcaf_core/caf/policy/work_stealing.hpp
libcaf_core/caf/policy/work_stealing.hpp
+11
-2
libcaf_core/caf/scheduler/coordinator.hpp
libcaf_core/caf/scheduler/coordinator.hpp
+3
-0
No files found.
libcaf_core/caf/policy/numa_aware_work_stealing.hpp
View file @
7bd8ef7f
...
@@ -109,7 +109,8 @@ public:
...
@@ -109,7 +109,8 @@ public:
:
rengine
(
std
::
random_device
{}())
:
rengine
(
std
::
random_device
{}())
,
strategies
(
get_poll_strategies
(
p
))
,
strategies
(
get_poll_strategies
(
p
))
,
neighborhood_level
(
,
neighborhood_level
(
p
->
system
().
config
().
numa_aware_work_stealing_neighborhood_level
)
{
p
->
system
().
config
().
numa_aware_work_stealing_neighborhood_level
)
,
number_of_steals
(
0
)
{
// nop
// nop
}
}
...
@@ -210,6 +211,7 @@ public:
...
@@ -210,6 +211,7 @@ public:
std
::
uniform_int_distribution
<
size_t
>
uniform
;
std
::
uniform_int_distribution
<
size_t
>
uniform
;
std
::
vector
<
poll_strategy
>
strategies
;
std
::
vector
<
poll_strategy
>
strategies
;
size_t
neighborhood_level
;
size_t
neighborhood_level
;
uint64_t
number_of_steals
;
};
};
/// Create x workers.
/// Create x workers.
...
@@ -317,8 +319,10 @@ public:
...
@@ -317,8 +319,10 @@ public:
// try to steal every X poll attempts
// try to steal every X poll attempts
if
((
i
%
strat
.
steal_interval
)
==
0
)
{
if
((
i
%
strat
.
steal_interval
)
==
0
)
{
job
=
try_steal
(
self
,
scheduler_lvl_idx
,
steal_cnt
);
job
=
try_steal
(
self
,
scheduler_lvl_idx
,
steal_cnt
);
if
(
job
)
if
(
job
)
{
++
d
(
self
).
number_of_steals
;
return
job
;
return
job
;
}
}
}
if
(
strat
.
sleep_duration
.
count
()
>
0
)
if
(
strat
.
sleep_duration
.
count
()
>
0
)
std
::
this_thread
::
sleep_for
(
strat
.
sleep_duration
);
std
::
this_thread
::
sleep_for
(
strat
.
sleep_duration
);
...
...
libcaf_core/caf/policy/scheduler_policy.hpp
View file @
7bd8ef7f
...
@@ -101,6 +101,9 @@ public:
...
@@ -101,6 +101,9 @@ public:
/// Applies given functor to all resumables attached to the coordinator.
/// Applies given functor to all resumables attached to the coordinator.
template
<
class
Coordinator
,
typename
UnaryFunction
>
template
<
class
Coordinator
,
typename
UnaryFunction
>
void
foreach_central_resumable
(
Coordinator
*
self
,
UnaryFunction
f
);
void
foreach_central_resumable
(
Coordinator
*
self
,
UnaryFunction
f
);
template
<
class
Worker
>
uint64_t
get_number_of_steals
(
Worker
*
self
);
};
};
}
// namespace policy
}
// namespace policy
...
...
libcaf_core/caf/policy/work_sharing.hpp
View file @
7bd8ef7f
...
@@ -54,9 +54,11 @@ public:
...
@@ -54,9 +54,11 @@ public:
template
<
class
Worker
>
template
<
class
Worker
>
struct
worker_data
{
struct
worker_data
{
explicit
worker_data
(
scheduler
::
abstract_coordinator
*
)
{
explicit
worker_data
(
scheduler
::
abstract_coordinator
*
)
:
number_of_steals
(
0
)
{
// nop
// nop
}
}
uint64_t
number_of_steals
;
};
};
// Create x workers.
// Create x workers.
...
...
libcaf_core/caf/policy/work_stealing.hpp
View file @
7bd8ef7f
...
@@ -91,7 +91,8 @@ public:
...
@@ -91,7 +91,8 @@ public:
// no need to worry about wrap-around; if `p->num_workers() < 2`,
// no need to worry about wrap-around; if `p->num_workers() < 2`,
// `uniform` will not be used anyway
// `uniform` will not be used anyway
,
uniform
(
0
,
p
->
num_workers
()
-
2
)
,
uniform
(
0
,
p
->
num_workers
()
-
2
)
,
strategies
(
get_poll_strategies
(
p
))
{
,
strategies
(
get_poll_strategies
(
p
))
,
number_of_steals
(
0
)
{
// nop
// nop
}
}
...
@@ -102,6 +103,7 @@ public:
...
@@ -102,6 +103,7 @@ public:
std
::
default_random_engine
rengine
;
std
::
default_random_engine
rengine
;
std
::
uniform_int_distribution
<
size_t
>
uniform
;
std
::
uniform_int_distribution
<
size_t
>
uniform
;
std
::
vector
<
poll_strategy
>
strategies
;
std
::
vector
<
poll_strategy
>
strategies
;
uint64_t
number_of_steals
;
};
};
// Create x workers.
// Create x workers.
...
@@ -179,8 +181,10 @@ public:
...
@@ -179,8 +181,10 @@ public:
// try to steal every X poll attempts
// try to steal every X poll attempts
if
((
i
%
strat
.
steal_interval
)
==
0
)
{
if
((
i
%
strat
.
steal_interval
)
==
0
)
{
job
=
try_steal
(
self
);
job
=
try_steal
(
self
);
if
(
job
)
if
(
job
)
{
++
d
(
self
).
number_of_steals
;
return
job
;
return
job
;
}
}
}
if
(
strat
.
sleep_duration
.
count
()
>
0
)
if
(
strat
.
sleep_duration
.
count
()
>
0
)
std
::
this_thread
::
sleep_for
(
strat
.
sleep_duration
);
std
::
this_thread
::
sleep_for
(
strat
.
sleep_duration
);
...
@@ -203,6 +207,11 @@ public:
...
@@ -203,6 +207,11 @@ public:
void
foreach_central_resumable
(
Coordinator
*
,
UnaryFunction
)
{
void
foreach_central_resumable
(
Coordinator
*
,
UnaryFunction
)
{
// nop
// nop
}
}
template
<
class
Worker
>
uint64_t
get_number_of_steals
(
Worker
*
self
)
{
return
d
(
self
).
number_of_steals
;
}
};
};
}
// namespace policy
}
// namespace policy
...
...
libcaf_core/caf/scheduler/coordinator.hpp
View file @
7bd8ef7f
...
@@ -72,6 +72,7 @@ protected:
...
@@ -72,6 +72,7 @@ protected:
}
}
void
stop
()
override
{
void
stop
()
override
{
uint64_t
accumulated_number_of_steals
=
0
;
// shutdown workers
// shutdown workers
class
shutdown_helper
:
public
resumable
,
public
ref_counted
{
class
shutdown_helper
:
public
resumable
,
public
ref_counted
{
public:
public:
...
@@ -120,7 +121,9 @@ protected:
...
@@ -120,7 +121,9 @@ protected:
// wait until all workers are done
// wait until all workers are done
for
(
auto
&
w
:
data_
.
workers
)
{
for
(
auto
&
w
:
data_
.
workers
)
{
w
->
get_thread
().
join
();
w
->
get_thread
().
join
();
accumulated_number_of_steals
=
w
->
data
().
number_of_steals
;
}
}
std
::
cout
<<
"accumulated_number_of_steals: "
<<
accumulated_number_of_steals
<<
std
::
endl
;
// run cleanup code for each resumable
// run cleanup code for each resumable
auto
f
=
&
abstract_coordinator
::
cleanup_and_release
;
auto
f
=
&
abstract_coordinator
::
cleanup_and_release
;
for
(
auto
&
w
:
data_
.
workers
)
for
(
auto
&
w
:
data_
.
workers
)
...
...
Write
Preview
Markdown
is supported
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