Commit 5a18b407 authored by Sebastian Woelke's avatar Sebastian Woelke

Add output which shows the number of steals

parent b0edea0b
......@@ -109,7 +109,8 @@ public:
: rengine(std::random_device{}())
, strategies(get_poll_strategies(p))
, 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
}
......@@ -210,6 +211,7 @@ public:
std::uniform_int_distribution<size_t> uniform;
std::vector<poll_strategy> strategies;
size_t neighborhood_level;
uint64_t number_of_steals;
};
/// Create x workers.
......@@ -318,8 +320,10 @@ public:
// try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) {
job = try_steal(self, scheduler_lvl_idx, steal_cnt);
if (job)
if (job) {
++d(self).number_of_steals;
return job;
}
}
if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration);
......
......@@ -101,6 +101,9 @@ public:
/// Applies given functor to all resumables attached to the coordinator.
template <class Coordinator, typename UnaryFunction>
void foreach_central_resumable(Coordinator* self, UnaryFunction f);
template <class Worker>
uint64_t get_number_of_steals(Worker* self);
};
} // namespace policy
......
......@@ -54,9 +54,11 @@ public:
template <class Worker>
struct worker_data {
explicit worker_data(scheduler::abstract_coordinator*) {
explicit worker_data(scheduler::abstract_coordinator*)
: number_of_steals(0) {
// nop
}
uint64_t number_of_steals;
};
// Create x workers.
......
......@@ -91,7 +91,8 @@ public:
// no need to worry about wrap-around; if `p->num_workers() < 2`,
// `uniform` will not be used anyway
, uniform(0, p->num_workers() - 2)
, strategies(get_poll_strategies(p)) {
, strategies(get_poll_strategies(p))
, number_of_steals(0) {
// nop
}
......@@ -102,6 +103,7 @@ public:
std::default_random_engine rengine;
std::uniform_int_distribution<size_t> uniform;
std::vector<poll_strategy> strategies;
uint64_t number_of_steals;
};
// Create x workers.
......@@ -180,8 +182,10 @@ public:
// try to steal every X poll attempts
if ((i % strat.steal_interval) == 0) {
job = try_steal(self);
if (job)
if (job) {
++d(self).number_of_steals;
return job;
}
}
if (strat.sleep_duration.count() > 0)
std::this_thread::sleep_for(strat.sleep_duration);
......@@ -204,6 +208,11 @@ public:
void foreach_central_resumable(Coordinator*, UnaryFunction) {
// nop
}
template <class Worker>
uint64_t get_number_of_steals(Worker* self) {
return d(self).number_of_steals;
}
};
} // namespace policy
......
......@@ -68,6 +68,7 @@ protected:
}
void stop() override {
uint64_t accumulated_number_of_steals = 0;
// shutdown workers
class shutdown_helper : public resumable, public ref_counted {
public:
......@@ -116,7 +117,9 @@ protected:
// wait until all workers are done
for (auto& w : data_.workers) {
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
auto f = &abstract_coordinator::cleanup_and_release;
for (auto& w : data_.workers)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment