diff options
author | Dominik Adamski <dominik.adamski@amd.com> | 2024-01-22 09:24:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 09:24:45 +0100 |
commit | 21199f9842dffa4f34b38101195c6f57d1bd4630 (patch) | |
tree | 6653b3fd1670671b5634a076d384d4165b0fbb6d /openmp | |
parent | a2caa4929e8e8a2ffff4ee5f03ab37a9be7462a0 (diff) | |
download | llvm-21199f9842dffa4f34b38101195c6f57d1bd4630.zip llvm-21199f9842dffa4f34b38101195c6f57d1bd4630.tar.gz llvm-21199f9842dffa4f34b38101195c6f57d1bd4630.tar.bz2 |
[OpenMP][OMPIRBuilder] Fix LLVM IR codegen for collapsed device loop (#78708)
When we generate the loop body function, we need to be sure, that all
original loop counters are replaced by the new counter.
We need to save all items which use the original loop counter and then
perform replacement of the original loop counter. If we don't do it,
there is a risk that some values are not updated.
Diffstat (limited to 'openmp')
-rw-r--r-- | openmp/libomptarget/test/offloading/fortran/target-parallel-do-collapse.f90 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/openmp/libomptarget/test/offloading/fortran/target-parallel-do-collapse.f90 b/openmp/libomptarget/test/offloading/fortran/target-parallel-do-collapse.f90 new file mode 100644 index 0000000..e44d6a5 --- /dev/null +++ b/openmp/libomptarget/test/offloading/fortran/target-parallel-do-collapse.f90 @@ -0,0 +1,44 @@ +! Basic offloading test with a target region +! REQUIRES: flang +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO +! UNSUPPORTED: x86_64-pc-linux-gnu +! UNSUPPORTED: x86_64-pc-linux-gnu-LTO + +! RUN: %libomptarget-compile-fortran-generic +! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic +program main + use omp_lib + implicit none + integer :: i,j + integer :: array(10,10), errors = 0 + do i = 1, 10 + do j = 1, 10 + array(j, i) = 0 + end do + end do + + !$omp target parallel do map(from:array) collapse(2) + do i = 1, 10 + do j = 1, 10 + array( j, i) = i + j + end do + end do + !$omp end target parallel do + + do i = 1, 10 + do j = 1, 10 + if ( array( j, i) .ne. (i + j) ) then + errors = errors + 1 + end if + end do + end do + + print *,"number of errors: ", errors + +end program main + +! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} +! CHECK: number of errors: 0 + |