Skip to content

Commit de765d8

Browse files
author
Alexander Sannikov
committed
IMB-Output: Fixed int overflow message in case of operation with reduction
1 parent 35d7549 commit de765d8

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src_c/IMB_output.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,35 @@ enum output_format {
9696

9797
/*****************************************************************/
9898

99+
#ifdef MPI1
100+
static const char *red_data_type_msg = " use \"-red_data_type double\"";
101+
static const char *data_type_msg = " use \"-data_type double\"";
102+
static const char *generic_overflow_msg = " Stopping benchmark";
103+
static const char *get_overflow_message(struct Bench* Bmark, struct comm_info* c_info)
104+
{
105+
int dtsize;
106+
int double_size;
107+
int is_reduce;
108+
109+
MPI_Type_size(MPI_DOUBLE, &double_size);
110+
if (!strcmp(Bmark->name, "Allreduce")
111+
|| !strcmp(Bmark->name, "Reduce")
112+
|| !strcmp(Bmark->name, "Reduce_scatter")
113+
|| !strcmp(Bmark->name, "Reduce_scatter_block")
114+
|| !strcmp(Bmark->name, "Reduce_local")) {
115+
MPI_Type_size(c_info->red_data_type, &dtsize);
116+
is_reduce = 1;
117+
} else {
118+
MPI_Type_size(c_info->r_data_type, &dtsize);
119+
is_reduce = 0;
120+
}
121+
if (dtsize < double_size) {
122+
return is_reduce ? red_data_type_msg : data_type_msg;
123+
}
124+
return generic_overflow_msg;
99125

126+
}
127+
#endif
100128

101129
/* IMB 3.1 << */
102130
/*
@@ -342,11 +370,14 @@ Input variables:
342370
break;
343371

344372
case SAMPLE_FAILED_INT_OVERFLOW:
373+
aux_string[offset] = '\0';
345374
#ifdef MPI1
346-
sprintf(aux_string + offset, " int-overflow; The production rank*size caused int overflow; use \"-data_type double\"");
375+
fprintf(unit, "%s%s%s", aux_string, " int-overflow; The production rank*size caused int overflow;",
376+
get_overflow_message(Bmark, c_info));
347377
#else
348-
sprintf(aux_string + offset, " int-overflow; The production rank*size caused int overflow;");
378+
fprintf(unit, "%s%s", aux_string, " int-overflow; The production rank*size caused int overflow;");
349379
#endif
380+
aux_string[0] = '\0';
350381
break;
351382
case SAMPLE_FAILED_TIME_OUT:
352383
aux_string[offset] = '\0';

0 commit comments

Comments
 (0)