Skip to content

Commit

Permalink
[HOTFIX] Quick fix for occasional crashes in MPL_ALLTOALLV with an ex…
Browse files Browse the repository at this point in the history
…tra MPI_WAIT (#29)

This actually reverts the async scenario to sync.
Further development will properly provide async.
  • Loading branch information
a-v-medvedev authored Nov 5, 2024
1 parent bec7c06 commit e9249da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/fiat/mpl/internal/mpl_alltoallv_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MODULE MPL_ALLTOALLV_MOD
USE MPL_DATA_MODULE
USE MPL_MESSAGE_MOD
USE MPL_STATS_MOD
USE MPL_WAIT_MOD
USE YOMMPLSTATS

IMPLICIT NONE
Expand Down Expand Up @@ -218,6 +219,8 @@ SUBROUTINE MPL_ALLTOALLV_REAL8(PSENDBUF,KSENDCOUNTS,PRECVBUF,KRECVCOUNTS,&
CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: CDSTRING
INTEGER(KIND=JPIM),INTENT(OUT),OPTIONAL :: KREQUEST,KERROR

!! FIXME: the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine!
!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
INTEGER(KIND=JPIM) :: IRECVDISPL(MPL_NUMPROC),ISENDDISPL(MPL_NUMPROC)

ISENDCOUNT=SIZE(PSENDBUF)
Expand Down Expand Up @@ -251,6 +254,11 @@ SUBROUTINE MPL_ALLTOALLV_REAL8(PSENDBUF,KSENDCOUNTS,PRECVBUF,KRECVCOUNTS,&
IF(.NOT.PRESENT(KREQUEST)) CALL MPL_MESSAGE(KERROR,'MPL_ALLTOALLV',' KREQUEST MISSING',LDABORT=LLABORT)
CALL MPI_IALLTOALLV(PSENDBUF(:),KSENDCOUNTS,ISENDDISPL,INT(MPI_REAL8), &
& PRECVBUF(:),KRECVCOUNTS,IRECVDISPL,INT(MPI_REAL8),ICOMM,KREQUEST,IERROR)
!!! FIXME since the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine
!!! we have to complete MPI_WAIT right in place
!!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
CALL MPL_WAIT(KREQUEST)
KREQUEST=MPI_REQUEST_NULL
ELSE
IF(PRESENT(KERROR)) THEN
IERROR=1
Expand Down Expand Up @@ -291,6 +299,8 @@ SUBROUTINE MPL_ALLTOALLV_REAL4(PSENDBUF,KSENDCOUNTS,PRECVBUF,KRECVCOUNTS,&
CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: CDSTRING
INTEGER(KIND=JPIM),INTENT(OUT),OPTIONAL :: KREQUEST,KERROR

!! FIXME: the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine!
!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
INTEGER(KIND=JPIM) :: IRECVDISPL(MPL_NUMPROC),ISENDDISPL(MPL_NUMPROC)

ISENDCOUNT=SIZE(PSENDBUF)
Expand Down Expand Up @@ -321,6 +331,11 @@ SUBROUTINE MPL_ALLTOALLV_REAL4(PSENDBUF,KSENDCOUNTS,PRECVBUF,KRECVCOUNTS,&
ELSEIF(IMP_TYPE == JP_NON_BLOCKING_STANDARD .OR. IMP_TYPE == JP_NON_BLOCKING_BUFFERED) THEN
CALL MPI_IALLTOALLV(PSENDBUF(:),KSENDCOUNTS,ISENDDISPL,INT(MPI_REAL4), &
& PRECVBUF(:),KRECVCOUNTS,IRECVDISPL,INT(MPI_REAL4),ICOMM,KREQUEST,IERROR)
!!! FIXME since the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine
!!! we have to complete MPI_WAIT right in place
!!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
CALL MPL_WAIT(KREQUEST)
KREQUEST=MPI_REQUEST_NULL
ELSE
IF(PRESENT(KERROR)) THEN
IERROR=1
Expand Down Expand Up @@ -362,6 +377,8 @@ SUBROUTINE MPL_ALLTOALLV_INTEGER(KSENDBUF,KSENDCOUNTS,KRECVBUF,KRECVCOUNTS,&
CHARACTER(LEN=*),INTENT(IN),OPTIONAL :: CDSTRING
INTEGER(KIND=JPIM),INTENT(OUT),OPTIONAL :: KREQUEST,KERROR

!! FIXME: the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine!
!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
INTEGER(KIND=JPIM) :: IRECVDISPL(MPL_NUMPROC),ISENDDISPL(MPL_NUMPROC)

ISENDCOUNT=SIZE(KSENDBUF)
Expand Down Expand Up @@ -393,6 +410,11 @@ SUBROUTINE MPL_ALLTOALLV_INTEGER(KSENDBUF,KSENDCOUNTS,KRECVBUF,KRECVCOUNTS,&
IF(.NOT.PRESENT(KREQUEST)) CALL MPL_MESSAGE(KERROR,'MPL_ALLTOALLV',' KREQUEST MISSING',LDABORT=LLABORT)
CALL MPI_IALLTOALLV(KSENDBUF(1),KSENDCOUNTS,ISENDDISPL,INT(MPI_INTEGER), &
& KRECVBUF(1),KRECVCOUNTS,IRECVDISPL,INT(MPI_INTEGER),ICOMM,KREQUEST,IERROR)
!!! FIXME since the lifetime of IRECVDISPL and ISENDDISPL is limited to this routine
!!! we have to complete MPI_WAIT right in place
!!! Details: https://github.com/ecmwf-ifs/fiat/issues/17
CALL MPL_WAIT(KREQUEST)
KREQUEST=MPI_REQUEST_NULL
ELSE
IF(PRESENT(KERROR)) THEN
IERROR=1
Expand Down

0 comments on commit e9249da

Please sign in to comment.