Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from pars…
…e tree to MLIR This patch implements the lowering of the OpenMP 'requires' directive from Flang parse tree to MLIR attributes attached to the top-level module. Target-related 'requires' clauses are gathered and combined for each top-level unit during semantics. Lastly, a single module-level `omp.requires` attribute is attached to the MLIR module with that information at the end of the process. The `atomic_default_mem_order` clause is not addressed by this patch, but rather it will come as a separate patch and follow a different approach. Depends on D147214, D150328, D150329 and D157983. Differential Revision: https://reviews.llvm.org/D147218
- Loading branch information
Showing
7 changed files
with
254 additions
and
34 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
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,23 @@ | ||
! This test checks the lowering of REQUIRES inside of an unnamed BLOCK DATA. | ||
! The symbol of the `symTab` scope of the `BlockDataUnit` PFT node is null in | ||
! this case, resulting in the inability to store the REQUIRES flags gathered in | ||
! it. | ||
|
||
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s | ||
! XFAIL: * | ||
|
||
!CHECK: module attributes { | ||
!CHECK-SAME: omp.requires = #omp<clause_requires unified_shared_memory> | ||
block data | ||
!$omp requires unified_shared_memory | ||
integer :: x | ||
common /block/ x | ||
data x / 10 / | ||
end | ||
|
||
subroutine f | ||
!$omp declare target | ||
end subroutine f |
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,19 @@ | ||
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s | ||
|
||
! This test checks the lowering of requires into MLIR | ||
|
||
!CHECK: module attributes { | ||
!CHECK-SAME: omp.requires = #omp<clause_requires unified_shared_memory> | ||
block data init | ||
!$omp requires unified_shared_memory | ||
integer :: x | ||
common /block/ x | ||
data x / 10 / | ||
end | ||
|
||
subroutine f | ||
!$omp declare target | ||
end subroutine f |
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,14 @@ | ||
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s | ||
|
||
! This test checks that requires lowering into MLIR skips creating the | ||
! omp.requires attribute with target-related clauses if there are no device | ||
! functions in the compilation unit | ||
|
||
!CHECK: module attributes { | ||
!CHECK-NOT: omp.requires | ||
program requires | ||
!$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst) | ||
end program requires |
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,14 @@ | ||
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s | ||
! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s | ||
|
||
! This test checks the lowering of requires into MLIR | ||
|
||
!CHECK: module attributes { | ||
!CHECK-SAME: omp.requires = #omp<clause_requires reverse_offload|unified_shared_memory> | ||
program requires | ||
!$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst) | ||
!$omp target | ||
!$omp end target | ||
end program requires |