Skip to content

[NFC][OpenMP][Flang] Add test for OpenMP target parallel do #77776

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
! 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
integer :: x(100)
integer :: errors = 0
integer :: i

!$omp target parallel do map(from: x)
do i = 1, 100
x(i) = i
end do
!$omp end target parallel do
Comment on lines +17 to +21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, AFAIU, offloading can silently fallback to the host, should we, in our offloading tests, always verify that offloading did indeed succeed somehow? I did this previously by taking device IDs and comparing them to make sure they are different. However, I am not sure this is the best approach.

Or do we not need to verify that at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Instead of modifying the code I based on libomptarget runtime logs (similar test case: https://github.com/llvm/llvm-project/blob/main/openmp/libomptarget/test/offloading/ompx_bare.c )

do i = 1, 100
if ( x(i) .ne. i ) then
errors = errors + 1
end if
end do

print *,"number of errors: ", errors

end program main

! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}}
! CHECKi: number of errors: 0