| 1 |
! { dg-do link } |
| 2 |
! { dg-additional-options "-fdump-tree-gimple" } |
| 3 |
! { dg-additional-sources "declare-variant-mod-2-use.f90" } |
| 4 |
|
| 5 |
! Note: We have to use 'link' as otherwise '-o' is specified, |
| 6 |
! which does not work with multiple files. |
| 7 |
|
| 8 |
! Error message in the additional-sources file: |
| 9 |
|
| 10 |
! { dg-error "'x' at .1. is specified more than once" "" { target *-*-* } 17 } |
| 11 |
|
| 12 |
|
| 13 |
! Check that module-file handling works for declare_variant |
| 14 |
! and its match/adjust_args/append_args clauses |
| 15 |
! |
| 16 |
! PR fortran/115271 |
| 17 |
|
| 18 |
module m1 |
| 19 |
implicit none (type, external) |
| 20 |
contains |
| 21 |
integer function m1_f (x, y, z) |
| 22 |
use iso_c_binding |
| 23 |
type(c_ptr) :: x, y, z |
| 24 |
value :: x |
| 25 |
m1_f = 1 |
| 26 |
end |
| 27 |
integer function m1_g (x, y, z) |
| 28 |
use iso_c_binding |
| 29 |
type(c_ptr) :: x, y, z |
| 30 |
value :: x |
| 31 |
m1_g = 2 |
| 32 |
end |
| 33 |
end module m1 |
| 34 |
|
| 35 |
module m2 |
| 36 |
use iso_c_binding, only: c_intptr_t |
| 37 |
implicit none (type, external) |
| 38 |
integer, parameter :: omp_interop_kind = c_intptr_t |
| 39 |
|
| 40 |
!$omp declare variant(m2_g : m2_f3) match(construct={do,dispatch}, device={kind(host)}) & |
| 41 |
!$omp& append_args(interop(target),interop(targetsync), interop(prefer_type({fr("cuda"), attr("ompx_A")}, {fr("hip")}, {attr("ompx_B")}), targetsync)) |
| 42 |
|
| 43 |
contains |
| 44 |
subroutine m2_f3 (x, obj1, obj2, obj3) |
| 45 |
use iso_c_binding |
| 46 |
integer(omp_interop_kind) :: obj1, obj2, obj3 |
| 47 |
value :: obj1 |
| 48 |
integer, value :: x |
| 49 |
end |
| 50 |
|
| 51 |
subroutine m2_f2 (x, obj1, obj2) |
| 52 |
use iso_c_binding |
| 53 |
integer(omp_interop_kind) :: obj1, obj2 |
| 54 |
integer, value :: x |
| 55 |
end |
| 56 |
|
| 57 |
subroutine m2_f1 (x, obj1) |
| 58 |
use iso_c_binding |
| 59 |
integer(omp_interop_kind), value :: obj1 |
| 60 |
integer, value :: x |
| 61 |
end |
| 62 |
|
| 63 |
subroutine m2_g (x) |
| 64 |
integer, value :: x |
| 65 |
!$omp declare variant(m2_g : m2_f1) match(construct={dispatch}) append_args(interop(target, targetsync, prefer_type("cuda", "hip"))) |
| 66 |
!$omp declare variant(m2_f2) match(construct={parallel,dispatch}, implementation={vendor("gnu")}) append_args(interop(target),interop(targetsync)) |
| 67 |
end |
| 68 |
end module |