Skip to content

Commit 4700284

Browse files
committed
ch4/ofi: use actual size in MPIDI_OFI_get_local_upids
Use the actual name size in MPIDI_OFI_get_local_upids rather than assume libfabric always use the same addrname length. This makes the code more robust. For example, if we ever accept dynamic processes from hybrid systems, then they may use different provider and different addr format.
1 parent 42f20cb commit 4700284

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ int MPIDI_OFI_get_local_upids(MPIR_Comm * comm, int **local_upid_size, char **lo
253253
hostname = utarray_eltptr(MPIR_Process.node_hostnames, node_id);
254254
hostname_len = strlen(hostname);
255255
}
256-
int upid_len = hostname_len + 1 + MPIDI_OFI_global.addrnamelen;
257-
if (idx + upid_len > buf_size) {
256+
if (idx + hostname_len + 1 + FI_NAME_MAX > buf_size) {
258257
buf_size += 1024;
259258
temp_buf = MPL_realloc(temp_buf, buf_size, MPL_MEM_OTHER);
260259
MPIR_Assert(temp_buf);
@@ -263,13 +262,13 @@ int MPIDI_OFI_get_local_upids(MPIR_Comm * comm, int **local_upid_size, char **lo
263262
strcpy(temp_buf + idx, hostname);
264263
idx += hostname_len + 1;
265264

266-
size_t sz = MPIDI_OFI_global.addrnamelen;;
265+
size_t sz = FI_NAME_MAX;
267266
MPIDI_av_entry_t *av = MPIDIU_comm_rank_to_av(comm, i);
268267
MPIDI_OFI_CALL(fi_av_lookup(MPIDI_OFI_global.ctx[ctx_idx].av,
269268
MPIDI_OFI_AV_ADDR_ROOT(av), temp_buf + idx, &sz), avlookup);
270269
idx += (int) sz;
271270

272-
(*local_upid_size)[i] = upid_len;
271+
(*local_upid_size)[i] = hostname_len + 1 + sz;
273272
}
274273

275274
*local_upids = temp_buf;

0 commit comments

Comments
 (0)