[PATCH] D107430: [OMPIRBuilder] Add ordered directive to OMPIRBuilder

Peixin Qiao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 17 06:27:25 PDT 2021


peixin updated this revision to Diff 366879.
peixin retitled this revision from "[OMPIRBuilder] Add ordered without depend and simd clause to OMPBuilder" to "[OMPIRBuilder] Add ordered directive to OMPIRBuilder".
peixin edited the summary of this revision.
peixin added a comment.

Support ordered directive in OMPIRBuilder to OMP 5.0 standard. That is, support ordered directive without clause, with threads, simd or depend clause.

Without clause specified, it behaves as if the threads clause is specified. With the threads clause specified, emit the entry and exit function calls before and after the inlined statements inside ordered region.

To understand simd clause specified, we need to look at the history commits for ordered codegen in clang Non-OMPIRBuilder code. The ordered simd codegen was implemented by Alexey Bataev to generate the outlined function for the statements inside ordered region (llvm-svn: 248772). Joseph Huber adds the always inline attribute to the outlined function when the optimization option is enabled since it is safe and it could potentially lead to performance degredation due to
inflated register counts in the parallel region (https://reviews.llvm.org/D106799). Alexey Batave supports the exception throw in llvm-svn 210098. According to OMP 5.0 standard, for C++ code, a throw executed inside a ordered region must cause execution to resume within the smae ordered region, and the same thread that threw the exception must catch it. I keep the Non-OMPIRBuilder code design and add one more EmitCaptureStmt function in OMPBuilderCBHelpers to support the exception throw for ordered simd.

With depend clause specified, the works can be split into three steps, analyzing the expressions of depend vector such as "(i, j-1) of depend(sink: i, j-1)", store the analyzed result values into depend vector, and generate runtime function call with the depend vector base address argument. I leave the analyzing experssions work in clang codegen since it is a little bit complicated to do it in OMPIRBuilder. Instead, several lines of code are enough in clang codegen. The code for other two steps are refactored in OMPIRBuilder.


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

https://reviews.llvm.org/D107430

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  clang/test/OpenMP/ordered_doacross_codegen.c
  clang/test/OpenMP/ordered_doacross_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107430.366879.patch
Type: text/x-patch
Size: 119656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210817/61a0aebd/attachment-0001.bin>


More information about the cfe-commits mailing list