This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize
ClosedPublic

Authored by agozillon on Apr 14 2023, 1:16 PM.

Details

Summary

This allows the generation of OpenMP offload metadata for the OpenMP
dialect when lowering to LLVM-IR and moves some of the shared logic
between the OpenMP Dialect and Clang into the IRBuilder.

This patch has a dependency on: https://reviews.llvm.org/D148038

As it requires the host ir file during lowering.

Diff Detail

Event Timeline

agozillon created this revision.Apr 14 2023, 1:16 PM
Herald added a project: Restricted Project. · View Herald Transcript
agozillon requested review of this revision.Apr 14 2023, 1:16 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald Transcript

A little unsure how to test this change on its own for Flang-new + OpenMP, as there currently isn't anything that utilises it upstream at the moment. It's part of the declare target work that I'm beginning to upstream, so eventually it'll be tested on the Flang side through it, and the Target region work will also eventually utilise it.

As for Clang OpenMP, it currently doesn't break any existing tests on my machine for OpenMP on AMDGPU or host tests, however, I can't speak for other targets but I expect they will pass happily as well.

If there is additional tests I can add that might contribute to the patch please do ask away!

agozillon added inline comments.Apr 14 2023, 1:48 PM
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
170

This will break the patch buildbot unfortunately until the patch this patch is dependent on is accepted and upstreamed

jsjodin added inline comments.Apr 14 2023, 4:41 PM
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
170

This will break the patch buildbot unfortunately until the patch this patch is dependent on is accepted and upstreamed

You can always skip this part and add it in a separate patch, or add it in a patch where it is needed.

The patch this is dependent on has now been accepted and landed, so this should be ready for review now if anyone is available!

  • Move hostIRFilePath initialize invocation to ModuleTranslation.cpp to respect TargetOp patch
agozillon updated this revision to Diff 517968.Apr 28 2023, 9:56 AM
  • Move hostIRFilePath initialize invocation to ModuleTranslation.cpp to respect TargetOp patch

rebase to see if it clears up the buildbot issue (currently the failing test appears to be unrelated and passes on my machine after a rebase)

Small ping to ask for some reviewer attention on this patch if at all possible!

jdoerfert added inline comments.May 2 2023, 10:24 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
1063

Move the additional comment to the initialize function instead to explain what the argument is for.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
452

early exit plz.

453

No llvm::

455

no assert false please. Use unreachable or report fatal error.

agozillon updated this revision to Diff 518875.May 2 2023, 3:06 PM
agozillon marked 4 inline comments as done.
  • Move hostIRFilePath initialize invocation to ModuleTranslation.cpp to respect TargetOp patch
  • Apply reviewer feedback

Thank you very much for the quick response time on the review and the review @jdoerfert! I believe I have applied all of your current feedback in the last update.

jdoerfert added inline comments.May 2 2023, 5:23 PM
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
560

no llvm::
style: ErrorReportFn

similarly elsewhere.

agozillon updated this revision to Diff 519048.May 3 2023, 6:02 AM
  • Move hostIRFilePath initialize invocation to ModuleTranslation.cpp to respect TargetOp patch
  • Apply reviewer feedback
  • Tidy up missed style guidelines i sillily forgot about
agozillon updated this revision to Diff 519050.May 3 2023, 6:06 AM
agozillon marked an inline comment as done.
  • Remove unneccessary OMPIRBuilder scope as well

Updated to fix the style issues that were present and pointed out by @jdoerfert thank you!

Hey @jdoerfert sorry to bother you, would it be possible to have this signed off on if there is no further issues with the current patch? Thank you for your time!

If it would be possible to get some poor reviewers precious time on this I would greatly appreciate it! Thank you very much ahead of time.

LG. Please wait a day before submitting.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
455–468

Nit: Might be good to spell the types and use braces for multi-line code inside if.

mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
18

Nit: Is this required here? Can it be in the CPP File?

This revision is now accepted and ready to land.May 15 2023, 6:00 AM

Thank you very much @kiranchandramohan! More than happy to wait a day incase anyone else wishes to do a final review. I'll add the Nits where possible when I commit the patch upstream and it should hopefully update the review with the alterations!

I am going to upstream this within the next hour, unless anyone has some final comments they wish to make