| 1 |
! RUN: %flang_fc1 -fopenmp -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-HOST,LLVM-ALL %s |
| 2 |
! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s |
| 3 |
! RUN: %flang_fc1 -fopenmp -fopenmp-is-target-device -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-DEVICE,LLVM-ALL %s |
| 4 |
! RUN: %flang_fc1 -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s |
| 5 |
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s |
| 6 |
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s |
| 7 |
|
| 8 |
! Check that the correct LLVM IR functions are kept for the host and device |
| 9 |
! after running the whole set of translation and transformation passes from |
| 10 |
! Fortran. |
| 11 |
|
| 12 |
! MLIR-ALL: func.func @{{.*}}device_fn( |
| 13 |
! MLIR-ALL: return |
| 14 |
|
| 15 |
! LLVM-ALL: define {{.*}} @{{.*}}device_fn{{.*}}( |
| 16 |
function device_fn() result(x) |
| 17 |
!$omp declare target to(device_fn) device_type(nohost) |
| 18 |
integer :: x |
| 19 |
x = 10 |
| 20 |
end function device_fn |
| 21 |
|
| 22 |
! MLIR-ALL: func.func @{{.*}}device_fn_enter( |
| 23 |
! MLIR-ALL: return |
| 24 |
|
| 25 |
! LLVM-ALL: define {{.*}} @{{.*}}device_fn_enter{{.*}}( |
| 26 |
function device_fn_enter() result(x) |
| 27 |
!$omp declare target enter(device_fn_enter) device_type(nohost) |
| 28 |
integer :: x |
| 29 |
x = 10 |
| 30 |
end function device_fn_enter |
| 31 |
|
| 32 |
! MLIR-HOST: func.func @{{.*}}host_fn( |
| 33 |
! MLIR-HOST: return |
| 34 |
! MLIR-DEVICE-NOT: func.func {{.*}}host_fn( |
| 35 |
|
| 36 |
! LLVM-HOST: define {{.*}} @{{.*}}host_fn{{.*}}( |
| 37 |
! LLVM-DEVICE-NOT: {{.*}} @{{.*}}host_fn{{.*}}( |
| 38 |
function host_fn() result(x) |
| 39 |
!$omp declare target to(host_fn) device_type(host) |
| 40 |
integer :: x |
| 41 |
x = 10 |
| 42 |
end function host_fn |
| 43 |
|
| 44 |
! LLVM-HOST: define {{.*}} @{{.*}}host_fn_enter{{.*}}( |
| 45 |
! LLVM-DEVICE-NOT: {{.*}} @{{.*}}host_fn_enter{{.*}}( |
| 46 |
function host_fn_enter() result(x) |
| 47 |
!$omp declare target enter(host_fn_enter) device_type(host) |
| 48 |
integer :: x |
| 49 |
x = 10 |
| 50 |
end function host_fn_enter |
| 51 |
|
| 52 |
! MLIR-ALL: func.func @{{.*}}target_subr( |
| 53 |
! MLIR-ALL: return |
| 54 |
|
| 55 |
! LLVM-HOST: define {{.*}} @{{.*}}target_subr{{.*}}( |
| 56 |
! LLVM-ALL: define {{.*}} @__omp_offloading_{{.*}}_{{.*}}_target_subr__{{.*}}( |
| 57 |
subroutine target_subr(x) |
| 58 |
integer, intent(out) :: x |
| 59 |
!$omp target map(from:x) |
| 60 |
x = 10 |
| 61 |
!$omp end target |
| 62 |
end subroutine target_subr |