| 1 |
! { dg-additional-options "-fdump-tree-original" } |
| 2 |
|
| 3 |
! The following definitions are in omp_lib, which cannot be included |
| 4 |
! in gcc/testsuite/ |
| 5 |
|
| 6 |
module m |
| 7 |
use iso_c_binding |
| 8 |
implicit none (type, external) |
| 9 |
|
| 10 |
integer, parameter :: omp_interop_kind = c_intptr_t |
| 11 |
integer, parameter :: omp_interop_none = 0_omp_interop_kind |
| 12 |
|
| 13 |
interface |
| 14 |
real function repl1(); end ! { dg-note "'declare variant' candidate 'repl1' declared here" } |
| 15 |
|
| 16 |
real function base1() |
| 17 |
!$omp declare variant(repl1) match(construct={dispatch}) |
| 18 |
end |
| 19 |
|
| 20 |
subroutine repl2 (x1, x2) ! { dg-note "'declare variant' candidate 'repl2' declared here" } |
| 21 |
import |
| 22 |
type(c_ptr), value :: x1, x2 |
| 23 |
end |
| 24 |
subroutine base2 (x, y) |
| 25 |
import |
| 26 |
type(c_ptr), value :: x, y |
| 27 |
!$omp declare variant(repl2) match(construct={dispatch}) adjust_args(need_device_ptr : y) |
| 28 |
end |
| 29 |
end interface |
| 30 |
|
| 31 |
contains |
| 32 |
|
| 33 |
real function dupl (a, b) |
| 34 |
type(c_ptr), value :: a, b |
| 35 |
integer(omp_interop_kind) :: obj1, obj2 |
| 36 |
real :: x |
| 37 |
|
| 38 |
!$omp dispatch interop ( obj1, obj2) device(2) |
| 39 |
x = base1 () |
| 40 |
! { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target *-*-* } .-1 } |
| 41 |
|
| 42 |
!$omp dispatch device(9) interop ( obj1, obj2) nocontext(.true.) |
| 43 |
call base2 (a, b) |
| 44 |
dupl = x |
| 45 |
end |
| 46 |
|
| 47 |
real function test (a, b) |
| 48 |
type(c_ptr), value :: a, b |
| 49 |
integer(omp_interop_kind) :: obj1, obj2 |
| 50 |
real :: x, y |
| 51 |
|
| 52 |
!$omp dispatch interop ( obj1 ) |
| 53 |
x = base1 () |
| 54 |
! { dg-error "number of list items in 'interop' clause \\(1\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target *-*-* } .-1 } |
| 55 |
|
| 56 |
!$omp dispatch interop ( obj1, obj1 ) device(42) ! Twice the same - should be fine. |
| 57 |
x = base1 () |
| 58 |
! { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl1'" "" { target *-*-* } .-1 } |
| 59 |
|
| 60 |
!$omp dispatch novariants(.true.) interop(obj2, obj1) device(0) |
| 61 |
y = base1 () |
| 62 |
|
| 63 |
!$omp dispatch interop(obj2, obj1) device(3) |
| 64 |
call base2 (a, b) |
| 65 |
! { dg-error "number of list items in 'interop' clause \\(2\\) exceeds the number of 'append_args' items \\(0\\) for 'declare variant' candidate 'repl2'" "" { target *-*-* } .-1 } |
| 66 |
|
| 67 |
!$omp dispatch interop(obj2) nocontext(.true.) |
| 68 |
call base2 (a, b) |
| 69 |
test = x + y |
| 70 |
end |
| 71 |
end module |
| 72 |
|
| 73 |
|
| 74 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj2\\) interop\\(obj1\\) device\\(2\\)\[\\n\\r\]" 1 "original" } } |
| 75 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj2\\) interop\\(obj1\\) nocontext\\(1\\) device\\(9\\)\[\\n\\r\]" 1 "original" } } |
| 76 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\)\[\\n\\r\]" 1 "original" } } |
| 77 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj1\\) device\\(42\\)\[\\n\\r\]" 1 "original" } } |
| 78 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj2\\) novariants\\(1\\) device\\(0\\)\[\\n\\r\]" 1 "original" } } |
| 79 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj1\\) interop\\(obj2\\) device\\(3\\)\[\\n\\r\]" 1 "original" } } |
| 80 |
! { dg-final { scan-tree-dump-times "#pragma omp dispatch interop\\(obj2\\) nocontext\\(1\\)\[\\n\\r\]" 1 "original" } } |