Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 8186b6b

Browse files
committed
mtl/ofi: Fix dynamic add_procs.
(cherry-picked from open-mpi/ompi@b3d8ead)
1 parent 81f5f89 commit 8186b6b

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

ompi/mca/mtl/ofi/mtl_ofi.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ BEGIN_C_DECLS
5151
extern mca_mtl_ofi_module_t ompi_mtl_ofi;
5252
extern mca_base_framework_t ompi_mtl_base_framework;
5353

54-
extern int ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
55-
size_t nprocs,
56-
struct ompi_proc_t **procs);
57-
5854
extern int ompi_mtl_ofi_del_procs(struct mca_mtl_base_module_t *mtl,
5955
size_t nprocs,
6056
struct ompi_proc_t **procs);
@@ -236,7 +232,7 @@ ompi_mtl_ofi_send_start(struct mca_mtl_base_module_t *mtl,
236232
ompi_mtl_ofi_request_t *ack_req = NULL; /* For synchronous send */
237233

238234
ompi_proc = ompi_comm_peer_lookup(comm, dest);
239-
endpoint = ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
235+
endpoint = ompi_mtl_ofi_get_endpoint(mtl, ompi_proc);
240236

241237
ompi_ret = ompi_mtl_datatype_pack(convertor, &start, &length, &free_after);
242238
if (OMPI_SUCCESS != ompi_ret) return ompi_ret;
@@ -461,7 +457,7 @@ ompi_mtl_ofi_recv_callback(struct fi_cq_tagged_entry *wc,
461457
if (ompi_mtl_ofi.any_addr == ofi_req->remote_addr) {
462458
src = MTL_OFI_GET_SOURCE(wc->tag);
463459
ompi_proc = ompi_comm_peer_lookup(ofi_req->comm, src);
464-
endpoint = ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
460+
endpoint = ompi_mtl_ofi_get_endpoint(ofi_req->mtl, ompi_proc);
465461
ofi_req->remote_addr = endpoint->peer_fiaddr;
466462
}
467463
MTL_OFI_RETRY_UNTIL_DONE(fi_tsend(ompi_mtl_ofi.ep,
@@ -533,7 +529,7 @@ ompi_mtl_ofi_irecv(struct mca_mtl_base_module_t *mtl,
533529

534530
if (MPI_ANY_SOURCE != src) {
535531
ompi_proc = ompi_comm_peer_lookup(comm, src);
536-
endpoint = ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
532+
endpoint = ompi_mtl_ofi_get_endpoint(mtl, ompi_proc);
537533
remote_addr = endpoint->peer_fiaddr;
538534
} else {
539535
remote_addr = ompi_mtl_ofi.any_addr;
@@ -745,7 +741,7 @@ ompi_mtl_ofi_iprobe(struct mca_mtl_base_module_t *mtl,
745741
*/
746742
if (MPI_ANY_SOURCE != src) {
747743
ompi_proc = ompi_comm_peer_lookup( comm, src );
748-
endpoint = ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
744+
endpoint = ompi_mtl_ofi_get_endpoint(mtl, ompi_proc);
749745
remote_proc = endpoint->peer_fiaddr;
750746
}
751747

@@ -830,7 +826,7 @@ ompi_mtl_ofi_improbe(struct mca_mtl_base_module_t *mtl,
830826
*/
831827
if (MPI_ANY_SOURCE != src) {
832828
ompi_proc = ompi_comm_peer_lookup( comm, src );
833-
endpoint = ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
829+
endpoint = ompi_mtl_ofi_get_endpoint(mtl, ompi_proc);
834830
remote_proc = endpoint->peer_fiaddr;
835831
}
836832

@@ -962,7 +958,6 @@ ompi_mtl_ofi_del_comm(struct mca_mtl_base_module_t *mtl,
962958
return OMPI_SUCCESS;
963959
}
964960

965-
966961
END_C_DECLS
967962

968963
#endif /* MTL_OFI_H_HAS_BEEN_INCLUDED */

ompi/mca/mtl/ofi/mtl_ofi_endpoint.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#ifndef OMPI_MTL_OFI_ENDPOINT_H
1212
#define OMPI_MTL_OFI_ENDPOINT_H
1313

14-
#include "mtl_ofi.h"
15-
1614
BEGIN_C_DECLS
1715

16+
extern int ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
17+
size_t nprocs,
18+
struct ompi_proc_t **procs);
19+
1820
OBJ_CLASS_DECLARATION(mca_mtl_ofi_endpoint_t);
1921

2022
/**
@@ -37,5 +39,14 @@ struct mca_mtl_ofi_endpoint_t {
3739
typedef struct mca_mtl_ofi_endpoint_t mca_mtl_ofi_endpoint_t;
3840
OBJ_CLASS_DECLARATION(mca_mtl_ofi_endpoint);
3941

42+
static inline mca_mtl_ofi_endpoint_t *ompi_mtl_ofi_get_endpoint (struct mca_mtl_base_module_t* mtl, ompi_proc_t *ompi_proc)
43+
{
44+
if (OPAL_UNLIKELY(NULL == ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL])) {
45+
ompi_mtl_ofi_add_procs(mtl, 1, &ompi_proc);
46+
}
47+
48+
return ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];
49+
}
50+
4051
END_C_DECLS
4152
#endif

ompi/mca/mtl/ofi/mtl_ofi_request.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ struct ompi_mtl_ofi_request_t {
5555
/* lookup source of an ANY_SOURCE Recv */
5656
struct ompi_communicator_t *comm;
5757

58+
/** Reference to the MTL used to lookup */
59+
/* source of an ANY_SOURCE Recv */
60+
struct mca_mtl_base_module_t* mtl;
61+
5862
/** Pack buffer */
5963
void *buffer;
6064

0 commit comments

Comments
 (0)