Commit 7bd8ef7f authored by Sebastian Woelke's avatar Sebastian Woelke

Add output which shows the number of steals

parent 2fa81bb4
...@@ -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);
......
...@@ -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
......
...@@ -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.
......
...@@ -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
......
...@@ -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)
......
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