-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[LLVM][OpenMP] Add "nowait" clause as valid for "workshare" #88426
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
Conversation
Add the "if" clause to the list of allowed clauses for the "workshare" directive.
@llvm/pr-subscribers-flang-semantics @llvm/pr-subscribers-flang-openmp Author: Krzysztof Parzyszek (kparzysz) ChangesAdd the "if" clause to the list of allowed clauses for the "workshare" directive. Full diff: https://github.com/llvm/llvm-project/pull/88426.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index d9a931438b4292..e91169e8da1aa5 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -2115,6 +2115,9 @@ def OMP_scope : Directive<"scope"> {
let association = AS_Block;
}
def OMP_Workshare : Directive<"workshare"> {
+ let allowedOnceClauses = [
+ VersionedClause<OMPC_NoWait>
+ ];
let association = AS_Block;
}
def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
|
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.
LGTM: nowait has been part of OpenMP since 4.5 (or earlier, I didn't check 4.0).
It'd be nice if you added a clang/test/OpenMP minimal test. I checked and I couldn't find a single parse test for the workshare directive.
Edit: turns out there is a semantics test for it already (line 339, flang/test/Semantics/OpenMP/clause-validity01.f90):
|
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.
LG.
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.
Sorry. It is already there in "End Workshare".
All directives that have "DIR/END DIR" format in Fortran, allow the clauses from the "END DIR" to be present in "DIR" (since there is no "END DIR" in C/C++). Workshare (being Fortran-only) is the only one that doesn't allow it. Not having the consistency makes it harder to handle OpenMP constructs with language-agnostic code. |
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.
That makes sense. Please wait for @mjklemm or @kkwli before proceeding. If you are going ahead might be good to call this out in https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md
Looking at other compilers. gfortran seems to accept it, ifx and classic flang rejects.
Not having the consistency makes it harder to handle OpenMP constructs with language-agnostic code.
It wasn't clear from the title that this is deviating from the standard specification for ease of implementation.
Add the "if" clause to the list of allowed clauses for the "workshare" directive.
"if" -> "nowait"
As far as I understand, |
It was a good catch on your side. I was testing my code that relied on this (which I had forgotten about). When I created the PR I honestly thought that this is where the "nowait" clause was supposed to be. Only after you pointed out the "end workshare" when I realized what really happened. |
The flang parser actually checks for such cases explicitly, and rejects cases of "nowait" on directives that allow it based on the .td contents, but where Fortran syntax requires them to be on the "end" directive. I added "workshare" to the list, and updated the testcase. I have checked that "copyprivate" on "!$omp single" is rejected as well. In the current form this PR will not have any effect on the accepted syntax, it will simply allow "nowait" to be associated with "workshare" internally to the compiler. |
Add the "nowait" clause to the list of allowed clauses for the "workshare" directive. This will make it consistent with other directives (which are shared between C/C++ and Fortran). The parser will still reject "nowait" on "!$omp workshare", so this has no effect on accepting/rejecting Fortran source code.
Add the "nowait" clause to the list of allowed clauses for the "workshare"
directive. This will make it consistent with other directives (which are
shared between C/C++ and Fortran).
The parser will still reject "nowait" on "!$omp workshare", so this has no
effect on accepting/rejecting Fortran source code.