| 1 |
! { dg-do compile } |
| 2 |
! { dg-additional-options "-fdump-tree-gimple -fdump-tree-ompdevlow" } |
| 3 |
|
| 4 |
subroutine f (a, num) |
| 5 |
integer, parameter :: N = 256 |
| 6 |
integer :: a(N) |
| 7 |
integer :: num |
| 8 |
integer :: i |
| 9 |
|
| 10 |
!$omp metadirective & |
| 11 |
!$omp& when (target_device={device_num(num), kind("gpu"), arch("nvptx")}: & |
| 12 |
!$omp& target parallel do map(tofrom: a(1:N))) & |
| 13 |
!$omp& when (target_device={device_num(num), kind("gpu"), & |
| 14 |
!$omp& arch("amdgcn"), isa("gfx906")}: & |
| 15 |
!$omp& target parallel do) & |
| 16 |
!$omp& when (target_device={device_num(num), kind("cpu"), arch("x86_64")}: & |
| 17 |
!$omp& parallel do) |
| 18 |
do i = 1, N |
| 19 |
a(i) = a(i) + i |
| 20 |
end do |
| 21 |
|
| 22 |
!$omp metadirective & |
| 23 |
!$omp& when (target_device={kind("gpu"), arch("nvptx")}: & |
| 24 |
!$omp& target parallel do map(tofrom: a(1:N))) |
| 25 |
do i = 1, N |
| 26 |
a(i) = a(i) + i |
| 27 |
end do |
| 28 |
end subroutine |
| 29 |
|
| 30 |
! For configurations with offloading, we expect one "pragma omp target" |
| 31 |
! with "device(num)" for each target_device selector that specifies |
| 32 |
! "device_num(num)". Without offloading, there should be zero as the |
| 33 |
! resolution happens during gimplification. |
| 34 |
! { dg-final { scan-tree-dump-times "pragma omp target\[^\\n\]* device\\(" 3 "gimple" { target offloading_enabled } } } |
| 35 |
! { dg-final { scan-tree-dump-times "pragma omp target\[^\\n\]* device\\(" 0 "gimple" { target { ! offloading_enabled } } } } |
| 36 |
|
| 37 |
! For configurations with offloading, expect one OMP_TARGET_DEVICE_MATCHES |
| 38 |
! for each kind/arch/isa selector. These are supposed to go away after |
| 39 |
! ompdevlow. |
| 40 |
! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 9 "gimple" { target offloading_enabled } } } |
| 41 |
! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 0 "gimple" { target { ! offloading_enabled } } } } |
| 42 |
! { dg-final { scan-tree-dump-times "OMP_TARGET_DEVICE_MATCHES" 0 "ompdevlow" { target offloading_enabled } } } |