-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Flang][OpenMP] Add LLVM translation support for UNTIED clause in Task #115283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang][OpenMP] Add LLVM translation support for UNTIED clause in Task #115283
Conversation
Implementation details: The UNTIED clause is recognized by setting the flag=0 for the default case or performing logical OR to flag if other clauses are specified, and this flag is passed as an argument to the `__kmpc_omp_task_alloc` runtime call.
@llvm/pr-subscribers-mlir-openmp @llvm/pr-subscribers-flang-openmp Author: Thirumalai Shaktivel (Thirumalai-Shaktivel) ChangesImplementation details: Full diff: https://github.com/llvm/llvm-project/pull/115283.diff 4 Files Affected:
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 4f9e2347308aa1..597871fb41f6aa 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2844,6 +2844,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
!std::holds_alternative<clause::UseDevicePtr>(clause.u) &&
!std::holds_alternative<clause::InReduction>(clause.u) &&
!std::holds_alternative<clause::Mergeable>(clause.u) &&
+ !std::holds_alternative<clause::Untied>(clause.u) &&
!std::holds_alternative<clause::TaskReduction>(clause.u)) {
TODO(clauseLocation, "OpenMP Block construct clause");
}
diff --git a/flang/test/Lower/OpenMP/Todo/task_untied.f90 b/flang/test/Lower/OpenMP/Todo/task_untied.f90
deleted file mode 100644
index 19621c7aac16d6..00000000000000
--- a/flang/test/Lower/OpenMP/Todo/task_untied.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-! 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
-
-!===============================================================================
-! `untied` clause
-!===============================================================================
-
-! CHECK: not yet implemented: OpenMP Block construct clause
-subroutine omp_task_untied()
- !$omp task untied
- call foo()
- !$omp end task
-end subroutine omp_task_untied
diff --git a/flang/test/Lower/OpenMP/task.f90 b/flang/test/Lower/OpenMP/task.f90
index 4f00f261fe57df..bf0f3574258076 100644
--- a/flang/test/Lower/OpenMP/task.f90
+++ b/flang/test/Lower/OpenMP/task.f90
@@ -245,3 +245,16 @@ subroutine task_multiple_clauses()
!CHECK: omp.terminator
!$omp end task
end subroutine task_multiple_clauses
+
+!===============================================================================
+! `untied` clause
+!===============================================================================
+
+!CHECK-LABEL: func.func @_QPomp_task_untied() {
+subroutine omp_task_untied()
+ !CHECK: omp.task untied {
+ !$omp task untied
+ call foo()
+ !CHECK: omp.terminator
+ !$omp end task
+end subroutine omp_task_untied
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index cdf94b1ceae11b..6eb9fbf0421311 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -3003,6 +3003,17 @@ module attributes {omp.is_target_device = true} {
// -----
+llvm.func @omp_task_untied() {
+ // The third argument is 0: which signifies the united task
+ // CHECK: {{.*}} = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %{{.*}}, i32 0, i64 40, i64 0, ptr @{{.*}})
+ omp.task untied {
+ omp.terminator
+ }
+ llvm.return
+}
+
+// -----
+
llvm.func external @foo_before() -> ()
llvm.func external @foo() -> ()
llvm.func external @foo_after() -> ()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you add a test showing what happens (TODO or correct behavior) if untied is used with taskloop.
Otherwise the changes look good.
See also the failing mlir test |
Yea, sure. I will check it out and report back. |
b5d84b3
to
7ea10e5
Compare
Taskloop doesn't have the OpenMP lowering support (it throws "not yet implemented: omp.taskloop"). |
7ea10e5
to
3006a54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. LGTM
This seems to be breaking one of the test-suite gfortran tests:
|
#115283)" This reverts commit 919aead. It breaks following LLVM bots: https://lab.llvm.org/buildbot/#/builders/199 https://lab.llvm.org/buildbot/#/builders/143 https://lab.llvm.org/buildbot/#/builders/17
I have temporarily reverted this change as it was breaking various LLVM bots due to failure of following LLVM testsuite GFortran tests: llvm-test-suite/Fortran/gfortran/regression/gomp/pr44085.f90 |
Implementation details: The UNTIED clause is recognized by setting the flag=0 for the default case or performing logical OR to flag if other clauses are specified, and this flag is passed as an argument to the `__kmpc_omp_task_alloc` runtime call. Resubmitting the PR with fix for the failure, as it was reverted here: 927a70d and previously merged here: #115283
…k (#121052) Implementation details: The UNTIED clause is recognized by setting the flag=0 for the default case or performing logical OR to flag if other clauses are specified, and this flag is passed as an argument to the `__kmpc_omp_task_alloc` runtime call. Resubmitting the PR with fix for the failure, as it was reverted here: 927a70d and previously merged here: llvm/llvm-project#115283
Implementation details:
The UNTIED clause is recognized by setting the flag=0 for the default case or performing logical OR to flag if other clauses are specified, and this flag is passed as an argument to the
__kmpc_omp_task_alloc
runtime call.