| 1 |
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes ALL,HOST |
| 2 |
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefixes ALL |
| 3 |
|
| 4 |
program main |
| 5 |
use, intrinsic :: iso_c_binding |
| 6 |
implicit none |
| 7 |
interface |
| 8 |
subroutine any_interface() bind(c,name="any_interface") |
| 9 |
use, intrinsic :: iso_c_binding |
| 10 |
implicit none |
| 11 |
!$omp declare target enter(any_interface) device_type(any) |
| 12 |
end subroutine any_interface |
| 13 |
|
| 14 |
subroutine host_interface() bind(c,name="host_interface") |
| 15 |
use, intrinsic :: iso_c_binding |
| 16 |
implicit none |
| 17 |
!$omp declare target enter(host_interface) device_type(host) |
| 18 |
end subroutine host_interface |
| 19 |
|
| 20 |
subroutine device_interface() bind(c,name="device_interface") |
| 21 |
use, intrinsic :: iso_c_binding |
| 22 |
implicit none |
| 23 |
!$omp declare target enter(device_interface) device_type(nohost) |
| 24 |
end subroutine device_interface |
| 25 |
|
| 26 |
subroutine called_from_target_interface(f1, f2) bind(c,name="called_from_target_interface") |
| 27 |
use, intrinsic :: iso_c_binding |
| 28 |
implicit none |
| 29 |
type(c_funptr),value :: f1 |
| 30 |
type(c_funptr),value :: f2 |
| 31 |
end subroutine called_from_target_interface |
| 32 |
|
| 33 |
subroutine called_from_host_interface(f1) bind(c,name="called_from_host_interface") |
| 34 |
use, intrinsic :: iso_c_binding |
| 35 |
implicit none |
| 36 |
type(c_funptr),value :: f1 |
| 37 |
end subroutine called_from_host_interface |
| 38 |
|
| 39 |
subroutine unused_unemitted_interface() bind(c,name="unused_unemitted_interface") |
| 40 |
use, intrinsic :: iso_c_binding |
| 41 |
implicit none |
| 42 |
!$omp declare target enter(unused_unemitted_interface) device_type(nohost) |
| 43 |
end subroutine unused_unemitted_interface |
| 44 |
|
| 45 |
end interface |
| 46 |
|
| 47 |
CALL called_from_host_interface(c_funloc(host_interface)) |
| 48 |
!$omp target |
| 49 |
CALL called_from_target_interface(c_funloc(any_interface), c_funloc(device_interface)) |
| 50 |
!$omp end target |
| 51 |
end program main |
| 52 |
|
| 53 |
!HOST-LABEL: func.func {{.*}} @host_interface() |
| 54 |
!HOST-SAME: {{.*}}, omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (enter)>{{.*}} |
| 55 |
!ALL-LABEL: func.func {{.*}} @called_from_target_interface(!fir.ref<i64>, !fir.ref<i64>) |
| 56 |
!ALL-SAME: {{.*}}, omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (to)>{{.*}} |
| 57 |
!ALL-LABEL: func.func {{.*}} @any_interface() |
| 58 |
!ALL-SAME: {{.*}}, omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (enter)>{{.*}} |
| 59 |
!ALL-LABEL: func.func {{.*}} @device_interface() |
| 60 |
!ALL-SAME: {{.*}}, omp.declare_target = #omp.declaretarget<device_type = (nohost), capture_clause = (enter)>{{.*}} |