[Openmp-commits] [openmp] [openmp][flang] Add tests for map clause (PR #70394)
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Sat Oct 28 11:06:08 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
----------------
jdoerfert wrote:
FWIW, this will sooner or later blow up. You assume there is only one GPU. I'd recommend to do something like:
```
print omp_get_num_devices()
!CHECK: [[ND:[0-9]*]]
print omp_get_default_device()
!CHECK: [[DD:[0-9]*]]
!CHECK: devices: [[ND]] [[DD]]
```
https://github.com/llvm/llvm-project/pull/70394
More information about the Openmp-commits
mailing list