This effectively implements some now deprecated OpenMP functionality that some applications (most notably at the moment GenASiS) unfortunately depend on (deprecated in specification version 5.2): "If a list item in a use_device_ptr clause is not of type C_PTR, the behavior is as if the list item appeared in a use_device_addr clause. Support for such list items in a use_device_ptr clause is deprecated." This PR downgrades the hard-error to a deprecated warning and "promotes" the above cases by simply moving the offending operands from the use_device_ptr value list to the back of the use_device_addr list (and moves the related symbols, locs and types that form the BlockArgs correspondingly) and then the generation of the target data construct proceeds as normal.
65 lines
2.2 KiB
Fortran
65 lines
2.2 KiB
Fortran
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
|
|
! OpenMP Version 5.0
|
|
! 2.10.1 use_device_ptr clause
|
|
! List item in USE_DEVICE_PTR clause must not be structure element.
|
|
! List item in USE_DEVICE_PTR clause must be of type C_PTR.
|
|
! List items that appear in a use_device_ptr clause can not appear in
|
|
! use_device_addr clause.
|
|
! Same list item can not be present multiple times or in multipe
|
|
! USE_DEVICE_PTR clauses.
|
|
|
|
subroutine omp_target_data
|
|
use iso_c_binding
|
|
integer :: a(1024)
|
|
type(C_PTR) :: b
|
|
integer, pointer :: arrayB
|
|
type my_type
|
|
type(C_PTR) :: my_cptr
|
|
end type my_type
|
|
|
|
type(my_type) :: my_var
|
|
a = 1
|
|
|
|
!ERROR: A variable that is part of another variable (structure element) cannot appear on the TARGET DATA USE_DEVICE_PTR clause
|
|
!$omp target data map(tofrom: a, arrayB) use_device_ptr(my_var%my_cptr)
|
|
allocate(arrayB)
|
|
call c_f_pointer(my_var%my_cptr, arrayB)
|
|
a = arrayB
|
|
!$omp end target data
|
|
|
|
!WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead
|
|
!$omp target data map(tofrom: a) use_device_ptr(a)
|
|
a = 2
|
|
!$omp end target data
|
|
|
|
!ERROR: List item 'b' present at multiple USE_DEVICE_PTR clauses
|
|
!$omp target data map(tofrom: a, arrayB) use_device_ptr(b) use_device_ptr(b)
|
|
allocate(arrayB)
|
|
call c_f_pointer(b, arrayB)
|
|
a = arrayB
|
|
!$omp end target data
|
|
|
|
!ERROR: List item 'b' present at multiple USE_DEVICE_PTR clauses
|
|
!$omp target data map(tofrom: a, arrayB) use_device_ptr(b,b)
|
|
allocate(arrayB)
|
|
call c_f_pointer(b, arrayB)
|
|
a = arrayB
|
|
!$omp end target data
|
|
|
|
!ERROR: Variable 'b' may not appear on both USE_DEVICE_PTR and USE_DEVICE_ADDR clauses on a TARGET DATA construct
|
|
!$omp target data map(tofrom: a, arrayB) use_device_addr(b) use_device_ptr(b)
|
|
allocate(arrayB)
|
|
call c_f_pointer(b, arrayB)
|
|
a = arrayB
|
|
!$omp end target data
|
|
|
|
!ERROR: Variable 'b' may not appear on both USE_DEVICE_PTR and USE_DEVICE_ADDR clauses on a TARGET DATA construct
|
|
!$omp target data map(tofrom: a, arrayB) use_device_ptr(b) use_device_addr(b)
|
|
allocate(arrayB)
|
|
call c_f_pointer(b, arrayB)
|
|
a = arrayB
|
|
!$omp end target data
|
|
|
|
end subroutine omp_target_data
|
|
|