Skip to content

Commit 16e410d

Browse files
committed
comm_split_type: Improve error message reported
Signed-off-by: Joshua Hursey <[email protected]> (cherry picked from commit 6ddcc58)
1 parent 44c2486 commit 16e410d

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

ompi/communicator/comm.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "opal/mca/threads/mutex.h"
4747
#include "opal/util/bit_ops.h"
4848
#include "opal/util/output.h"
49+
#include "opal/util/show_help.h"
4950
#include "ompi/mca/topo/topo.h"
5051
#include "ompi/mca/topo/base/base.h"
5152
#include "ompi/dpm/dpm.h"
@@ -79,6 +80,21 @@ static const ompi_comm_split_type_hw_guided_t ompi_comm_split_type_hw_guided_sup
7980
{.info_value = NULL},
8081
};
8182

83+
static const char * ompi_comm_split_type_to_str(int split_type) {
84+
for (int i = 0; NULL != ompi_comm_split_type_hw_guided_support[i].info_value; ++i) {
85+
if (split_type == ompi_comm_split_type_hw_guided_support[i].split_type) {
86+
return ompi_comm_split_type_hw_guided_support[i].info_value;
87+
}
88+
}
89+
if (MPI_COMM_TYPE_HW_GUIDED == split_type) {
90+
return "MPI_COMM_TYPE_HW_GUIDED";
91+
}
92+
else if (MPI_COMM_TYPE_HW_UNGUIDED == split_type) {
93+
return "MPI_COMM_TYPE_HW_UNGUIDED";
94+
}
95+
return "Unknown";
96+
}
97+
8298
/*
8399
** sort-function for MPI_Comm_split
84100
*/
@@ -793,7 +809,11 @@ static int ompi_comm_split_type_get_part (ompi_group_t *group, const int split_t
793809
* We should not get here as the split type will be changed
794810
* at a higher level.
795811
*/
796-
opal_output(0, "Error: in ompi_comm_split_type_get_part() unexpected split_type=%d", split_type);
812+
opal_show_help("help-comm.txt",
813+
"unexpected-split-type",
814+
true,
815+
ompi_comm_split_type_to_str(split_type),
816+
split_type);
797817
return OMPI_ERR_BAD_PARAM;
798818
}
799819

@@ -871,6 +891,8 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key,
871891
int global_split_type, global_orig_split_type, ok[2], tmp[6];
872892
int rc;
873893
int orig_split_type = split_type;
894+
int flag;
895+
opal_cstring_t *value = NULL;
874896

875897
/* silence clang warning. newcomm should never be NULL */
876898
if (OPAL_UNLIKELY(NULL == newcomm)) {
@@ -881,9 +903,6 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key,
881903

882904
/* Step 0: Convert MPI_COMM_TYPE_HW_GUIDED to the internal type */
883905
if (MPI_COMM_TYPE_HW_GUIDED == split_type) {
884-
int flag;
885-
opal_cstring_t *value = NULL;
886-
887906
opal_info_get(info, "mpi_hw_resource_type", &value, &flag);
888907
/* If key is not in the 'info', then return MPI_COMM_NULL.
889908
* This is caught at the MPI interface level, but it doesn't hurt to
@@ -963,11 +982,16 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key,
963982

964983
if (OPAL_UNLIKELY(!ok[0] || !ok[1])) {
965984
if (0 == ompi_comm_rank(comm)) {
966-
if (!ok[1]) {
967-
opal_output(0, "Error: Mismatched info values for MPI_COMM_TYPE_HW_GUIDED");
968-
} else {
969-
opal_output(0, "Error: Mismatched info values for split_type");
985+
opal_info_get(info, "mpi_hw_resource_type", &value, &flag);
986+
if (!flag) {
987+
value = NULL;
970988
}
989+
opal_show_help("help-comm.txt",
990+
"mismatched-split_type-values",
991+
true,
992+
ompi_comm_split_type_to_str(orig_split_type),
993+
orig_split_type,
994+
NULL == value ? "" : value->string);
971995
}
972996
return OMPI_ERR_BAD_PARAM;
973997
}

ompi/communicator/help-comm.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ Comments
2626
MPI_Info_set warning, key is using a reserved prefix.
2727
Key: %s
2828
Reserved prefix: %s
29+
[mismatched-split_type-values]
30+
Detected mismatched split_type and/or info "mpi_hw_resource_type" values
31+
in a call to MPI_Comm_split_type between peers in the communicator.
32+
split_type: %s (%d)
33+
info: %s

0 commit comments

Comments
 (0)