Skip to content

Commit 946a738

Browse files
committed
Address reviews
1 parent 966e3dd commit 946a738

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,12 +1134,21 @@ class BinaryWrapper {
11341134

11351135
// Compress the image using zstd.
11361136
SmallVector<uint8_t, 512> CompressedBuffer;
1137-
llvm::compression::zstd::compress(
1138-
ArrayRef<unsigned char>(
1139-
(const unsigned char *)(Bin->getBufferStart()),
1140-
Bin->getBufferSize()),
1141-
CompressedBuffer, OffloadCompressLevel);
1142-
1137+
#if LLVM_ENABLE_EXCEPTIONS
1138+
try {
1139+
#endif
1140+
llvm::compression::zstd::compress(
1141+
ArrayRef<unsigned char>(
1142+
(const unsigned char *)(Bin->getBufferStart()),
1143+
Bin->getBufferSize()),
1144+
CompressedBuffer, OffloadCompressLevel);
1145+
#if LLVM_ENABLE_EXCEPTIONS
1146+
} catch (const std::exception &ex) {
1147+
return createStringError(inconvertibleErrorCode(),
1148+
std::string("Failed to compress the device image: \n") +
1149+
std::string(ex.what()));
1150+
}
1151+
#endif
11431152
if (Verbose)
11441153
errs() << "[Compression] Original image size: "
11451154
<< Bin->getBufferSize() << "\n"

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,11 @@ setSpecializationConstants(const std::shared_ptr<device_image_impl> &InputImpl,
734734
}
735735

736736
static inline void CheckAndDecompressImage(RTDeviceBinaryImage *Img) {
737+
#ifndef SYCL_RT_ZSTD_NOT_AVAIABLE
737738
if (auto CompImg = dynamic_cast<CompressedRTDeviceBinaryImage *>(Img))
738739
if (CompImg->IsCompressed())
739740
CompImg->Decompress();
741+
#endif
740742
}
741743

742744
// When caching is enabled, the returned UrProgram will already have

sycl/test-e2e/Compression/compression_multiple_tu.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// End-to-End test for testing device image compression when we have two
22
// translation units, one compressed and one not compressed.
3-
// REQUIRES: zstd
3+
// REQUIRES: zstd, linux
44

5-
// DEFINE: %{fPIC_flag} = %if windows %{%} %else %{-fPIC%}
6-
// RUN: %{build} --offload-compress -DENABLE_KERNEL1 -shared %{fPIC_flag} -o %T/kernel1.so
7-
// RUN: %{build} -DENABLE_KERNEL2 -shared %{fPIC_flag} -o %T/kernel2.so
5+
// RUN: %{build} --offload-compress -DENABLE_KERNEL1 -shared -fPIC -o %T/kernel1.so
6+
// RUN: %{build} -DENABLE_KERNEL2 -shared -fPIC -o %T/kernel2.so
87

98
// RUN: %{build} %T/kernel1.so %T/kernel2.so -o %t_compress.out
109
// RUN: %{run} %t_compress.out

0 commit comments

Comments
 (0)