-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Description
The below Fortran program:
program gatherv_pfunit_1
use mpi
implicit none
! Context type to mimic pFUnit
type :: mpi_context
integer :: root
integer :: mpiCommunicator
end type mpi_context
type(mpi_context) :: this
integer :: ierr, rank, size, i, j, total
character(len=10), allocatable :: sendBuffer(:), recvBuffer(:)
integer, allocatable :: counts(:), displacements(:)
logical :: error
integer :: numEntries
! Initialize MPI
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
call MPI_Comm_size(MPI_COMM_WORLD, size, ierr)
! Set up context
this%root = 0
this%mpiCommunicator = MPI_COMM_WORLD
! Each process sends 'rank + 1' strings of length 10
numEntries = rank + 1
allocate(sendBuffer(numEntries))
do i = 1, numEntries
write(sendBuffer(i), '(A,I0)') 'proc', rank ! Dummy words: "proc0", "proc1", etc.
end do
! Allocate receive buffers on root
if (rank == this%root) then
allocate(counts(size))
allocate(displacements(size))
total = 0
do i = 0, size - 1
counts(i+1) = (i + 1) * 10 ! Number of characters from each process
displacements(i+1) = total
total = total + counts(i+1)
end do
allocate(recvBuffer(total / 10)) ! Total number of strings
recvBuffer = ''
else
allocate(counts(1), displacements(1), recvBuffer(1)) ! Dummy for non-root
end if
! Perform MPI_Gatherv as in pFUnit
call MPI_Gatherv(sendBuffer, numEntries * 10, MPI_CHARACTER, &
recvBuffer, counts, displacements, MPI_CHARACTER, &
this%root, this%mpiCommunicator, ierr)
! Verify results on root
error = .false.
if (rank == this%root) then
total = 0
do i = 0, size - 1
do j = 1, i + 1
if (trim(recvBuffer(total + j)) /= 'proc'//trim(adjustl(int2str(i)))) then
print *, "Error at rank ", i, " index ", j, &
": expected 'proc", i, "', got '", &
trim(recvBuffer(total + j)), "'"
error = .true.
end if
end do
total = total + i + 1
end do
if (.not. error) then
print *, "MPI_Gatherv pFUnit test passed on root"
end if
end if
! Clean up
deallocate(sendBuffer, recvBuffer, counts, displacements)
call MPI_Finalize(ierr)
if (error) stop 1
contains
! Helper function to convert integer to string
function int2str(i) result(str)
integer, intent(in) :: i
character(len=10) :: str
write(str, '(I0)') i
end function int2str
end program gatherv_pfunit_1
was sent as a test case in PR: #126, but it fails with LFortran with the below error:
(c_mpich_gfortran_env) gxyd@Gauravs-MacBook-Air fortran_mpi/tests (gatherv_char) » lfortran --version
LFortran version: 0.52.0-340-gf1e307e13-dirty
Platform: macOS ARM
LLVM: 11.1.0
Default target: arm64-apple-darwin24.5.0
(c_mpich_gfortran_env) gxyd@Gauravs-MacBook-Air fortran_mpi/tests (gatherv_char) » FC="/Users/gxyd/OpenSource/lfortran/src/bin/lfortran --cpp" ./run_tests.sh gatherv_2.f90
Removing all untracked files
#################################
Using FC=/Users/gxyd/OpenSource/lfortran/src/bin/lfortran --cpp compiler
Using CC=clang compiler
################################
Received argument(s). Will only compile/run: gatherv_2.f90
Compiling gatherv_2...
Running gatherv_2 with 1 MPI ranks...
MPI_Gatherv pFUnit test passed on root
Test gatherv_2 with 1 MPI ranks PASSED!
Running gatherv_2 with 2 MPI ranks...
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 76217 RUNNING AT Gauravs-MacBook-Air.local
= EXIT CODE: 11
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault: 11 (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
Test gatherv_2 with 2 MPI ranks FAILED!
(c_mpich_gfortran_env) gxyd@Gauravs-MacBook-Air fortran_mpi/tests (gatherv_char) » echo $? 1 ↵
1
we need to extract MRE from the above program and report it against LFortran.
Metadata
Metadata
Assignees
Labels
No labels