Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.

Problem with MPI_SCATTERV

danielsue
Beginner
1,218 Views

Hi All,

I ran into a problem with MPI_SCATTERV. When the sendcounts (scounts) is the same for every process, it works fine, but if the sendcounts is different, (e.g., 1, 2, 3, 4 for 4 processes) there will be error as follows:

Fatal error in PMPI_Scatterv: Message truncated, error stack:
PMPI_Scatterv(376)................: MPI_Scatterv(sbuf=0000000000000000, scnts=0000000000E16CD0, displs=0000000000E16CA0,
 MPI_INT, rbuf=0000000002BD0050, rcount=1, MPI_INT, root=0, MPI_COMM_WORLD) failed
MPIR_Scatterv_impl(187)...........:
MPIR_Scatterv(144)................:
MPIDI_CH3U_Receive_data_found(129): Message from rank 0 and tag 6 truncated; 16 bytes received but buffer size is 4
 

The code is simple as follows:

call MPI_SCATTERV(ja_in, scounts, displs, MPI_INT, ja, scounts, MPI_INT, 0, comm , ierr)

Thanks and regards,

Daniel

0 Kudos
2 Replies
danielsue
Beginner
1,218 Views

    program main
    
    use mpi    
    
    implicit none

    integer :: myid, numtasks, ierr
    integer, allocatable :: ia_in(:), ia(:), displs(:), scounts(:)
    
    call MPI_INIT ( ierr )
    call MPI_COMM_RANK ( MPI_COMM_WORLD , myid , ierr )
    call MPI_COMM_SIZE ( MPI_COMM_WORLD , numtasks , ierr )
    write(*,*) "size-rank:", numtasks, "-", myid
    
    if (myid == 0) then
        allocate(ia_in(100))
        do i = 1, size(ia_in, 1)
            ia_in(i) = i
        end do            
    end if
    
   
    allocate(displs(numtasks))
    allocate(scounts(numtasks))
    
    displs(1) = 0
    scounts(1) = 1
    do i = 2, numtasks
        scounts(i) = i
        displs(i) = displs(i-1) + scounts(i-1)
    end do
    
    write(*,*) ""
    
    allocate(ia(scounts(myid+1)))
    
    write(*,'(a, 4(x, i))') "myid, size displs, size scounts, size ia", myid, size(displs, 1), size(scounts, 1), size(ia, 1)
    
    !if scounts values are different, error in MPI_SCATTERV
    call MPI_SCATTERV(ia_in, scounts, displs, MPI_INT, ia, scounts, MPI_INT, 0, MPI_COMM_WORLD , ierr)
    
    call MPI_BARRIER(MPI_COMM_WORLD, ierr)

    call MPI_FINALIZE ( ierr )
    
    stop
    
    end program main

0 Kudos
danielsue
Beginner
1,218 Views

It works after I changed the recvcnt value to the scounts(rank+1).

0 Kudos
Reply