| 1 |
! The "use_device_addr" was added to the "target data" directive in OpenMP 5.0. |
| 2 |
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s |
| 3 |
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s |
| 4 |
|
| 5 |
! This tests primary goal is to check the promotion of |
| 6 |
! non-CPTR arguments from use_device_ptr to |
| 7 |
! use_device_addr works, without breaking any |
| 8 |
! functionality |
| 9 |
|
| 10 |
!CHECK: func.func @{{.*}}only_use_device_ptr() |
| 11 |
!CHECK: omp.target_data use_device_ptr(%{{.*}} : !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>) use_device_addr(%{{.*}}, %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) { |
| 12 |
!CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, %{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, %{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>): |
| 13 |
subroutine only_use_device_ptr |
| 14 |
use iso_c_binding |
| 15 |
integer, pointer, dimension(:) :: array |
| 16 |
real, pointer :: pa(:) |
| 17 |
type(c_ptr) :: cptr |
| 18 |
|
| 19 |
!$omp target data use_device_ptr(pa, cptr, array) |
| 20 |
!$omp end target data |
| 21 |
end subroutine |
| 22 |
|
| 23 |
!CHECK: func.func @{{.*}}mix_use_device_ptr_and_addr() |
| 24 |
!CHECK: omp.target_data use_device_ptr({{.*}} : !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>) use_device_addr(%{{.*}}, %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) { |
| 25 |
!CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, %{{.*}}: !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, %{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>): |
| 26 |
subroutine mix_use_device_ptr_and_addr |
| 27 |
use iso_c_binding |
| 28 |
integer, pointer, dimension(:) :: array |
| 29 |
real, pointer :: pa(:) |
| 30 |
type(c_ptr) :: cptr |
| 31 |
|
| 32 |
!$omp target data use_device_ptr(pa, cptr) use_device_addr(array) |
| 33 |
!$omp end target data |
| 34 |
end subroutine |
| 35 |
|
| 36 |
!CHECK: func.func @{{.*}}only_use_device_addr() |
| 37 |
!CHECK: omp.target_data use_device_addr(%{{.*}}, %{{.*}}, %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) { |
| 38 |
!CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, %{{.*}}: !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, %{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>): |
| 39 |
subroutine only_use_device_addr |
| 40 |
use iso_c_binding |
| 41 |
integer, pointer, dimension(:) :: array |
| 42 |
real, pointer :: pa(:) |
| 43 |
type(c_ptr) :: cptr |
| 44 |
|
| 45 |
!$omp target data use_device_addr(pa, cptr, array) |
| 46 |
!$omp end target data |
| 47 |
end subroutine |
| 48 |
|
| 49 |
!CHECK: func.func @{{.*}}mix_use_device_ptr_and_addr_and_map() |
| 50 |
!CHECK: omp.target_data use_device_ptr(%{{.*}} : !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>) use_device_addr(%{{.*}}, %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) map_entries(%{{.*}}, %{{.*}} : !fir.ref<i32>, !fir.ref<i32>) { |
| 51 |
!CHECK: ^bb0(%{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, %{{.*}}: !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, %{{.*}}: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>): |
| 52 |
subroutine mix_use_device_ptr_and_addr_and_map |
| 53 |
use iso_c_binding |
| 54 |
integer :: i, j |
| 55 |
integer, pointer, dimension(:) :: array |
| 56 |
real, pointer :: pa(:) |
| 57 |
type(c_ptr) :: cptr |
| 58 |
|
| 59 |
!$omp target data use_device_ptr(pa, cptr) use_device_addr(array) map(tofrom: i, j) |
| 60 |
!$omp end target data |
| 61 |
end subroutine |
| 62 |
|
| 63 |
!CHECK: func.func @{{.*}}only_use_map() |
| 64 |
!CHECK: omp.target_data map_entries(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) { |
| 65 |
subroutine only_use_map |
| 66 |
use iso_c_binding |
| 67 |
integer, pointer, dimension(:) :: array |
| 68 |
real, pointer :: pa(:) |
| 69 |
type(c_ptr) :: cptr |
| 70 |
|
| 71 |
!$omp target data map(pa, cptr, array) |
| 72 |
!$omp end target data |
| 73 |
end subroutine |