OpenMP 5.0 adds a new clause in_reduction on OpenMP task directive. This patch adds parser support for the same.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the patch @NimishMishra
LGTM. Please wait for others to review and approve.
Please add a parse-tree test for this, like this one - https://github.com/llvm/llvm-project/blob/main/flang/test/Parser/omp-sections.f90
Why is the file name "omp-block-construct-unparse.f90"? We want to test in_reduction clause, why not add an omp task pragma unparsing test (if not already there). The name of the testfile is a little misleading. Same thing for the parse-tree tests. Rest LGTM.
I actually checked the current files in https://github.com/llvm/llvm-project/tree/main/flang/test/Parser and wondered if I should include one file that would contain all tests related to block constructs that we include in future. Many block construct related directives are absent in the flang/test/Parser directory; but I wondered we can condense any block directive incoming in future into this file. Let me know what you think about this.
Does this need changes in flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp? @kiranchandramohan
flang/include/flang/Parser/parse-tree.h | ||
---|---|---|
3437 |
I actually checked the current files in https://github.com/llvm/llvm-project/tree/main/flang/test/Parser and wondered if I should include one file that would contain all tests related to block constructs that we include in future. Many block construct related directives are absent in the flang/test/Parser directory; but I wondered we can condense any block directive incoming in future into this file. Let me know what you think about this.
I am assuming you are talking about OpenMP Block constructs and not there is no block construct in core fortran. In that case, their tests should be separated IMO. "omp-parallel-unparse.f90" should be separated from "omp-task-unparse.f90" as they are easily distinguishable. Nevertheless, I don't have a very strong opinion on this and am okay with "omp-block-construct-unparse.f90" too, but please add parse tree tests.
Minor comments. Thank you!
flang/test/Parser/omp-task-unparse.f90 | ||
---|---|---|
5 ↗ | (On Diff #430573) | Are you sure this program is semantically correct? I think an in_reduction clause must be enclosed inside task_reduction or some form of reduction clause. Having it at the top level could be an error, but I could be wrong. If it is not an error this is okay, otherwise a simple solution would be to change this to a subroutine instead of a program. |
7 ↗ | (On Diff #430573) | Please add some code in the structured block, maybe an x = x+1 or something actually reducing on x. Also just a suggestion, maybe check if it is generated while unparsing (to make sure we walk the children of such a node). |
flang/test/Semantics/omp-clause-validity01.f90 | ||
66 ↗ | (On Diff #430573) | Why are we adding semantics test when we have no semantic checks for this clause yet? IMO we should not be adding this test right now. Anyways, if you decide to add this test, maybe add it as a separate test because private(b) and in_reduction(+:b) are probably conflicting. Also, please add some reducing code inside the structured block. |
It reports something like the following for the in_reduction clause which seems OK. You can build the tool with -DFLANG_BUILD_EXAMPLES=On and check with check-flang-examples. Run the tool like
$BUILD_DIR/bin/flang-new -fc1 -load $BUILD_DIR/lib/flangOmpReport.so -plugin flang-omp-report -fopenmp $FILE_NAME -o -
construct: task clauses: - clause: in_reduction details: '+:z'
flang/test/Semantics/omp-clause-validity01.f90 | ||
---|---|---|
66 ↗ | (On Diff #430573) | Possibly, it is checking the allowed clauses that are automatically created due to entries in OMP.td. Not clear whether it is allowed or not. But something simple and separate would be better. !$omp taskgroup task_reduction(+:z) !$omp task in_reduction(+:z) z = z + 5 !$omp end task !$omp end taskgroup We might also need to ask the task modifier to the regular reduction clause sometime. |