Skip to content

Commit

Permalink
test: modify the error tests for user error handler
Browse files Browse the repository at this point in the history
It is not clear that after a MPI function calls the user error handler,
whether it should return MPI_SUCESS or not. Update the tests not to
assume the MPI will return the error code after invoking the error
handler.

Rationale: if user want the MPI function to return error code, they
should use MPI_ERRORS_RETURN instead. Otherwise, we assume the user
error handler "resolved" the error. User always can throw an exception
in their error handlers.
  • Loading branch information
hzhou committed Apr 10, 2024
1 parent 3efb577 commit 48c5d93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
30 changes: 9 additions & 21 deletions test/mpi/errors/f77/io/uerrhandf.f
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ program main
call mpi_comm_set_errhandler( wdup, comm_errh, ierr )
call mpi_comm_size( wdup, wdsize, ierr )
call mpi_send( id, 1, MPI_INTEGER, wdsize, -37, wdup, ierr )
if (ierr .eq. MPI_SUCCESS) then
print *, ' Failed to detect error in use of MPI_SEND'
C NOTE: ierr may be MPI_SUCCESS but handler should be invoked
if (iseen(1) .ne. 1) then
errs = errs + 1
else
if (iseen(1) .ne. 1) then
errs = errs + 1
print *, ' Failed to increment comm error counter'
endif
print *, ' Failed to increment comm error counter'
endif

asize = 2*sizeofint
Expand All @@ -68,14 +64,10 @@ program main
asize = 0
call mpi_put( winbuf, 1, MPI_INT, wdsize, asize, 1, MPI_INT, winh,
$ ierr )
if (ierr .eq. MPI_SUCCESS) then
print *, ' Failed to detect error in use of MPI_PUT'
C NOTE: ierr may be MPI_SUCCESS but handler should be invoked
if (iseen(3) .ne. 1) then
errs = errs + 1
else
if (iseen(3) .ne. 1) then
errs = errs + 1
print *, ' Failed to increment win error counter'
endif
print *, ' Failed to increment win error counter'
endif

call mpi_file_open( MPI_COMM_SELF, 'ftest', MPI_MODE_CREATE +
Expand All @@ -89,14 +81,10 @@ program main
offset = -100
call mpi_file_read_at( fh, offset, winbuf, 1, MPI_INTEGER, status,
$ ierr )
if (ierr .eq. MPI_SUCCESS) then
print *, ' Failed to detect error in use of MPI_PUT'
C NOTE: ierr may be MPI_SUCCESS but handler should be invoked
if (iseen(2) .ne. 1) then
errs = errs + 1
else
if (iseen(2) .ne. 1) then
errs = errs + 1
print *, ' Failed to increment file error counter'
endif
print *, ' Failed to increment file error counter'
endif

call mpi_comm_free( wdup, ierr )
Expand Down
5 changes: 1 addition & 4 deletions test/mpi/errors/session/comm_create_from_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@ int main(int argc, char *argv[])
}

/* try to get a communicator with NULL comm as arg */
/* NOTE: the rc may be MPI_SUCCESS here but the errhandler should be invoked */
rc = MPI_Comm_create_from_group(ghandle, "org.mpi-forum.mpi-v4_0.example-ex10_8",
MPI_INFO_NULL, errhandler, NULL);
if (rc == MPI_SUCCESS) {
errs++;
goto fn_exit;
}

/* get a communicator */
rc = MPI_Comm_create_from_group(ghandle, "org.mpi-forum.mpi-v4_0.example-ex10_8",
Expand Down

0 comments on commit 48c5d93

Please sign in to comment.