This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][MLIR]Add support for guided, auto and runtime scheduling
ClosedPublic

Authored by Leporacanthicus on Apr 28 2021, 2:35 AM.

Details

Summary

When using parallel loop construct, the OpenMP specification allows for
guided, auto and runtime as scheduling variants (as well as static and
dynamic which are already supported).

This adds the translation from MLIR to LLVM-IR for these scheduling
variants.

Diff Detail

Event Timeline

Leporacanthicus requested review of this revision.Apr 28 2021, 2:35 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript

The MLIR part LGTM after comments are addressed.

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
185–187

Haven't we covered all clauses?

266

llvm_unreachable

270–271

Could we have a test that at list hits this code path? Does not need to be detailed, just the check that the calls to runtime functions are actually emitted, similarly to what we have for static loops.

jdoerfert accepted this revision.Apr 28 2021, 11:16 AM

2 nits, LGTM otherwise.

llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
118

Can we move all of the entries here and use //< ... comments maybe.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
1387–1388
This revision is now accepted and ready to land.Apr 28 2021, 11:16 AM

Will do some minor fixes tomorrow, thanks for the feedback!

llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
118

I'll take a look at moving the others as a separate patch - will fix the comment style in this patch to remind myself that it needs fixing for the others! :)

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
1760

Should use SchedType rather than GetParam()

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
185–187

Good point. Probably good enough to cover that in the default of the switch at the bottom.

270–271

The test code that I modified does this - I added the test when adding support for Dynamic scheduling, and this only updated the test to take the scheduling type as a parameter - because that's the only difference from this side - the OpenMP runtime will do different things [I think!]

Leporacanthicus marked 4 inline comments as done.

Updates based on review comments:

  • Fix style using PascalCase rather than camelCase.
  • Add Doxygen comment for parameter.
  • Change comment style for constants.
  • Remove useless error output - there was no way to get to that error.
  • Use llvm_unreachable instead of assert(0).

Adding MLIR to LLVM-IR tests. The tests are very basic, just checking that
the correct runtime functions are called.

Leporacanthicus added inline comments.May 5 2021, 5:58 AM
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
270–271

I have added some MLIR to LLVM-IR tests that check that the correct runtime calls are made, as well as the above unit-test.