[clang-offload-bundler] extracting compatible bundle entry
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Fri, 23 Sep 2022 14:35:55 +0000 (10:35 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Wed, 5 Oct 2022 23:44:38 +0000 (19:44 -0400)
commit844b84af20c71482093995b1d64abc190eb5a5f9
tree9175155ac484b80ceab115331404276b5bda5c30
parent8f10d204d13b23fc67e6c6e32c6396b9e3ef9be4
[clang-offload-bundler] extracting compatible bundle entry

In HIP a library is usually compiled with default target ID e.g. gfx906 so that
it can be used in all GPU configurations. The bitcode is saved in bundled
bitcode with gfx906 in entry ID.

In runtime compilation, a HIP program is compiled with a target ID matching
the GPU configuration, e.g. gfx906:xnack-. This program needs to link with
a library bundled bitcode with target ID gfx906.

For example:

  clang --offload-arch=gfx906 -o lib.o lib.hip
  clang --offload-arch=gfx906:xnack- program.hip lib.o

This common use case requires that clang-offlod-bundler to be able to extract
entry with compatible target ID, e.g. extracting an gfx906 entry when requesting
gfx906:xnack-.

Currently clang-offload-bundler only allow extracting entry with exact match
of target ID. This patch relaxes that so that it can extract entries with compatible
target ID.

Reviewed by: Artem Belevich, Saiyedul Islam

Differential Revision: https://reviews.llvm.org/D134546
clang/include/clang/Basic/TargetID.h
clang/include/clang/Driver/OffloadBundler.h
clang/lib/Basic/TargetID.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/test/Driver/clang-offload-bundler.c
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp