-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP][Lower] Support lowering of
teams
directive to MLIR
This patch adds support for translating `teams` OpenMP directives to MLIR, when appearing as either loop or block constructs and as part of combined constructs or on its own. The current Fortran parser does not allow the specification of the optional lower bound for the "num_teams" clause, so only the `num_teams_upper` MLIR argument is set by this patch. Depends on D156809 Differential Revision: https://reviews.llvm.org/D156884
- Loading branch information
Showing
4 changed files
with
251 additions
and
6 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,12 @@ | ||
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s | ||
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s | ||
|
||
! CHECK: not yet implemented: Reduction of TEAMS directive | ||
subroutine reduction_teams() | ||
integer :: i | ||
i = 0 | ||
|
||
!$omp teams reduction(+:i) | ||
i = i + 1 | ||
!$omp end teams | ||
end subroutine reduction_teams |
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,114 @@ | ||
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: func @_QPteams_simple | ||
subroutine teams_simple() | ||
! CHECK: omp.teams | ||
!$omp teams | ||
! CHECK: fir.call | ||
call f1() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
end subroutine teams_simple | ||
|
||
!=============================================================================== | ||
! `num_teams` clause | ||
!=============================================================================== | ||
|
||
! CHECK-LABEL: func @_QPteams_numteams | ||
subroutine teams_numteams(num_teams) | ||
integer, intent(inout) :: num_teams | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: num_teams( to %{{.*}}: i32) | ||
!$omp teams num_teams(4) | ||
! CHECK: fir.call | ||
call f1() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: num_teams( to %{{.*}}: i32) | ||
!$omp teams num_teams(num_teams) | ||
! CHECK: fir.call | ||
call f2() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
end subroutine teams_numteams | ||
|
||
!=============================================================================== | ||
! `if` clause | ||
!=============================================================================== | ||
|
||
! CHECK-LABEL: func @_QPteams_if | ||
subroutine teams_if(alpha) | ||
integer, intent(in) :: alpha | ||
logical :: condition | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: if(%{{.*}}) | ||
!$omp teams if(.false.) | ||
! CHECK: fir.call | ||
call f1() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: if(%{{.*}}) | ||
!$omp teams if(alpha .le. 0) | ||
! CHECK: fir.call | ||
call f2() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: if(%{{.*}}) | ||
!$omp teams if(condition) | ||
! CHECK: fir.call | ||
call f3() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
end subroutine teams_if | ||
|
||
!=============================================================================== | ||
! `thread_limit` clause | ||
!=============================================================================== | ||
|
||
! CHECK-LABEL: func @_QPteams_threadlimit | ||
subroutine teams_threadlimit(thread_limit) | ||
integer, intent(inout) :: thread_limit | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: thread_limit(%{{.*}}: i32) | ||
!$omp teams thread_limit(4) | ||
! CHECK: fir.call | ||
call f1() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
! CHECK: omp.teams | ||
! CHECK-SAME: thread_limit(%{{.*}}: i32) | ||
!$omp teams thread_limit(thread_limit) | ||
! CHECK: fir.call | ||
call f2() | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
|
||
end subroutine teams_threadlimit | ||
|
||
!=============================================================================== | ||
! `allocate` clause | ||
!=============================================================================== | ||
|
||
! CHECK-LABEL: func @_QPteams_allocate | ||
subroutine teams_allocate() | ||
use omp_lib | ||
integer :: x | ||
! CHECK: omp.teams | ||
! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) | ||
!$omp teams allocate(omp_high_bw_mem_alloc: x) private(x) | ||
! CHECK: arith.addi | ||
x = x + 12 | ||
! CHECK: omp.terminator | ||
!$omp end teams | ||
end subroutine teams_allocate |