Skip to content

Commit

Permalink
fix lci-pp: fix lci_progress_pool when there are multiple pus per core
Browse files Browse the repository at this point in the history
  • Loading branch information
JiakunYan committed Jan 11, 2024
1 parent 975dbc2 commit b6d8915
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,29 +210,30 @@ namespace hpx::traits {
hpx::threads::policies::scheduler_mode::
do_background_work_only);

size_t ncores_to_add =
size_t npus_to_add =
parcelset::policies::lci::config_t::progress_thread_num;
std::vector<const hpx::resource::core*> cores;
std::vector<const hpx::resource::pu*> pus;
for (auto& numa_domain : rp.numa_domains())
{
for (auto& core : numa_domain.cores())
{
cores.push_back(&core);
for (auto& pu : core.pus())
pus.push_back(&pu);
}
}
if (cores.size() <= 1)
if (pus.size() <= 1)
{
fprintf(stderr, "We don't have enough cores!\n");
fprintf(stderr, "We don't have enough pus!\n");
exit(1);
}
if ((size_t) ncores_to_add > cores.size() / 2)
if ((size_t) npus_to_add > pus.size() / 2)
{
ncores_to_add = cores.size() / 2;
npus_to_add = pus.size() / 2;
}
for (size_t i = 0; i < ncores_to_add; ++i)
for (size_t i = 0; i < npus_to_add; ++i)
{
size_t next_core = i * cores.size() / ncores_to_add;
rp.add_resource(*cores[next_core], "lci-progress-pool");
size_t next_pu = i * pus.size() / npus_to_add;
rp.add_resource(*pus[next_pu], "lci-progress-pool");
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions libs/full/parcelport_lci/src/parcelport_lci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,14 @@ namespace hpx::parcelset::policies::lci {
if (hpx::this_thread::get_pool() ==
&hpx::resource::get_thread_pool("lci-progress-pool"))
{
std::size_t prg_thread_id =
hpx::get_local_worker_thread_num();
double rate = (double) config_t::ndevices /
config_t::progress_thread_num;
for (int i = prg_thread_id * rate;
i < (prg_thread_id + 1) * rate; ++i)
int prg_thread_id =
static_cast<int>(hpx::get_local_worker_thread_num());
HPX_ASSERT(prg_thread_id < config_t::progress_thread_num);
for (int i = prg_thread_id * config_t::ndevices /
config_t::progress_thread_num;
i < (prg_thread_id + 1) * config_t::ndevices /
config_t::progress_thread_num;
++i)
{
devices_to_progress.push_back(&devices[i]);
}
Expand Down

0 comments on commit b6d8915

Please sign in to comment.