Skip to content

Commit 390c56b

Browse files
committed
ch4/ofi: fix the av table assumptions
Because we insert all remote endpoints to all local endpoints at the same time, thus follow the exact same insertion order, they will share the same av table index except for the local root endpoint because it has inserted other remote root endpoints at init time. The local root to remote non-root endpoints will have a fixed offset from that of local non-root.
1 parent f990be2 commit 390c56b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/mpid/ch4/netmod/ofi/ofi_pre.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,14 @@ typedef struct {
310310
/* Maximum number of network interfaces CH4 can support. */
311311
#define MPIDI_OFI_MAX_NICS 8
312312

313+
/* Imagine a dimension of [local_vci][local_nic][rank][vci][nic] -
314+
* all local endpoints will share the same remote address due to the same insertion order
315+
* and use of FI_AV_TABLE except the local root endpoint.
316+
*/
313317
typedef struct {
314-
fi_addr_t root_dest;
315-
fi_addr_t *all_dest; /* to be allocated into an array of [nic * vci] */
318+
fi_addr_t root_dest; /* [0][0][r][0][0] */
319+
fi_addr_t root_offset; /* [0][0][r][vci][nic] - [*][*][r][vci][nic] */
320+
fi_addr_t *all_dest; /* [*][*][r][vci][nic] */
316321
} MPIDI_OFI_addr_t;
317322

318323
#endif /* OFI_PRE_H_INCLUDED */

src/mpid/ch4/netmod/ofi/ofi_vci.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,13 @@ static int addr_exchange_all_ctx(MPIR_Comm * comm, int *all_num_vcis)
230230

231231
/* insert and store non-root nic/vci on the root context */
232232
for (int r = 0; r < nprocs; r++) {
233+
fi_addr_t expect_addr = FI_ADDR_NOTAVAIL;
234+
fi_addr_t root_offset = 0;
233235
GET_AV_AND_ADDRNAMES(r);
234236
/* for each remote endpoints */
235237
for (int nic = 0; nic < num_nics; nic++) {
236238
for (int vci = 0; vci < NUM_VCIS_FOR_RANK(r); vci++) {
237239
/* for each local endpoints */
238-
fi_addr_t expect_addr = FI_ADDR_NOTAVAIL;
239240
for (int nic_local = 0; nic_local < num_nics; nic_local++) {
240241
for (int vci_local = 0; vci_local < my_num_vcis; vci_local++) {
241242
/* skip root */
@@ -244,18 +245,28 @@ static int addr_exchange_all_ctx(MPIR_Comm * comm, int *all_num_vcis)
244245
}
245246
int ctx_idx = MPIDI_OFI_get_ctx_index(vci_local, nic_local);
246247
DO_AV_INSERT(ctx_idx, nic, vci);
247-
/* we expect all resulting addr to be the same */
248+
/* we expect all resulting addr to be the same except for local root endpoint, which
249+
* will have an offset */
248250
if (expect_addr == FI_ADDR_NOTAVAIL) {
249251
expect_addr = addr;
252+
} else if (nic_local == 0 && vci_local == 0) {
253+
if (root_offset == 0) {
254+
root_offset = addr - expect_addr;
255+
} else {
256+
MPIR_Assert(addr == expect_addr + root_offset);
257+
}
250258
} else {
251-
MPIR_Assert(expect_addr == addr);
259+
MPIR_Assert(addr == expect_addr);
252260
}
253261
}
254262
}
255263
MPIR_Assert(expect_addr != FI_ADDR_NOTAVAIL);
256-
MPIDI_OFI_AV_ADDR_NONROOT(av, vci, nic) = expect_addr;
264+
MPIDI_OFI_AV_ADDR_NO_OFFSET(av, vci, nic) = expect_addr;
265+
/* next */
266+
expect_addr++;
257267
}
258268
}
269+
MPIDI_OFI_AV(av).root_offset = root_offset;
259270
}
260271

261272
mpi_errno = MPIR_Barrier_fallback(comm, MPIR_ERR_NONE);

0 commit comments

Comments
 (0)