This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Add offload kind to embedded offload object
ClosedPublic

Authored by jhuber6 on Feb 21 2022, 11:45 AM.

Details

Summary

This patch adds the offload kind to the embedded section name in
preparation for offloading to different kinda like CUDA or HIP.

Depends on D120288

Diff Detail

Unit TestsFailed

Event Timeline

jhuber6 requested review of this revision.Feb 21 2022, 11:45 AM
jhuber6 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2022, 11:45 AM

The failing test needs to be adjusted, right?

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
187

Why not filename in the hash and equal method?

Can we split this change off into a separate patch please.

The failing test needs to be adjusted, right?

Yes, forgot about that.

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
187

The purpose of this implementation is to group device files that share the same triple, ect. The filename is unique so it wouldn't be helpful for that purpose.

I could move this to a separate patch, might be find considering I remove the OffloadKind from this map in the next patch set so it doesn't need to be tied to this one.

jhuber6 updated this revision to Diff 410413.Feb 21 2022, 3:56 PM

Updating after moving dense map implementation out.

Will it be possible to use Bundle Entry ID format [1] for naming sections and being sort of the the primary key to refer an offload object?
The arch string following the triple will be just offload-arch (or march, or mcpu) for others, but for amdgpu it may contain some more information.

[1] https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id

Will it be possible to use Bundle Entry ID format [1] for naming sections and being sort of the the primary key to refer an offload object?
The arch string following the triple will be just offload-arch (or march, or mcpu) for others, but for amdgpu it may contain some more information.

[1] https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id

It might also be useful for PTX, considering when we do LTO we need to know the target features (e.g. +ptx74). As long as it's a valid section name anything goes, especially as things get more complex like when we may want to embed both PTX and cubins, or maybe always embed bitcode for option JIT use. This change definitely brings us closer to what we had in the old offload bundler so we could unify that somewhat. That could be the topic of a future patch.

@saiislam Ok to postpone the bundle entry usage to a follow up?

Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 3:00 PM
jdoerfert accepted this revision.Mar 14 2022, 4:28 PM

Adjust commit message. LG, we can address outstanding comments for different encodings as we go.

This revision is now accepted and ready to land.Mar 14 2022, 4:28 PM
jhuber6 edited the summary of this revision. (Show Details)Mar 14 2022, 4:29 PM
This revision was landed with ongoing or failed builds.Mar 14 2022, 5:09 PM
This revision was automatically updated to reflect the committed changes.