[PATCH] D99360: [OpenMP][WIP] Add standard notes for ELF offload images
Vyacheslav Zakharin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 25 11:17:53 PDT 2021
vzakhari created this revision.
vzakhari added a project: OpenMP.
Herald added subscribers: kerbowa, rupprecht, guansong, yaxunl, mgorny, nhaehnle, jvesely.
Herald added a reviewer: alexshap.
Herald added a reviewer: jhenderson.
vzakhari requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.
This patch adds //standard// ELF notes into SHT_NOTE sections of ELF offload images passed to clang-offload-wrapper. The notes then can be read by the offload plugins to get some extra information about the image.
The new notes use a null-terminated //"LLVMOMPOFFLOAD"// note name. There are currently three types of notes:
- //VERSION//: a string (not null-terminated) representing the ELF offload image structure. The current version '1.0' does not put any restrictions on the structure of the image. If we ever need to come up with a common structure for ELF offload images (e.g. to be able to analyze the images in libomptarget in some standard way), then we will introduce new versions.
- //PRODUCER//: a vendor specific name of the producing toolchain. Upstream LLVM uses //"LLVM"// (not null-terminated).
- //PRODUCER_VERSION//: a vendor specific version of the producing toolchain. Upstream LLVM uses //LLVM_VERSION_STRING// with optional //<space> LLVM_REVISION//.
All three notes are not mandatory currently.
The second part of the patch implements an //ELF light// interface for the plugins to be able to ierate ELF notes in //SHT/PT_NOTE// sections/segments. One implementation is based on //libelf// and it can be used for platforms, where //libelf// depdency can be easily satisfied. The second implementation is based on //LLVM ELFObjectFile// and requires in-tree build - this one can be used on Windows, etc.
Debug output from the plugins would look like this:
> TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_VERSION with value: '1.0'
> TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_PRODUCER with value: 'LLVM'
> TARGET Common ELF --> LLVMOMPOFFLOAD ELF note NT_LLVM_OPENMP_OFFLOAD_PRODUCER_VERSION with value: '13.0.0git 9f8975163c75b1f9f736f9a8e0a60e29ac062754'
**TODOs:**
- Find the right place to document //clang-offload-wrapper// behavior for ELF images.
- Write LIT tests.
- Decide how to test the //LLVM ELF// implementation of //ELF light//, since I expect the upstream builds will use //libelf// implementation.
- Perform thorough testing of //LLVM ELF// implementation on Windows downstream.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99360
Files:
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
llvm/include/llvm/BinaryFormat/ELF.h
llvm/tools/llvm-readobj/ELFDumper.cpp
openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
openmp/libomptarget/plugins/common/elf_common/CMakeLists.txt
openmp/libomptarget/plugins/common/elf_common/elf_common.cpp
openmp/libomptarget/plugins/common/elf_common/elf_common.h
openmp/libomptarget/plugins/common/elf_common/elf_constants.h
openmp/libomptarget/plugins/common/elf_common/elf_light.cpp
openmp/libomptarget/plugins/common/elf_common/elf_light.h
openmp/libomptarget/plugins/remote/server/CMakeLists.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99360.333349.patch
Type: text/x-patch
Size: 75791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210325/70da0db7/attachment-0001.bin>
More information about the cfe-commits
mailing list