Skip to content

Commit 838889b

Browse files
author
Luke Robison
committed
mtl/ofi: Fix EP name length bug for fi_av_insert()
This change removes the (invalid) assumption that all ep_names will be the same length. Rather than pre-allocating a list of all names, and then inserting them all later, we instead just insert each name as we retrieve it from modex. Signed-off-by: Luke Robison <[email protected]>
1 parent 479c746 commit 838889b

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

ompi/mca/mtl/ofi/mtl_ofi.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
227227
size_t namelen;
228228
int count = 0;
229229
char *ep_name = NULL;
230-
char *ep_names = NULL;
231230
fi_addr_t *fi_addrs = NULL;
232231
mca_mtl_ofi_endpoint_t *endpoint = NULL;
233232
int num_peers_limit = (1 << ompi_mtl_ofi.num_bits_source_rank) - 1;
@@ -246,15 +245,6 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
246245
goto bail;
247246
}
248247

249-
/**
250-
* Create array of EP names.
251-
*/
252-
ep_names = malloc(nprocs * namelen);
253-
if (NULL == ep_names) {
254-
ret = OMPI_ERROR;
255-
goto bail;
256-
}
257-
258248
/**
259249
* Create array of fi_addrs.
260250
*/
@@ -264,10 +254,10 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
264254
goto bail;
265255
}
266256

267-
/**
268-
* Retrieve the processes' EP names from modex.
269-
*/
270257
for (i = 0; i < nprocs; ++i) {
258+
/**
259+
* Retrieve the processes' EP name from modex.
260+
*/
271261
OFI_COMPAT_MODEX_RECV(ret,
272262
&mca_mtl_ofi_component.super.mtl_version,
273263
procs[i],
@@ -281,19 +271,18 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
281271
free(errhost);
282272
goto bail;
283273
}
284-
memcpy(&ep_names[i*namelen], ep_name, namelen);
285-
}
286274

287-
/**
288-
* Map the EP names to fi_addrs.
289-
*/
290-
count = fi_av_insert(ompi_mtl_ofi.av, ep_names, nprocs, fi_addrs, 0, NULL);
291-
if ((count < 0) || (nprocs != (size_t)count)) {
292-
opal_output_verbose(1, opal_common_ofi.output,
293-
"%s:%d: fi_av_insert failed: %d\n",
294-
__FILE__, __LINE__, count);
295-
ret = OMPI_ERROR;
296-
goto bail;
275+
/**
276+
* Map the EP name to fi_addr.
277+
*/
278+
count = fi_av_insert(ompi_mtl_ofi.av, ep_name, 1, &fi_addrs[i], 0, NULL);
279+
if ((count < 0) || (1 != (size_t)count)) {
280+
opal_output_verbose(1, opal_common_ofi.output,
281+
"%s:%d: fi_av_insert failed for address %s: %d\n",
282+
__FILE__, __LINE__, ep_name, count);
283+
ret = OMPI_ERROR;
284+
goto bail;
285+
}
297286
}
298287

299288
/**
@@ -326,9 +315,6 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
326315
if (fi_addrs)
327316
free(fi_addrs);
328317

329-
if (ep_names)
330-
free(ep_names);
331-
332318
return ret;
333319
}
334320

0 commit comments

Comments
 (0)