Commit 08d5124f authored by a-chmil's avatar a-chmil
Browse files

changed steal communication strategy

parent 4d5bf3e8
......@@ -5,6 +5,7 @@
constexpr unsigned int
DEFAULT_WORKER_THREADS_COUNT=4,
DEFAULT_STEAL_PROC_COUNT=2,
DEFAULT_COMM_REQUEST_THREADS_COUNT=1,
DEFAULT_COMM_RECEIVE_THREADS_COUNT=1;
......@@ -31,6 +32,7 @@ public:
std::string get_version() const;
bool dynamic_balance() const;
unsigned int get_steal_proc_count() const noexcept;
unsigned int get_worker_threads_count() const noexcept;
unsigned int get_comm_request_threads_count() const noexcept;
unsigned int get_comm_recv_threads_count() const noexcept;
......
......@@ -59,7 +59,7 @@ public:
int get_steal_req();
void steal_req(int tag);
void steal_req(int tag, unsigned int proc_count);
void change_load(int delta) {
stopper_->change_works(delta);
......
......@@ -96,6 +96,10 @@ bool Config::dynamic_balance() const
return dynamic_balance_;
}
unsigned int Config::get_steal_proc_count() const noexcept {
return DEFAULT_STEAL_PROC_COUNT;
}
unsigned int Config::get_worker_threads_count() const noexcept
{
return DEFAULT_WORKER_THREADS_COUNT;
......
......@@ -40,17 +40,18 @@ RTS::RTS(Comm &comm, const Config &conf, const FP &fp)
);
if(conf.dynamic_balance()) {
pool_.on_empty([this]() {
unsigned int proc_count = conf_->get_steal_proc_count();
pool_.on_empty([this, proc_count]() {
if (!need_jobs_) {
need_jobs_ = true;
steal_req(TAG_STEAL);
steal_req(TAG_STEAL, proc_count);
}
});
pool_.on_submit([this]() {
pool_.on_submit([this, proc_count]() {
if (need_jobs_) {
need_jobs_ = false;
steal_req(TAG_STEAL_REVOKE);
steal_req(TAG_STEAL_REVOKE, proc_count);
}
});
}
......@@ -322,9 +323,16 @@ void RTS::unexpect_pushes(const Id &cfid)
waiters_.erase(it);
}
void RTS::steal_req(int tag)
void RTS::steal_req(int tag, unsigned int proc_count)
{
comm_->bcast(tag);
if(comm_->size() - 1 >= proc_count) {
comm_->bcast(tag);
} else {
int rank = comm_->rank;
for(int i = 0; i < proc_count; i++) {
comm_->send((i+rank)%size(), tag, nullptr, 0);
}
}
}
int RTS::get_steal_req()
......
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