Skip to content

Kernels could be mapped to target data clauses #14

Open
@Pennycook

Description

@Pennycook

As noted in the README, the experimental support for the kernels directive currently produces empty target regions that need to be manually corrected. In the code I'm working with, it seems like it would be possible to map kernels to target enter/target exit regions instead. I think this transformation might be safer.

Original

subroutine foo(a, b, n)
  implicit none
  integer :: a(:)
  integer :: b(:)
  integer :: n
  integer :: i

!$acc kernels copyin(a)
!$acc loop
do i=1,n
  b(i) = a(i) + 1
enddo
!$acc end kernels

end subroutine foo

Migrated

subroutine foo(a, b, n)
  implicit none
  integer :: a(:)
  integer :: b(:)
  integer :: n
  integer :: i

!$omp target map(to:a)
!$omp end target
!$omp target teams loop
do i=1,n
  b(i) = a(i) + 1
enddo

end subroutine foo

Expected

subroutine foo(a, b, n)
  implicit none
  integer :: a(:)
  integer :: b(:)
  integer :: n
  integer :: i

!$omp target enter data map(to:a)
!$omp target teams loop
do i=1,n
  b(i) = a(i) + 1
enddo
!$omp end target teams loop
!$omp target exit data map(release:a)

end subroutine foo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions