Skip to content

Commit b22e5fa

Browse files
committed
coll/han: refactor mca_coll_han_get_ranks function
Relax the function requirement to allow null low/up_rank output pointers, and rename the arguments because the function works for non-root ranks as well. Signed-off-by: Wenduo Wang <wenduwan@amazon.com>
1 parent 0353f7e commit b22e5fa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ompi/mca/coll/han/coll_han.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* reserved.
55
* Copyright (c) 2022 IBM Corporation. All rights reserved
66
* Copyright (c) 2020-2022 Bull S.A.S. All rights reserved.
7+
* Copyright (c) Amazon.com, Inc. or its affiliates.
8+
* All rights reserved.
79
* $COPYRIGHT$
810
*
911
* Additional copyrights may follow
@@ -432,11 +434,16 @@ int *mca_coll_han_topo_init(struct ompi_communicator_t *comm, mca_coll_han_modul
432434

433435
/* Utils */
434436
static inline void
435-
mca_coll_han_get_ranks(int *vranks, int root, int low_size,
436-
int *root_low_rank, int *root_up_rank)
437+
mca_coll_han_get_ranks(int *vranks, int w_rank, int low_size,
438+
int *low_rank, int *up_rank)
437439
{
438-
*root_up_rank = vranks[root] / low_size;
439-
*root_low_rank = vranks[root] % low_size;
440+
if (up_rank) {
441+
*up_rank = vranks[w_rank] / low_size;
442+
}
443+
444+
if (low_rank) {
445+
*low_rank = vranks[w_rank] % low_size;
446+
}
440447
}
441448

442449
const char* mca_coll_han_topo_lvl_to_str(TOPO_LVL_T topo_lvl);

0 commit comments

Comments
 (0)