Skip to content

Commit

Permalink
Order broadcast keys so that we send to myrank+1 first
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Feb 23, 2024
1 parent c06654f commit b8c2cc8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ttg/ttg/parsec/ttg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2817,6 +2817,7 @@ ttg::abort(); // should not happen
broadcast_arg(const ttg::span<const Key> &keylist, const Value &value) {
using valueT = std::tuple_element_t<i, input_values_full_tuple_type>;
auto world = ttg_default_execution_context();
auto np = world.size();
int rank = world.rank();
uint64_t pos = 0;
bool have_remote = keylist.end() != std::find_if(keylist.begin(), keylist.end(),
Expand All @@ -2830,7 +2831,10 @@ ttg::abort(); // should not happen
std::sort(keylist_sorted.begin(), keylist_sorted.end(), [&](const Key &a, const Key &b) mutable {
int rank_a = keymap(a);
int rank_b = keymap(b);
return rank_a < rank_b;
// sort so that the keys for my rank are first, rank+1 next, ..., wrapping around to 0
int pos_a = (rank_a + np - rank) % np;
int pos_b = (rank_b + np - rank) % np;
return pos_a < pos_b;
});

/* Assuming there are no local keys, will be updated while iterating over the keys */
Expand Down

0 comments on commit b8c2cc8

Please sign in to comment.