[Openmp-commits] [PATCH] D127432: [Libomptarget] Add support for offloading binaries in libomptarget

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jun 9 12:17:52 PDT 2022


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992, saiislam, ye-luo.
Herald added subscribers: kosarev, kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

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. In order to
parse these classes I pulled out the implementation of the binary from
llvm/Object/OffloadBinary.h and specialized it for this use-case. This
is so we don't need to pull in the LLVM libraries to handle this.

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, but I wasn't sure if I wanted
the plugins to require dependencies more complicated than some pointers.

This approach also requires copying the pointers to make new structs,
but we're referencing the same data buffer so copying a few pointers
into a vector isn't likely to introduce any significant overhead.

Let me know if we should use some other approach to get this done.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127432

Files:
  openmp/libomptarget/include/device.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/include/rtl.h
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins/common/elf_common/elf_common.cpp
  openmp/libomptarget/plugins/common/elf_common/elf_common.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/plugins/remote/include/Utils.h
  openmp/libomptarget/plugins/remote/lib/Utils.cpp
  openmp/libomptarget/plugins/remote/server/Server.cpp
  openmp/libomptarget/plugins/remote/server/Server.h
  openmp/libomptarget/plugins/remote/src/Client.cpp
  openmp/libomptarget/plugins/remote/src/Client.h
  openmp/libomptarget/plugins/remote/src/rtl.cpp
  openmp/libomptarget/plugins/ve/src/rtl.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/src/rtl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127432.435642.patch
Type: text/x-patch
Size: 28300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220609/ac5c274f/attachment-0001.bin>


More information about the Openmp-commits mailing list