This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Added parser support for in_reduction clause on OpenMP Task directive
ClosedPublic

Authored by NimishMishra on Apr 21 2022, 2:34 AM.

Details

Summary

OpenMP 5.0 adds a new clause in_reduction on OpenMP task directive. This patch adds parser support for the same.

Diff Detail

Event Timeline

NimishMishra created this revision.Apr 21 2022, 2:34 AM
Herald added a project: Restricted Project. · View Herald Transcript
NimishMishra requested review of this revision.Apr 21 2022, 2:34 AM
Herald added a project: Restricted Project. · View Herald Transcript

Thanks for the patch @NimishMishra
LGTM. Please wait for others to review and approve.

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.

shraiysh requested changes to this revision.Apr 25 2022, 8:36 PM
This revision now requires changes to proceed.Apr 25 2022, 8:36 PM

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.

Addressed comments

shraiysh accepted this revision.May 19 2022, 10:37 PM

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.

This revision is now accepted and ready to land.May 19 2022, 10:37 PM
peixin accepted this revision.May 20 2022, 12:39 AM

Does this need changes in flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp? @kiranchandramohan

LGTM. Please wait for @kiranchandramohan 's comments about this.

Does this need changes in flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp? @kiranchandramohan

LGTM. Please wait for @kiranchandramohan 's comments about this.

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.

NimishMishra marked 4 inline comments as done.
NimishMishra added inline comments.
flang/test/Parser/omp-task-unparse.f90
5 ↗(On Diff #430573)

Could you check this updated test case?

flang/test/Semantics/omp-clause-validity01.f90
66 ↗(On Diff #430573)

I think @shraiysh is right in mentioning that I shouldn't be touching the semantics side of things. Removed the test case.

NimishMishra marked an inline comment as done.
This revision was landed with ongoing or failed builds.Jun 6 2022, 2:24 AM
This revision was automatically updated to reflect the committed changes.