-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP] NFC: Create versions of declare-target tests with HLFIR
These tests work with HLFIR without any change. declare-target-implicit-tarop-cap.f90 fails and hence not included here.
- Loading branch information
1 parent
599eade
commit 7fe8e0a
Showing
3 changed files
with
400 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s | ||
|
||
module test_0 | ||
implicit none | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Edata_int {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : i32 | ||
INTEGER :: data_int = 10 | ||
!$omp declare target link(data_int) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Earray_1d({{.*}}) {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !fir.array<3xi32> | ||
INTEGER :: array_1d(3) = (/1,2,3/) | ||
!$omp declare target link(array_1d) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Earray_2d({{.*}}) {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !fir.array<2x2xi32> | ||
INTEGER :: array_2d(2,2) = reshape((/1,2,3,4/), (/2,2/)) | ||
!$omp declare target link(array_2d) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Ept1 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !fir.box<!fir.ptr<i32>> | ||
INTEGER, POINTER :: pt1 | ||
!$omp declare target link(pt1) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Ept2_tar {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} target : i32 | ||
INTEGER, TARGET :: pt2_tar = 5 | ||
!$omp declare target link(pt2_tar) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Ept2 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : !fir.box<!fir.ptr<i32>> | ||
INTEGER, POINTER :: pt2 => pt2_tar | ||
!$omp declare target link(pt2) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Edata_int_to {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : i32 | ||
INTEGER :: data_int_to = 5 | ||
!$omp declare target to(data_int_to) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Edata_int_clauseless {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : i32 | ||
INTEGER :: data_int_clauseless = 1 | ||
!$omp declare target(data_int_clauseless) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Edata_extended_to_1 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : f32 | ||
!CHECK-DAG: fir.global @_QMtest_0Edata_extended_to_2 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : f32 | ||
REAL :: data_extended_to_1 = 2 | ||
REAL :: data_extended_to_2 = 3 | ||
!$omp declare target to(data_extended_to_1, data_extended_to_2) | ||
|
||
!CHECK-DAG: fir.global @_QMtest_0Edata_extended_link_1 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : f32 | ||
!CHECK-DAG: fir.global @_QMtest_0Edata_extended_link_2 {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : f32 | ||
REAL :: data_extended_link_1 = 2 | ||
REAL :: data_extended_link_2 = 3 | ||
!$omp declare target link(data_extended_link_1, data_extended_link_2) | ||
|
||
contains | ||
end module test_0 | ||
|
||
PROGRAM commons | ||
!CHECK-DAG: fir.global @numbers_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> { | ||
REAL :: one = 1 | ||
REAL :: two = 2 | ||
COMMON /numbers/ one, two | ||
!$omp declare target(/numbers/) | ||
|
||
!CHECK-DAG: fir.global @numbers_link_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : tuple<f32, f32> { | ||
REAL :: one_link = 1 | ||
REAL :: two_link = 2 | ||
COMMON /numbers_link/ one_link, two_link | ||
!$omp declare target link(/numbers_link/) | ||
|
||
!CHECK-DAG: fir.global @numbers_to_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> { | ||
REAL :: one_to = 1 | ||
REAL :: two_to = 2 | ||
COMMON /numbers_to/ one_to, two_to | ||
!$omp declare target to(/numbers_to/) | ||
END |
110 changes: 110 additions & 0 deletions
110
flang/test/Lower/OpenMP/declare-target-func-and-subr.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,110 @@ | ||
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes ALL,HOST | ||
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL,DEVICE | ||
|
||
! Check specification valid forms of declare target with functions | ||
! utilising device_type and to clauses as well as the default | ||
! zero clause declare target | ||
|
||
! DEVICE-LABEL: func.func @_QPfunc_t_device() | ||
! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_T_DEVICE() RESULT(I) | ||
!$omp declare target to(FUNC_T_DEVICE) device_type(nohost) | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_T_DEVICE | ||
|
||
! HOST-LABEL: func.func @_QPfunc_t_host() | ||
! HOST-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_T_HOST() RESULT(I) | ||
!$omp declare target to(FUNC_T_HOST) device_type(host) | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_T_HOST | ||
|
||
! ALL-LABEL: func.func @_QPfunc_t_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_T_ANY() RESULT(I) | ||
!$omp declare target to(FUNC_T_ANY) device_type(any) | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_T_ANY | ||
|
||
! ALL-LABEL: func.func @_QPfunc_default_t_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_DEFAULT_T_ANY() RESULT(I) | ||
!$omp declare target to(FUNC_DEFAULT_T_ANY) | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_DEFAULT_T_ANY | ||
|
||
! ALL-LABEL: func.func @_QPfunc_default_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_DEFAULT_ANY() RESULT(I) | ||
!$omp declare target | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_DEFAULT_ANY | ||
|
||
! ALL-LABEL: func.func @_QPfunc_default_extendedlist() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
FUNCTION FUNC_DEFAULT_EXTENDEDLIST() RESULT(I) | ||
!$omp declare target(FUNC_DEFAULT_EXTENDEDLIST) | ||
INTEGER :: I | ||
I = 1 | ||
END FUNCTION FUNC_DEFAULT_EXTENDEDLIST | ||
|
||
!! ----- | ||
|
||
! Check specification valid forms of declare target with subroutines | ||
! utilising device_type and to clauses as well as the default | ||
! zero clause declare target | ||
|
||
! DEVICE-LABEL: func.func @_QPsubr_t_device() | ||
! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_T_DEVICE() | ||
!$omp declare target to(SUBR_T_DEVICE) device_type(nohost) | ||
END | ||
|
||
! HOST-LABEL: func.func @_QPsubr_t_host() | ||
! HOST-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_T_HOST() | ||
!$omp declare target to(SUBR_T_HOST) device_type(host) | ||
END | ||
|
||
! ALL-LABEL: func.func @_QPsubr_t_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_T_ANY() | ||
!$omp declare target to(SUBR_T_ANY) device_type(any) | ||
END | ||
|
||
! ALL-LABEL: func.func @_QPsubr_default_t_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_DEFAULT_T_ANY() | ||
!$omp declare target to(SUBR_DEFAULT_T_ANY) | ||
END | ||
|
||
! ALL-LABEL: func.func @_QPsubr_default_any() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_DEFAULT_ANY() | ||
!$omp declare target | ||
END | ||
|
||
! ALL-LABEL: func.func @_QPsubr_default_extendedlist() | ||
! ALL-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>{{.*}} | ||
SUBROUTINE SUBR_DEFAULT_EXTENDEDLIST() | ||
!$omp declare target(SUBR_DEFAULT_EXTENDEDLIST) | ||
END | ||
|
||
!! ----- | ||
|
||
! DEVICE-LABEL: func.func @_QPrecursive_declare_target | ||
! DEVICE-SAME: {{.*}}attributes {omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} | ||
RECURSIVE FUNCTION RECURSIVE_DECLARE_TARGET(INCREMENT) RESULT(K) | ||
!$omp declare target to(RECURSIVE_DECLARE_TARGET) device_type(nohost) | ||
INTEGER :: INCREMENT, K | ||
IF (INCREMENT == 10) THEN | ||
K = INCREMENT | ||
ELSE | ||
K = RECURSIVE_DECLARE_TARGET(INCREMENT + 1) | ||
END IF | ||
END FUNCTION RECURSIVE_DECLARE_TARGET |
Oops, something went wrong.