From b8c2cc8aa5dd458f97ecdb084a6b887345e453c7 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Fri, 23 Feb 2024 13:58:43 -0500 Subject: [PATCH] Order broadcast keys so that we send to myrank+1 first Signed-off-by: Joseph Schuchart --- ttg/ttg/parsec/ttg.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ttg/ttg/parsec/ttg.h b/ttg/ttg/parsec/ttg.h index 1dcbd6878..2ba474305 100644 --- a/ttg/ttg/parsec/ttg.h +++ b/ttg/ttg/parsec/ttg.h @@ -2817,6 +2817,7 @@ ttg::abort(); // should not happen broadcast_arg(const ttg::span &keylist, const Value &value) { using valueT = std::tuple_element_t; 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(), @@ -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 */