Skip to content

Conversation

skatrak
Copy link
Member

@skatrak skatrak commented Sep 23, 2024

This patch fixes TargetOp::getInnermostCapturedOmpOp() to avoid detecting as captured by the top target construct other constructs nested inside of a loop. This prevents the omp.target verifier from incorrectly flagging valid SPMD loops, like in the following example:

subroutine foo(n)
  implicit none
  integer, intent(in) :: n
  integer :: i, j

  !$omp target teams distribute parallel do
  do i=1,n
    !$omp simd
    do j=1,n
      call bar()
    enddo
  enddo
end subroutine foo

It's an improvement over the workaround implemented in #98, hopefully covering all cases.

This patch fixes `TargetOp::getInnermostCapturedOmpOp()` to avoid detecting as
captured by the top target construct other constructs nested inside of a loop.
This prevents the `omp.target` verifier from incorrectly flagging valid SPMD
loops, like in the following example:

```f90
subroutine foo(n)
  implicit none
  integer, intent(in) :: n
  integer :: i, j

  !$omp target teams distribute parallel do
  do i=1,n
    !$omp simd
    do j=1,n
      call bar()
    enddo
  enddo
end subroutine foo
```
Copy link

@dpalermo dpalermo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing (smoke & SPEC hpc/accel) looks good to me.

@dpalermo dpalermo merged commit 6d8995a into ROCm:amd-trunk-dev Sep 24, 2024
3 of 5 checks passed
@dpalermo
Copy link

Merged to get more coverage in tonight's build/testing.

@skatrak skatrak deleted the fix-spmd-nested-construct branch September 25, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants