[Openmp-commits] [openmp] [openmp][flang] Add tests for map clause (PR #70394)

via Openmp-commits openmp-commits at lists.llvm.org
Sun Oct 29 10:36:55 PDT 2023


================
@@ -0,0 +1,82 @@
+! Basic offloading test with a target region
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! 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-run-and-check-generic
+
+! Testing simple variables in common block.
+program main
+  call check_device
+  call commonblock_simple_with_implicit_type
+  call commonblock_simple_with_integer
+  call commonblock_simple_with_real
+end program main
+
+!-----
+
+subroutine check_device
+  use omp_lib
+  integer :: devices(2)
+  devices(1) = omp_get_device_num()
+  !$omp target map(tofrom:devices)
+    devices(2) = omp_get_device_num()
+  !$omp end target
+  print *, "devices: ", devices
+end subroutine check_device
+
+!CHECK: devices: 1 0
----------------
shraiysh wrote:

Thanks for pointing this out. 

If possible, I'd like to do something like this, and make sure this runs only if there is a device. Is it possible to do this with LIT directives to ensure this test runs when there is atleast one device, and doesn't run (unsupported) otherwise?

```
print omp_get_num_devices()
!CHECK: [[ND:[1-9]*]]
```

https://github.com/llvm/llvm-project/pull/70394


More information about the Openmp-commits mailing list