forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][OpenMP] Add support for
target ... private
Adds support for the `private` clause in the `target` directive. In order to support that, the `DataSharingProcessor` was also restructured in order to separate the collection of prviate symbols from their actual privatization code-gen. The commit adds both a code-gen and an offloading tests.
- Loading branch information
Showing
5 changed files
with
141 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
!Test data-sharing attribute clauses for the `target` directive. | ||
|
||
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
!CHECK-LABEL: func.func @_QPomp_target_private() | ||
subroutine omp_target_private | ||
implicit none | ||
integer :: x(1) | ||
|
||
!$omp target private(x) | ||
x(1) = 42 | ||
!$omp end target | ||
!CHECK: omp.target { | ||
!CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index | ||
!CHECK-DAG: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.array<1xi32> {bindc_name = "x", | ||
!CHECK-SAME: pinned, uniq_name = "_QFomp_target_privateEx"} | ||
!CHECK-NEXT: %[[SHAPE:.*]] = fir.shape %[[C1]] : (index) -> !fir.shape<1> | ||
!CHECK-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]](%[[SHAPE]]) | ||
!CHECK-SAME: {uniq_name = "_QFomp_target_privateEx"} : | ||
!CHECK-SAME: (!fir.ref<!fir.array<1xi32>>, !fir.shape<1>) -> | ||
!CHECK-SAME: (!fir.ref<!fir.array<1xi32>>, !fir.ref<!fir.array<1xi32>>) | ||
!CHECK-DAG: %[[C42:.*]] = arith.constant 42 : i32 | ||
!CHECK-DAG: %[[C1_2:.*]] = arith.constant 1 : index | ||
!CHECK-NEXT: %[[PRIV_BINDING:.*]] = hlfir.designate %[[PRIV_DECL]]#0 (%[[C1_2]]) | ||
!CHECK-SAME: : (!fir.ref<!fir.array<1xi32>>, index) -> !fir.ref<i32> | ||
!CHECK-NEXT: hlfir.assign %[[C42]] to %[[PRIV_BINDING]] : i32, !fir.ref<i32> | ||
!CHECK-NEXT: omp.terminator | ||
!CHECK-NEXT: } | ||
|
||
end subroutine omp_target_private |
29 changes: 29 additions & 0 deletions
29
openmp/libomptarget/test/offloading/fortran/target_private.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! 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 target_update | ||
implicit none | ||
integer :: x(1) | ||
integer :: y(1) | ||
|
||
x(1) = 42 | ||
|
||
!$omp target private(x) map(tofrom: y) | ||
x(1) = 84 | ||
y(1) = x(1) | ||
!$omp end target | ||
|
||
print *, "x =", x(1) | ||
print *, "y =", y(1) | ||
|
||
end program target_update | ||
! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}} | ||
! CHECK: x = 42 | ||
! CHECK: y = 84 |