This is a RFC for bundling a YAML file along with the device image in clang-offload-wrapper, so that auxiliary information is passed to the offload plugins.
Currently, many plugins expect that the device image is an ELF image, so they look for the ELF magic word and go from there. This change-set puts extra data before the actual image like this (see code in ClangOffloadWrapper.cpp):
// Insert 1OMP header magic word. // The expected image structure is like this: // struct { // char MagicWord[ONEOMPMAGLEN]; // "1OMP" // uint32_t HeaderSize; // In little-endian. // char Header[HeaderSize]; // Uncompressed YAML with auxiliary // // information. // char ActualImage[]; // ELF or another image. // }
For backward compatibility, plugins have to continue working with plain ELF images. If 1OMP magic word is detected, then the corresponding Header has to be read as an YAML file with some mandatory keys.
As long as unification between multiple offload targets is not practical, vendors/plugins may use optional keys (such as CompileOptions for cuModuleLoadDataEx()) to convey auxiliary information from the source code or compiler options to the device specific plugins.
Main concerns about this change-set are the dependency on LLVMSupport (requiring pre-build llvm project) and the final size of the plugins (due to LLVMSupport linking).
Just for an example, the plugins will see this auxiliary data like this:
TARGET x86_64 RTL --> 1OMP header: HeaderSize(133), HeaderBegin(0x00000000004009f8), ImageBegin(0x0000000000400a7d), ImageEnd(0x0000000000402ba5)
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <CompileOptions: [
TARGET x86_64 RTL --> ,
TARGET x86_64 RTL --> ]>
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <LinkOptions: [
TARGET x86_64 RTL --> ,
TARGET x86_64 RTL --> ]>
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <Producer: [
TARGET x86_64 RTL --> unknown,
TARGET x86_64 RTL --> ]>
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <TargetID: [
TARGET x86_64 RTL --> ,
TARGET x86_64 RTL --> ]>
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <VendorId: [
TARGET x86_64 RTL --> 9,
TARGET x86_64 RTL --> ]>
TARGET x86_64 RTL --> Read OpenMPAttr:
TARGET x86_64 RTL --> <VendorName: [
TARGET x86_64 RTL --> llvm,
TARGET x86_64 RTL --> ]>