This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Fix semantic check of test case in taskloop simd construct
ClosedPublic

Authored by peixin on Jul 12 2021, 11:33 PM.

Details

Summary

The following semantic check is removed in OpenMP Version 5.0:

Taskloop simd construct restrictions: No reduction clause can be specified.

Also fix several typos.

Diff Detail

Event Timeline

peixin created this revision.Jul 12 2021, 11:33 PM
peixin requested review of this revision.Jul 12 2021, 11:34 PM
peixin updated this revision to Diff 358184.Jul 13 2021, 12:55 AM

Add ! REQUIRES: shell in omp-taskloop-simd01.f90.

kiranchandramohan requested changes to this revision.Jul 13 2021, 5:29 AM

Thanks, @peixin for this patch. Also great to see you here.

The recommendation is to provide the full context when submitting patches. I think if you use arcanist, this happens by default. If you use the web interface then there are some recommended commands to use to get the full context. Please see the following links.
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface

Also, could you point me to the place in the standard where this restriction is specified?

flang/lib/Semantics/check-omp-structure.cpp
1035

I think would be better to say that reduction is not expected for taskloop simd? Or is this a common pattern that we have in semantic errors?

I think we capitalize the name of constructs when we report errors. Please check other errors and capitalize if needed.

This revision now requires changes to proceed.Jul 13 2021, 5:29 AM
peixin updated this revision to Diff 358246.Jul 13 2021, 6:26 AM
peixin added a reviewer: bryanpkc.
peixin updated this revision to Diff 358251.Jul 13 2021, 6:39 AM

@kiranchandramohan Thanks for the guide to submit patches and the comments.

The standard is at page 92 in openmp-4.5 specification, which I quote:

Restrictions
The restrictions for the taskloop and simd constructs apply.
No reduction clause can be specified.

I argee that saying the clause is not allowed in the directive is better. Changed the code fix and test case error info. It is common semantic check in DirectiveStructureChecker in flang/lib/Semantics/check-directive-structure.h, which I quote in the following:

if (!GetContext().allowedClauses.test(clause) &&
    !GetContext().allowedOnceClauses.test(clause) &&
    !GetContext().allowedExclusiveClauses.test(clause) &&
    !GetContext().requiredClauses.test(clause)) {
  context_.Say(GetContext().clauseSource,
      "%s clause is not allowed on the %s directive"_err_en_US,
      parser::ToUpperCaseLetters(getClauseName(clause).str()),
      parser::ToUpperCaseLetters(GetContext().directiveSource.ToString()));
  return;
}

The reason why it is not checked in DirectiveStructureChecker is the clause OMPC_Reduction is defined inside OMP_TaskLoopSimd in llvm/include/llvm/Frontend/OpenMP/OMP.td.
I also noticed that there is no this restriction in openmp-5.0 specification.

The reason why it is not checked in DirectiveStructureChecker is the clause OMPC_Reduction is defined inside OMP_TaskLoopSimd in llvm/include/llvm/Frontend/OpenMP/OMP.td.
I also noticed that there is no this restriction in openmp-5.0 specification.

I think this is going against the generic directive checker. If the clause is set as allowed in the OMP.td file it should be allowed. Since the file is shared with clang the semantic should be done on version 5.0 or 5.1.

peixin added a comment.EditedJul 13 2021, 8:43 AM

@clementval Yes, I agree. I did not notice that this restriction was deleted in Openmp-5.0 standard when I upload the first version of this patch. Do you think if I should fix the restriction info in omp-taskloop-simd01.f90 and the typos in omp-clause-validity01.f90, and change the commit message by stating that this restriction is deleted in openmp version 5.0?

@clementval Yes, I agree. I did not notice that this restriction was deleted in Openmp-5.0 standard when I upload the first version of this patch. Do you think if I should fix the restriction info in omp-taskloop-simd01.f90 and the typos in omp-clause-validity01.f90, and change the commit message by stating that this restriction is deleted in openmp version 5.0?

Yes, please do.

peixin updated this revision to Diff 358482.Jul 13 2021, 6:34 PM
peixin retitled this revision from [flang][OpenMP] Add semantic check for reduction clause in taskloop simd construct to [flang][OpenMP] Fix semantic check of test case in taskloop simd construct.
peixin edited the summary of this revision. (Show Details)
peixin set the repository for this revision to rG LLVM Github Monorepo.

Thanks for the comments. Update the following:

  1. Remove the semantic check of taskloop simd reduction in check-omp-structrue.cpp.
  2. Fix the test case of omp-taskloop-simd01.f90 according to OpenMP 5.0 specification.
  3. Fix the title and summary.
This revision is now accepted and ready to land.Jul 14 2021, 12:58 AM

Let me know if you don't have commit access and would need help to land this patch.

I will land this patch for him @kiranchandramohan , thanks for reviewing.