[Openmp-commits] [openmp] [OpenMP][flang] Adding more tests for commonblock with target map (PR #71146)
via Openmp-commits
openmp-commits at lists.llvm.org
Thu Nov 2 22:31:24 PDT 2023
https://github.com/shraiysh created https://github.com/llvm/llvm-project/pull/71146
This patch addresses the concern about multiple devices and also adds more tests for `map(to:)`, `map(from:)` and named common blocks.
>From 714c7e3e2c305660b90429bcc3b9c37b2b2a8eb7 Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay <shraiysh.vaishay at amd.com>
Date: Fri, 3 Nov 2023 00:29:51 -0500
Subject: [PATCH] [OpenMP][flang] Adding more tests for commonblock with target
map
---
.../fortran/target_map_common_block.f90 | 69 ++++++++++++++++++-
1 file changed, 67 insertions(+), 2 deletions(-)
diff --git a/openmp/libomptarget/test/offloading/fortran/target_map_common_block.f90 b/openmp/libomptarget/test/offloading/fortran/target_map_common_block.f90
index cc7ce50e661e198..ffaa2459e403580 100644
--- a/openmp/libomptarget/test/offloading/fortran/target_map_common_block.f90
+++ b/openmp/libomptarget/test/offloading/fortran/target_map_common_block.f90
@@ -15,6 +15,10 @@ program main
call commonblock_simple_with_implicit_type
call commonblock_simple_with_integer
call commonblock_simple_with_real
+ call commonblock_simple_to
+ call commonblock_simple_from
+ call set_commonblock_named
+ call use_commonblock_named
end program main
!-----
@@ -26,11 +30,14 @@ subroutine check_device
!$omp target map(tofrom:devices)
devices(2) = omp_get_device_num()
!$omp end target
+ print *, omp_get_num_devices()
+ !CHECK: [[ND:[0-9]+]]
+ print *, omp_get_default_device()
+ !CHECK: [[DD:[0-9]+]]
+ !CHECK: devices: [[ND]] [[DD]]
print *, "devices: ", devices
end subroutine check_device
-!CHECK: devices: 1 0
-
!-----
subroutine commonblock_simple_with_implicit_type
@@ -80,3 +87,61 @@ subroutine commonblock_simple_with_real
! CHECK: var3 before target = 12.5
! CHECK: var3 after target = 14.5
+
+! -----
+
+subroutine commonblock_simple_to
+ use omp_lib
+ integer :: var4, tmp
+ common var4
+ var4 = 10
+ tmp = 20
+ !$omp target map(to:var4) map(from:tmp)
+ tmp = var4
+ var4 = 20
+ !$omp end target
+ print *, "var4 after target = ", var4
+ print *, "tmp after target = ", tmp
+end subroutine
+
+! CHECK: var4 after target = 10
+! CHECK: tmp after target = 10
+
+! -----
+
+subroutine commonblock_simple_from
+ use omp_lib
+ integer :: var5, tmp
+ var5 = 10
+ tmp = 20
+ !$omp target map(from:var5) map(to:tmp)
+ var5 = tmp
+ tmp = 30
+ !$omp end target
+ print *, "var5 after target = ", var5
+ print *, "tmp after target = ", tmp
+end subroutine commonblock_simple_from
+
+! CHECK: var5 after target = 20
+! CHECK: tmp after target = 20
+
+! -----
+
+subroutine set_commonblock_named
+ integer :: var6
+ common /my_common_block/ var6
+ var6 = 20
+end subroutine
+
+subroutine use_commonblock_named
+ integer :: var6
+ common /my_common_block/ var6
+ print *, "var6 before target = ", var6
+ !$omp target map(tofrom: var6)
+ var6 = 30
+ !$omp end target
+ print *, "var6 after target = ", var6
+end subroutine
+
+! CHECK: var6 before target = 20
+! CHECK: var6 after target = 30
More information about the Openmp-commits
mailing list