[all-commits] [llvm/llvm-project] 080022: [LinkerWrapper] Embed OffloadBinaries for OpenMP o...

Joseph Huber via All-commits all-commits at lists.llvm.org
Thu Jul 21 10:20:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 080022d8ed6c1bd9ba5ece33cfea248f9473e775
      https://github.com/llvm/llvm-project/commit/080022d8ed6c1bd9ba5ece33cfea248f9473e775
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-21 (Thu, 21 Jul 2022)

  Changed paths:
    M clang/test/Driver/linker-wrapper-image.c
    M clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
    M clang/tools/clang-linker-wrapper/OffloadWrapper.cpp

  Log Message:
  -----------
  [LinkerWrapper] Embed OffloadBinaries for OpenMP offloading images

The OpenMP offloading runtine currently uses an array of linked
offloading images. One downside to this is that we cannot know the
architecture or triple associated with the given image. In this patch,
instead of embedding the image itself, we embed an offloading binary
instead. This binary is simply a binary format that wraps around the
original linked image to provide some additional metadata. This will
allow us to support offloading to multiple architecture, or performing
future JIT compilation inside of the runtime, more clearly.
Additionally, these can be placed at a special section such that the
supported architectures can be identified using objdump with the support
from D126904. This needs to be stored in a new section name
`.llvm.offloading.images` because the `.llvm.offloading` section
implicitly uses the `SHF_EXCLUDE` flag and will always be stripped.

This patch does not contain the necessary code to parse these in
libomptarget.

Depends on D127246

Reviewed By: saiislam

Differential Revision: https://reviews.llvm.org/D127304


  Commit: fbcb1ee7f3648c0b3f326db32a7ae0772b962e06
      https://github.com/llvm/llvm-project/commit/fbcb1ee7f3648c0b3f326db32a7ae0772b962e06
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-21 (Thu, 21 Jul 2022)

  Changed paths:
    M openmp/libomptarget/include/device.h
    M openmp/libomptarget/include/omptarget.h
    M openmp/libomptarget/include/omptargetplugin.h
    M openmp/libomptarget/include/rtl.h
    M openmp/libomptarget/src/rtl.cpp

  Log Message:
  -----------
  [Libomptarget] Add support for offloading binaries in libomptarget

The previous path changed the linker wrapper to embed the offloading
binary format inside the target image instead. This will allow us to
more generically bundle metadata with these images, such as requires
clauses or the target architecture it was compiled for.

I wasn't sure how to handle this best, so I introduced a new type that
replaces the old `__tgt_device_image` struct that we can expand inside
the runtime library. I made the new `__tgt_device_binary` struct pretty
much the same for now. In the future we could change this struct to
pretty much be the `OffloadBinary` class in the future.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D127432


  Commit: e01ce4e88a8443993afb19f64b2811d50dca65aa
      https://github.com/llvm/llvm-project/commit/e01ce4e88a8443993afb19f64b2811d50dca65aa
  Author: Joseph Huber <jhuber6 at vols.utk.edu>
  Date:   2022-07-21 (Thu, 21 Jul 2022)

  Changed paths:
    M openmp/libomptarget/plugins/cuda/src/rtl.cpp
    M openmp/libomptarget/plugins/exports

  Log Message:
  -----------
  [Libomptarget] Add checks for CUDA subarchitecture using new info

This patch extends the `is_valid_binary` routine to also check if the
binary's architecture string matches the one parsed from the runtime.
This should allow us to only use the binary whose compute capability
matches, allowing us to support basic multi-architecture binaries for
CUDA.

Depends on D127432

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D127505


Compare: https://github.com/llvm/llvm-project/compare/53d7bf3052dc...e01ce4e88a84


More information about the All-commits mailing list