Skip to content

[SYCL] Support --offload-compress in clang-linker-wrapper#22605

Open
bviyer wants to merge 2 commits into
syclfrom
bviyer-sycl-compress-support
Open

[SYCL] Support --offload-compress in clang-linker-wrapper#22605
bviyer wants to merge 2 commits into
syclfrom
bviyer-sycl-compress-support

Conversation

@bviyer

@bviyer bviyer commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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.

bviyer added 2 commits July 10, 2026 16:00
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.
@bviyer bviyer requested review from YuriPlyakhin and maksimsab July 12, 2026 15:23
@bviyer bviyer marked this pull request as ready for review July 14, 2026 14:05
@bviyer bviyer requested review from a team as code owners July 14, 2026 14:05
// 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">,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the SYCL runtime already knows how to handle this and the format matches the old offload model?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

"'--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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants