[PATCH] D90697: [Flang][OpenMP 4.5] Add semantic check for OpenMP Reduction Clause

Yashaswini Hegde via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 22:36:42 PST 2021


yhegde updated this revision to Diff 328384.
yhegde added a comment.

This patch is updated after addressing the review comments.

However there is an error in the build. 
The following sections from the omp-firstprivate01.f90 is the source.

  !$omp parallel reduction(+:a)
  !$omp sections firstprivate(a, b)
  !$omp section 
   c = c * a + b
  !$omp end sections
  !$omp end parallel
  
  
  !$omp parallel reduction(-:a)
  !$omp task firstprivate(a,b)
   c =  c - a * b
  !$omp end task
  !$omp end parallel

With the above test case
The "enclosingContext{GetEnclosingDirContext()" is returning reduction clause causing the error as - 
"REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the "worksharing" construct bind."

This is because as it appears to me, that the each directive context is pushed including end sections
( void OmpStructureChecker::Enter(const parser::OmpEndSectionsDirective &x) {

  case llvm::omp::Directive::OMPD_sections:
  PushContextAndClauseSets(
      dir.source, llvm::omp::Directive::OMPD_end_sections);
  break;

)
 but there is no corresponding pop for the end sections . This is probably because by the std. it is "There is an implicit barrier at the end of a sections construct unless a nowait clause is specified "  
( https://www.openmp.org/wp-content/uploads/openmp-4.5.pdf :page 66 )

And it looks to me that  "no wait" is not yet implemented and that could be the cause of error for all the worksharing constructs, because the implementation of nowait may have a corresponding pop (dirContext_.pop_back();).

I request the reviewer's suggestions to handle this case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90697/new/

https://reviews.llvm.org/D90697

Files:
  flang/lib/Semantics/check-directive-structure.h
  flang/lib/Semantics/check-omp-structure.cpp
  flang/lib/Semantics/check-omp-structure.h
  flang/lib/Semantics/resolve-directives.cpp
  flang/test/Semantics/omp-firstprivate01.f90
  flang/test/Semantics/omp-reduction01.f90
  flang/test/Semantics/omp-reduction02.f90
  flang/test/Semantics/omp-reduction03.f90
  flang/test/Semantics/omp-reduction04.f90
  flang/test/Semantics/omp-reduction05.f90
  flang/test/Semantics/omp-reduction06.f90
  flang/test/Semantics/omp-reduction07.f90
  flang/test/Semantics/omp-reduction08.f90
  flang/test/Semantics/omp-reduction09.f90
  flang/test/Semantics/omp-reduction10.f90
  flang/test/Semantics/omp-symbol08.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90697.328384.patch
Type: text/x-patch
Size: 31082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210305/aff79c17/attachment.bin>


More information about the llvm-commits mailing list