Skip to content

Commit 30b6435

Browse files
authored
Merge pull request #6015 from aravindksg/proc-threshold-fix
MTL/OFI: Check threshold number of peers allowed per rank
2 parents 2805b8a + 5cf43de commit 30b6435

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

ompi/mca/mtl/ofi/mtl_ofi.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
5454
char *ep_names = NULL;
5555
fi_addr_t *fi_addrs = NULL;
5656
mca_mtl_ofi_endpoint_t *endpoint = NULL;
57+
int num_peers_limit = (1 << ompi_mtl_ofi.num_bits_source_rank) - 1;
5758

5859
namelen = ompi_mtl_ofi.epnamelen;
5960

61+
/* We cannot add more ranks than available tag bits */
62+
if ((false == ompi_mtl_ofi.fi_cq_data) &&
63+
OPAL_UNLIKELY(((int) (nprocs + ompi_mtl_ofi.num_peers) > num_peers_limit))) {
64+
opal_output(0, "%s:%d: OFI provider: %s does not have enough bits for source rank in its tag.\n"
65+
"Adding more ranks will result in undefined behaviour. Please enable\n"
66+
"FI_REMOTE_CQ_DATA feature in the provider. For more info refer fi_cq(3).\n",
67+
__FILE__, __LINE__, ompi_mtl_ofi.provider_name);
68+
fflush(stderr);
69+
ret = OMPI_ERROR;
70+
goto bail;
71+
}
72+
6073
/**
6174
* Create array of EP names.
6275
*/
@@ -126,6 +139,9 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
126139
procs[i]->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL] = endpoint;
127140
}
128141

142+
/* Update global counter of number of procs added to this rank */
143+
ompi_mtl_ofi.num_peers += nprocs;
144+
129145
ret = OMPI_SUCCESS;
130146

131147
bail:

ompi/mca/mtl/ofi/mtl_ofi_component.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "mtl_ofi.h"
1717
#include "opal/util/argv.h"
18-
#include "opal/util/show_help.h"
1918
#include "opal/util/printf.h"
2019

2120
static int ompi_mtl_ofi_component_open(void);
@@ -607,6 +606,7 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
607606

608607
/* Update the maximum supported Communicator ID */
609608
ompi_mtl_ofi.base.mtl_max_contextid = (int)((1ULL << ofi_tag_bits_for_cid) - 1);
609+
ompi_mtl_ofi.num_peers = 0;
610610

611611
/**
612612
* Open fabric
@@ -740,6 +740,8 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
740740
goto error;
741741
}
742742

743+
ompi_mtl_ofi.provider_name = strdup(prov->fabric_attr->prov_name);
744+
743745
/**
744746
* Free providers info since it's not needed anymore.
745747
*/

ompi/mca/mtl/ofi/mtl_ofi_endpoint.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ typedef struct mca_mtl_ofi_endpoint_t mca_mtl_ofi_endpoint_t;
4141
static inline mca_mtl_ofi_endpoint_t *ompi_mtl_ofi_get_endpoint (struct mca_mtl_base_module_t* mtl, ompi_proc_t *ompi_proc)
4242
{
4343
if (OPAL_UNLIKELY(NULL == ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL])) {
44-
ompi_mtl_ofi_add_procs(mtl, 1, &ompi_proc);
44+
if (OPAL_UNLIKELY(OMPI_SUCCESS != ompi_mtl_ofi_add_procs(mtl, 1, &ompi_proc))) {
45+
/* Fatal error. exit() out */
46+
opal_output(0, "%s:%d: *** The Open MPI OFI MTL is aborting the MPI job (via exit(3)).\n",
47+
__FILE__, __LINE__);
48+
fflush(stderr);
49+
exit(1);
50+
}
4551
}
4652

4753
return ompi_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_MTL];

ompi/mca/mtl/ofi/mtl_ofi_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct mca_mtl_ofi_module_t {
4343
/** "Any source" address */
4444
fi_addr_t any_addr;
4545

46-
/** Optional user-specified OFI provider name */
46+
/** OFI provider name */
4747
char *provider_name;
4848

4949
/** Maximum inject size */
@@ -61,6 +61,7 @@ typedef struct mca_mtl_ofi_module_t {
6161
unsigned long long source_rank_mask;
6262
unsigned long long mpi_tag_mask;
6363
int num_bits_mpi_tag;
64+
int num_peers;
6465

6566
/** Synchronous protocol tag bits */
6667
unsigned long long sync_send;

0 commit comments

Comments
 (0)