[SYCL] Support --offload-compress in clang-linker-wrapper#22605
Conversation
Forward --offload-compress (and --offload-compression-level=) from the driver to clang-linker-wrapper under the new offloading driver. In wrapSYCLBinariesFromFile, zstd-compress each SYCL device image whose payload is at or above --offload-compression-threshold= (default 512 bytes) and tag it with the new BIF_CompressedNone image format so the SYCL runtime decompresses lazily via CompressedRTDeviceBinaryImage.
| // The --compress flag above is a different mechanism: for HIP only, it is | ||
| // forwarded verbatim to a clang-offload-bundler subprocess which does the | ||
| // compression itself. | ||
| def offload_compress : Flag<["--"], "offload-compress">, |
There was a problem hiding this comment.
Instead of adding new flags could we just re-use the existing ones? Then I don't think we need any driver changes, it seems addOffloadCompressArgs should do what we need if we make clang-linker-wrapper do the right thing
| BIF_Native, // Native Image kind | ||
| BIF_SPIRV, // SPIR-V | ||
| BIF_LLVMBC, // LLVM bitcode | ||
| BIF_CompressedNone // zstd-compressed image; format-of-original unknown |
There was a problem hiding this comment.
Maybe we could just call it BIF_Compressed unless we need different BIFCompressed versions for different original formats, which it seems like we don't
| case SYCLBinaryImageFormat::BIF_LLVMBC: | ||
| return 3; | ||
| case SYCLBinaryImageFormat::BIF_CompressedNone: | ||
| return 4; |
There was a problem hiding this comment.
I assume the SYCL runtime already knows how to handle this and the format matches the old offload model?
| "'--offload-compress' is specified but zstd is not available"); | ||
|
|
||
| int Level = 10; // default zstd level, matches clang-offload-wrapper | ||
| int Threshold = 512; // skip compression below this many bytes |
There was a problem hiding this comment.
I wonder if we can h ave a shared function that both clang-offload-wrapper and clang-linker-wrapper use until we remove old offload model support. Maybe we could put it in llvm/lib/Frontend/Offloading/Utility.cpp?
Forward --offload-compress (and --offload-compression-level=) from the driver to clang-linker-wrapper under the new offloading driver. In wrapSYCLBinariesFromFile, zstd-compress each SYCL device image whose payload is at or above --offload-compression-threshold= (default 512 bytes) and tag it with the new BIF_CompressedNone image format so the SYCL runtime decompresses lazily via CompressedRTDeviceBinaryImage.
Significant help from Claude Opus 4.7.