Skip to content

Commit eab2dfc

Browse files
[Driver] Do not compress bundle when offloading to HIP (#15881)
Fixes: #15829 **Problem** `--offload-compress` is being used by HIP in `clang-offload-bundler` and by us in `clang-offload-wrapper`. When we use ` --offload-compress` for SYCL offloading to HIP, the device images gets compressed twice: once in `offload-bundler` and then in `offload-wrapper`. **~Solution~ Workaround** This PR intends to disable compression in `clang-offload-bundler` when offloading to HIP.
1 parent 9143b2c commit eab2dfc

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

clang/lib/Driver/ToolChains/HIPUtility.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
324324
Args.MakeArgString(std::string("-output=").append(Output));
325325
BundlerArgs.push_back(BundlerOutputArg);
326326

327-
addOffloadCompressArgs(Args, BundlerArgs);
327+
// For SYCL, the compression is occurring during the wrapping step, so we do
328+
// not want to do additional compression here.
329+
if (!JA.isDeviceOffloading(Action::OFK_SYCL))
330+
addOffloadCompressArgs(Args, BundlerArgs);
328331

329332
const char *Bundler = Args.MakeArgString(
330333
T.getToolChain().GetProgramPath("clang-offload-bundler"));

clang/test/Driver/sycl-offload-wrapper-compression.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@
1010
// RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-COMPRESS
1111
// RUN: %clangxx -### -fsycl --offload-compression-level=3 %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-COMPRESS
1212

13+
// For SYCL offloading to HIP, make sure we don't pass '--compress' to offload-bundler.
14+
// RUN: %clangxx -### -fsycl --offload-compress -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx1031 -fsycl-targets=amdgcn-amd-amdhsa -fno-sycl-libspirv -nogpulib %s &> %t.driver
15+
// RUN: FileCheck %s --check-prefix=CHECK-NO-COMPRESS-BUNDLER --input-file=%t.driver
16+
1317
// CHECK-NO-COMPRESS-NOT: {{.*}}clang-offload-wrapper{{.*}}"-offload-compress"{{.*}}
1418
// CHECK-NO-COMPRESS-NOT: {{.*}}clang-offload-wrapper{{.*}}"-offload-compression-level=3"{{.*}}
19+
20+
// CHECK-NO-COMPRESS-BUNDLER-NOT: {{.*}}clang-offload-bundler{{.*}}"-compress"{{.*}}

sycl/test-e2e/Compression/compression.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// End-to-End test for testing device image compression.
22
// REQUIRES: zstd
33

4-
// XFAIL: hip_amd
5-
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/15829
6-
74
// RUN: %{build} -O0 -g %S/Inputs/single_kernel.cpp -o %t_not_compress.out
85
// RUN: %{build} -O0 -g --offload-compress --offload-compression-level=3 %S/Inputs/single_kernel.cpp -o %t_compress.out
96
// RUN: %{run} %t_not_compress.out

sycl/test-e2e/Compression/compression_multiple_tu.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// translation units, one compressed and one not compressed.
33
// REQUIRES: zstd, linux
44

5-
// XFAIL: hip_amd
6-
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/15829
7-
85
// RUN: %{build} --offload-compress -DENABLE_KERNEL1 -shared -fPIC -o %T/kernel1.so
96
// RUN: %{build} -DENABLE_KERNEL2 -shared -fPIC -o %T/kernel2.so
107

0 commit comments

Comments
 (0)