Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let Fortran array match caller of different rank (in ignore_tkr) #9367

Closed
wants to merge 1 commit into from

Commits on Sep 10, 2021

  1. let Fortran array match caller of different rank (in ignore_tkr)

    The below example program uses a 2d array for requests and that gets
    rejected by the type/kind/rank checking when the MPI_Waitall module
    says the incoming argument should be an array.
    
        program main
        use mpi
        integer, contiguous, pointer :: requests(:, :)
        integer :: ierr, sbuf1, sbuf2, rbuf1, rbuf2
        allocate(requests(2,2))
        call MPI_Init(ierr)
        sbuf1 = 1
        sbuf2 = 2
        rbuf1 = -1
        rbuf2 = -1
        call MPI_Irecv(rbuf1, 1, MPI_INTEGER, 0, 99, MPI_COMM_SELF, requests(1,1), ierr)
        call MPI_Irecv(rbuf2, 1, MPI_INTEGER, 0, 99, MPI_COMM_SELF, requests(1,2), ierr)
        call MPI_Isend(sbuf1, 1, MPI_INTEGER, 0, 99, MPI_COMM_SELF, requests(2,1), ierr)
        call MPI_Isend(sbuf2, 1, MPI_INTEGER, 0, 99, MPI_COMM_SELF, requests(2,2), ierr)
        call MPI_Waitall(size(requests), requests, MPI_STATUSES_IGNORE, ierr)
        print *, 'rbufs:', rbuf1, rbuf2
        if (rbuf1 .ne. 1 .or. rbuf2 .ne. 2) then
            print *, 'failed'
            call MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OTHER, ierr)
        else
            print *, 'passed'
        endif
        call MPI_Finalize(ierr)
        end
    
    % mpifort -o x mpi.F90
    > "mpi.F90", line 15.6: 1513-062 (S) Generic procedure reference
    > can not be resolved due to incorrect actual argument attributes.
    > ** main   === End of Compilation 1 ===
    > 1501-511  Compilation failed for file mpi.F90.
    
    The above is XLF, but gfortran is similar.
    
    This commit changes array_of_requests and a bunch of other arrays from
       integer, dimension(count), intent(inout) :: array_of_requests
    to
       @OMPI_FORTRAN_IGNORE_TKR_PREDECL@ array_of_requests
       @OMPI_FORTRAN_IGNORE_TKR_TYPE@, intent(inout) :: array_of_requests
    
    This approach throws away more than just the rank check, so for example
    it would now start failing to detect if an array of reals was passed in
    as a request array.  But I didn't find a good way to be more targeted.
    
    Some compilers can be more targeted, eg XLF can use
        integer count
        !ibm* ignore_tkr (r) array
        integer, dimension(count) :: array
    but gfortran as far as I know doesn't have an equivalent, and only has
        integer count
        !GCC$ ATTRIBUTES NO_ARG_CHECK :: array
        type(*), dimension(*) :: array
    but the macro system would have to provide a lot more than settings
    for OMPI_FORTRAN_IGNORE_TKR_PREDECL and OMPI_FORTRAN_IGNORE_TKR_TYPE
    to produce that code.  Plus XLF recognizes the gfortran pragmas so it
    takes the gfortran path in configure so it wouldn't necessarily even
    take the more targeted path if we did provide it.
    
    Signed-off-by: Mark Allen <[email protected]>
    markalle committed Sep 10, 2021
    Configuration menu
    Copy the full SHA
    e965f45 View commit details
    Browse the repository at this point in the history