[PATCH] D90830: [OpenMPIRBuilder] Implement CreateCanonicalLoop.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 00:48:08 PST 2020


Meinersbur created this revision.
Meinersbur added reviewers: jdoerfert, AMDChirag, anchu-rajendran, kiranchandramohan, AlexisPerry, SouraVX, kiranktp, fghanim.
Meinersbur added a project: LLVM.
Herald added subscribers: guansong, hiraditya, yaxunl.
Meinersbur requested review of this revision.
Herald added a subscriber: sstefan1.

CreateCanonicalLoop generates a standardized control flow structure for OpenMP canonical for loops. The structure can be consumed by loop-associated directives such as worksharing-loop, distribute, simd etc. as well as loop transformations such as tile and unroll.

This is a first design without considering all complexities yet. The control-flow emits more basic block than strictly necessary, but these will be optimized by CFGSimplify anyway, provide a nice separation of concerns and might later be useful with more complex scenarios. I successfully implemented a basic tile construct using this API, which is not part of this patch.

The fundamental building block is the CreateCanonicalLoop that only takes the loop trip count and operates on the logical iteration spaces only. An overloaded CreateCanonicalLoop for using LB, UB, Increment is provided as well, but at least for C++, Clang will need to implement a loop counter to logical induction variable mapping anyway, since iterator overload resolution cannot be done in LLVMFrontend.

As there currently is no user for CreateCanonicalLoop, it is only called from unittests. Similarly, CanonicalLoopInfo::eraseFromParent() is used in my file implementation and might be generally useful for implementing loop-associated constructs, but is not used in this patch itself.

The following non-exhaustive list describes not yet covered items:

- collapse clause (including non-rectangular and non-perfectly nested); idea is to provide a OpenMPIRBuilder::collapseLoopNest method consuming multiple nested loops and returning a new CanonicalLoopInfo that can be used for loop-associated directives.
- simarly: ordered clause for DOACROSS loops
- Cancellation point (?)
- AllocaIP
- break statement (if needed at all)
- Exceptions (if not completely handled in the front-end)
- As OutlineInfo is delayed to the finalize method (why?), applying loop-associated directive may need to be delayed as well (at latest when OpenMP 6.0 allows applying loops transformations on chunked loops).
  - Using it in Clang; this requires implementing at least one loop-associated construct.
- ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90830

Files:
  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: D90830.303049.patch
Type: text/x-patch
Size: 23171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201105/5b29d8a7/attachment.bin>


More information about the llvm-commits mailing list