Skip to content

Commit

Permalink
[flang][OpenMP] Added support for lowering OpenMP taskyield construct
Browse files Browse the repository at this point in the history
Summary:
This patch lower `!OMP TASKYIELD` construct from PFT to
OpenMPDialect operations.
Construct is lowered with conformance to OpenMP 5.0 spec.

Patch is carved out of following merged PR:
flang-compiler/f18-llvm-project#297

Reviewed: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D84350
  • Loading branch information
SouraVX committed Jul 23, 2020
1 parent b27ab9c commit 9e4ab43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flang/lib/Lower/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ static void genOMP(Fortran::lower::AbstractConverter &absConv,
absConv.getCurrentLocation());
break;
case llvm::omp::Directive::OMPD_taskyield:
TODO();
absConv.getFirOpBuilder().create<mlir::omp::TaskyieldOp>(
absConv.getCurrentLocation());
break;
case llvm::omp::Directive::OMPD_target_enter_data:
TODO();
case llvm::omp::Directive::OMPD_target_exit_data:
Expand Down
15 changes: 15 additions & 0 deletions flang/unittests/Lower/OpenMPLoweringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,19 @@ TEST_F(OpenMPLoweringTest, TaskWait) {
EXPECT_EQ(succeeded(taskWaitOp.verify()), true);
}

TEST_F(OpenMPLoweringTest, TaskYield) {
// Construct a dummy parse tree node for `!OMP taskyield`.
struct Fortran::parser::OmpSimpleStandaloneDirective taskYieldDirective(
llvm::omp::Directive::OMPD_taskyield);

// Check and lower the `!OMP taskyield` node to `TaskYieldOp` operation of
// OpenMPDialect.
EXPECT_EQ(taskYieldDirective.v, llvm::omp::Directive::OMPD_taskyield);
auto taskYieldOp = mlirOpBuilder->create<mlir::omp::TaskyieldOp>(
mlirOpBuilder->getUnknownLoc());

EXPECT_EQ(taskYieldOp.getOperationName(), "omp.taskyield");
EXPECT_EQ(succeeded(taskYieldOp.verify()), true);
}

// main() from gtest_main

0 comments on commit 9e4ab43

Please sign in to comment.