Skip to content

Commit

Permalink
break loop when encountering first error
Browse files Browse the repository at this point in the history
stop checking collectively when error occurs in one of processes
break 2nd loop when encountering first error
  • Loading branch information
wkliao committed Nov 26, 2024
1 parent 30834bc commit a6fe2f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/testcases/flexible.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,j+rank+10,buf[j][i]);
nerrs++;
j = NY;
break;
}

Expand All @@ -147,6 +148,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,j+rank+10,buf[j][i]);
nerrs++;
j = NY;
break;
}

Expand All @@ -169,10 +171,12 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,j+rank+10,schar_buf[j*NX+i]);
nerrs++;
j = NY;
break;
}

for (j=0; j<NY; j++) for (i=0; i<NX; i++) schar_buf[j*NX+i] = -1;

err = ncmpi_get_vara_all(ncid, varid3, start, count, schar_buf+NX, 1, buftype); CHECK_ERR

/* check read contents */
Expand All @@ -181,6 +185,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,j+rank+10,schar_buf[j*NX+i]);
nerrs++;
j = NY;
break;
}

Expand Down Expand Up @@ -259,6 +264,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,buf[j][i],getValue);
nerrs++;
j = (int)count[0];
break;
}
}
Expand All @@ -272,6 +278,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,buf[j][i],getValue);
nerrs++;
j = (int)count[0];
break;
}
}
Expand All @@ -288,6 +295,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,buf[j][i],getValue);
nerrs++;
j = (int)count[0];
break;
}
}
Expand All @@ -304,6 +312,7 @@ int main(int argc, char **argv) {
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
__FILE__,__LINE__,j,i,buf[j][i],getValue);
nerrs++;
j = (int)count[0];
break;
}
}
Expand Down
5 changes: 4 additions & 1 deletion test/testcases/tst_vars_fill.m4
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test_vars_$1(char *filename)
{
char var_name[32];
int i, j, k, nprocs, rank, err, nerrs=0, ncid, dimid[2], varid[NVARS];
int max_nerrs;
MPI_Offset start[2], count[2], stride[2];
$1 buf[NY][NX];

Expand Down Expand Up @@ -123,9 +124,11 @@ test_vars_$1(char *filename)
}
}
}
fn_exit:
MPI_Allreduce(&nerrs, &max_nerrs, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
if (max_nerrs > 0) break;
}

fn_exit:
err = ncmpi_close(ncid); CHECK_ERR
return nerrs;
}
Expand Down

0 comments on commit a6fe2f1

Please sign in to comment.