forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP] PFT-based detection of target SPMD
This patch improves the fix in #125 to detect target SPMD kernels during Flang lowering to MLIR. It transitions from a MLIR-based check to a PFT-based check, which is a more resilient alternative since the MLIR representation is in process of being built where it's being checked.
- Loading branch information
Showing
2 changed files
with
312 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: func.func @_QPdistribute_parallel_do_generic() { | ||
subroutine distribute_parallel_do_generic() | ||
! CHECK: omp.target | ||
! CHECK-NOT: trip_count({{.*}}) | ||
! CHECK-SAME: { | ||
!$omp target | ||
!$omp teams | ||
!$omp distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do | ||
call bar() | ||
!$omp end teams | ||
!$omp end target | ||
|
||
! CHECK: omp.target | ||
! CHECK-NOT: trip_count({{.*}}) | ||
! CHECK-SAME: { | ||
!$omp target teams | ||
!$omp distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do | ||
call bar() | ||
!$omp end target teams | ||
end subroutine distribute_parallel_do_generic | ||
|
||
! CHECK-LABEL: func.func @_QPdistribute_parallel_do_spmd() { | ||
subroutine distribute_parallel_do_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target | ||
!$omp teams | ||
!$omp distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do | ||
!$omp end teams | ||
!$omp end target | ||
|
||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target teams | ||
!$omp distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do | ||
!$omp end target teams | ||
end subroutine distribute_parallel_do_spmd | ||
|
||
! CHECK-LABEL: func.func @_QPdistribute_parallel_do_simd_generic() { | ||
subroutine distribute_parallel_do_simd_generic() | ||
! CHECK: omp.target | ||
! CHECK-NOT: trip_count({{.*}}) | ||
! CHECK-SAME: { | ||
!$omp target | ||
!$omp teams | ||
!$omp distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do simd | ||
call bar() | ||
!$omp end teams | ||
!$omp end target | ||
|
||
! CHECK: omp.target | ||
! CHECK-NOT: trip_count({{.*}}) | ||
! CHECK-SAME: { | ||
!$omp target teams | ||
!$omp distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do simd | ||
call bar() | ||
!$omp end target teams | ||
end subroutine distribute_parallel_do_simd_generic | ||
|
||
! CHECK-LABEL: func.func @_QPdistribute_parallel_do_simd_spmd() { | ||
subroutine distribute_parallel_do_simd_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target | ||
!$omp teams | ||
!$omp distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do simd | ||
!$omp end teams | ||
!$omp end target | ||
|
||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target teams | ||
!$omp distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end distribute parallel do simd | ||
!$omp end target teams | ||
end subroutine distribute_parallel_do_simd_spmd | ||
|
||
! CHECK-LABEL: func.func @_QPteams_distribute_parallel_do_spmd() { | ||
subroutine teams_distribute_parallel_do_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target | ||
!$omp teams distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end teams distribute parallel do | ||
!$omp end target | ||
end subroutine teams_distribute_parallel_do_spmd | ||
|
||
! CHECK-LABEL: func.func @_QPteams_distribute_parallel_do_simd_spmd() { | ||
subroutine teams_distribute_parallel_do_simd_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target | ||
!$omp teams distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end teams distribute parallel do simd | ||
!$omp end target | ||
end subroutine teams_distribute_parallel_do_simd_spmd | ||
|
||
! CHECK-LABEL: func.func @_QPtarget_teams_distribute_parallel_do_spmd() { | ||
subroutine target_teams_distribute_parallel_do_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target teams distribute parallel do | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end target teams distribute parallel do | ||
end subroutine target_teams_distribute_parallel_do_spmd | ||
|
||
! CHECK-LABEL: func.func @_QPtarget_teams_distribute_parallel_do_simd_spmd() { | ||
subroutine target_teams_distribute_parallel_do_simd_spmd() | ||
! CHECK: omp.target | ||
! CHECK-SAME: trip_count({{.*}}) | ||
!$omp target teams distribute parallel do simd | ||
do i = 1, 10 | ||
call foo(i) | ||
end do | ||
!$omp end target teams distribute parallel do simd | ||
end subroutine target_teams_distribute_parallel_do_simd_spmd |