|
4 | 4 | * reserved.
|
5 | 5 | * Copyright (c) 2020 Bull S.A.S. All rights reserved.
|
6 | 6 | * Copyright (c) 2022 IBM Corporation. All rights reserved
|
| 7 | + * Copyright (c) 2024 Computer Architecture and VLSI Systems (CARV) |
| 8 | + * Laboratory, ICS Forth. All rights reserved. |
7 | 9 | * $COPYRIGHT$
|
8 | 10 | *
|
9 | 11 | * Additional copyrights may follow
|
@@ -139,11 +141,18 @@ mca_coll_han_reduce_intra(const void *sbuf,
|
139 | 141 | "[%d]: root_low_rank %d root_up_rank %d\n", w_rank, root_low_rank,
|
140 | 142 | root_up_rank));
|
141 | 143 |
|
142 |
| - void *tmp_rbuf = rbuf; |
| 144 | + /* node leaders require a buffer to store intermediate results */ |
| 145 | + void *tmp_rbuf = NULL; |
143 | 146 | void *tmp_rbuf_to_free = NULL;
|
144 |
| - if (low_rank == root_low_rank && root_up_rank != up_rank) { |
145 |
| - /* allocate 2 segments on node leaders that are not the global root */ |
| 147 | + if (w_rank == root) { |
| 148 | + /* the global root already has one */ |
| 149 | + tmp_rbuf = rbuf; |
| 150 | + } else if (low_rank == root_low_rank) { |
| 151 | + /* allocate 2 temporary segments on node leaders that are not the global root */ |
146 | 152 | tmp_rbuf = malloc(2*extent*seg_count);
|
| 153 | + if (NULL == tmp_rbuf) { |
| 154 | + return OMPI_ERR_OUT_OF_RESOURCE; |
| 155 | + } |
147 | 156 | tmp_rbuf_to_free = tmp_rbuf;
|
148 | 157 | }
|
149 | 158 |
|
@@ -176,7 +185,7 @@ mca_coll_han_reduce_intra(const void *sbuf,
|
176 | 185 | t->sbuf = (char *) t->sbuf + extent * t->seg_count;
|
177 | 186 | }
|
178 | 187 |
|
179 |
| - if (up_rank == root_up_rank) { |
| 188 | + if (w_rank == root) { |
180 | 189 | t->rbuf = (char *) t->rbuf + extent * t->seg_count;
|
181 | 190 | }
|
182 | 191 | t->cur_seg = t->cur_seg + 1;
|
|
0 commit comments