Skip to content

LFortran fails with MPI_BCast test program #63

@adit4443ya

Description

@adit4443ya

MRE

program test_bcast
    use mpi 
    implicit none

    integer :: ierror, rank, size, comm, root, n, i
    real(8), allocatable :: arr(:,:)
    comm = MPI_COMM_WORLD

    ! Initialize MPI
    call MPI_Init(ierror)

    ! Get our rank and the total number of processes
    call MPI_Comm_rank(comm, rank, ierror)
    call MPI_Comm_size(comm, size, ierror)

    ! Decide how large an array to broadcast
    n = 5
    allocate(arr(n,n))

    ! Only the root (rank=0) initializes the data
    root = 0
    if (rank == root) then
        arr = reshape([(i, i=1,n*n)], shape=[n, n])  ! Initialize as a 2D array
    else
        arr = -999  ! fill with dummy values to see if Bcast overwrites them
    end if

    ! Broadcast the array from root=0 to all processes
    call MPI_Bcast(arr, n, MPI_REAL8, root, comm, ierror)
    if (ierror /= MPI_SUCCESS) then
        print *, "Error in MPI_Bcast:", ierror
    end if

    ! Print result on each rank
    print *, "Rank=", rank, " received arr=", arr

    ! Finalize MPI
    call MPI_Finalize(ierror)
end program test_bcast
 aditya-trivedi   tests    bcast ≢  ~1    FC='lfortran' ./run_tests.sh bcast_1.f90 
Received argument(s). Will only compile/run: bcast_1.f90
Compiling bcast_1...
Running bcast_1 with 1 MPI ranks...
[Observer:367469:0:367469] Caught signal 11 (Segmentation fault: Sent by the kernel at address (nil))
==== backtrace (tid: 367469) ====
 0  /home/aditya-trivedi/conda_root/envs/mpich/lib/./libucs.so.0(ucs_handle_error+0x305) [0x713a5bcc6015]
 1  /home/aditya-trivedi/conda_root/envs/mpich/lib/./libucs.so.0(+0x2f214) [0x713a5bcc6214]
 2  /home/aditya-trivedi/conda_root/envs/mpich/lib/./libucs.so.0(+0x2f3da) [0x713a5bcc63da]
 3  /lib/x86_64-linux-gnu/libc.so.6(+0x45330) [0x713a5aa45330]
 4  ./bcast_1(+0x24ab) [0x5f81a07674ab]
 5  /lib/x86_64-linux-gnu/libc.so.6(+0x2a1ca) [0x713a5aa2a1ca]
 6  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x8b) [0x713a5aa2a28b]
 7  ./bcast_1(+0x1215) [0x5f81a0766215]
=================================

===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   PID 367469 RUNNING AT Observer
=   EXIT CODE: 139
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
Test bcast_1 with 1 MPI ranks FAILED!
 aditya-trivedi   tests    bcast ≢  ?1 ~2    FC='gfortran' ./run_tests.sh bcast_1.f90 
Received argument(s). Will only compile/run: bcast_1.f90
Compiling bcast_1...
Running bcast_1 with 1 MPI ranks...
 Rank=           0  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000        6.0000000000000000        7.0000000000000000        8.0000000000000000        9.0000000000000000        10.000000000000000        11.000000000000000        12.000000000000000        13.000000000000000        14.000000000000000        15.000000000000000        16.000000000000000        17.000000000000000        18.000000000000000        19.000000000000000        20.000000000000000        21.000000000000000        22.000000000000000        23.000000000000000        24.000000000000000        25.000000000000000     
Test bcast_1 with 1 MPI ranks PASSED!
Running bcast_1 with 2 MPI ranks...
 Rank=           0  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000        6.0000000000000000        7.0000000000000000        8.0000000000000000        9.0000000000000000        10.000000000000000        11.000000000000000        12.000000000000000        13.000000000000000        14.000000000000000        15.000000000000000        16.000000000000000        17.000000000000000        18.000000000000000        19.000000000000000        20.000000000000000        21.000000000000000        22.000000000000000        23.000000000000000        24.000000000000000        25.000000000000000     
 Rank=           1  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000     
Test bcast_1 with 2 MPI ranks PASSED!
Running bcast_1 with 4 MPI ranks...
 Rank=           0  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000        6.0000000000000000        7.0000000000000000        8.0000000000000000        9.0000000000000000        10.000000000000000        11.000000000000000        12.000000000000000        13.000000000000000        14.000000000000000        15.000000000000000        16.000000000000000        17.000000000000000        18.000000000000000        19.000000000000000        20.000000000000000        21.000000000000000        22.000000000000000        23.000000000000000        24.000000000000000        25.000000000000000     
 Rank=           1  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000     
 Rank=           2  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000     
 Rank=           3  received arr=   1.0000000000000000        2.0000000000000000        3.0000000000000000        4.0000000000000000        5.0000000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000       -999.00000000000000     
Test bcast_1 with 4 MPI ranks PASSED!

... Running standalone tests took 1 seconds ...

TODO:- Create MRE in lfortran to fix this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions