Skip to content

Fortran: MPI_Alltoallw/MPI_Ialltoallw using MPI_IN_PLACE do not ignore sendtypes #5459

Closed
@geimer

Description

@geimer

According to the standard, MPI_Alltoallw and MPI_Ialltoallw should ignore the sendcounts, sdispls, and sendtypes arguments if sendbuf is MPI_IN_PLACE. Open MPI (tested with 3.0.0) takes this into account for sendcounts and sdispls, but not for sendtypes. This leads to a segmentation fault with the following test code:

PROGRAM main
    USE mpi
    IMPLICIT NONE

    INTEGER :: size
    INTEGER :: rank
    INTEGER :: ierr
    INTEGER :: i

    INTEGER, ALLOCATABLE :: recvbuf(:)
    INTEGER, ALLOCATABLE :: recvcounts(:)
    INTEGER, ALLOCATABLE :: recvdispls(:)
    INTEGER, ALLOCATABLE :: recvtypes(:)
    INTEGER, ALLOCATABLE :: NULL(:)

    CALL MPI_Init(ierr)
    CALL MPI_Comm_size(MPI_COMM_WORLD, size, ierr)
    CALL MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)

    ALLOCATE(recvbuf(size))
    ALLOCATE(recvcounts(size))
    ALLOCATE(recvdispls(size))
    ALLOCATE(recvtypes(size))
    DO i = 1, size
        recvcounts(i) = 1
        recvdispls(i) = i * (storage_size(recvbuf) / 8)
        recvtypes(i)  = MPI_INTEGER
        recvbuf(i)    = rank
    END DO

    CALL MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, &
                       recvbuf, recvcounts, recvdispls, recvtypes, &
                       MPI_COMM_WORLD, ierr)

    CALL MPI_Finalize(ierr)
END PROGRAM

It seems that the loops at

while (size > 0) {
c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]);
--size;
}
and
while (size > 0) {
c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]);
--size;
}
are the culprit.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions