brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 659ca1c Raw
72 lines · plain
1! Small regression test that checks that we do not cause a runtime map error in2! cases where we are required to allocate a local variable for the fortran3! descriptor to store into and then load from it, done so by reusing the4! temporary local variable across all maps related to the mapped variable and5! associated local variable to make sure that each map does as it is intended6! to do with the original data. This prevents blobs of local descriptor data7! remaining attached on device long after it's supposed to, which can cause8! weird map issues later in susbequent function invocations. However, it9! doesn't avoid a user shooting themselves in the foot by mapping data via10! enter and then not providing a corresponding exit.11! REQUIRES: flang, amdgpu12 13! RUN: %libomptarget-compile-fortran-run-and-check-generic14subroutine launchOne(n1, n2, ret)15    implicit none16    real, intent(out) :: ret17    real(4), dimension(n1,n2) :: sbuf3118    integer :: n1,n219!$omp target enter data map(alloc:sbuf31)20 21!$omp target22      sbuf31(2, 2) = 1023!$omp end target24 25!$omp target update from(sbuf31)26 27   ret = sbuf31(2, 2)28 29!$omp target exit data map(delete:sbuf31)30end subroutine launchOne31 32subroutine launchTwo(N, ret)33    implicit none34    real, intent(inout) :: ret35    integer :: N36    real(4), dimension(N) :: p37 38!$omp target enter data map(to:p)39 40!$omp target41    p(8) = 2042!$omp end target43 44!$omp target update from(p)45 46ret = ret + p(8)47 48! intentional non-deletion, can trigger an illegal map49! issue in cases where the local map we store and load50! from for the variable is different across all maps.51! Not too sure why this is the thing that triggers the52! problem in general. It seems like it would be an issue53! made apparent with and without this statement commented,54! especially as the issue occurs with the enter and not the55! corresponding exit (from the runtime trace at least).56!!$omp target exit data map(delete:p)57end subroutine launchTwo58 59program reproducer60    implicit none61    integer :: N = 1062    integer :: nr = 10, nt = 1063    real :: output = 064 65    call launchOne(nr, nt,  output)66    call launchTwo(N, output)67 68    print *, output69end program reproducer70 71! CHECK: 3072