From 1d8181335fb188aa4ae0ad39b3826a4162b200d2 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Fri, 13 Sep 2024 13:17:55 -0700 Subject: [PATCH] Throw error in clang-offload-wrapper when zstd is not present but still do --offload-compress; Dynamically detect if zstd is present when running E2E tests. --- .../ClangOffloadWrapper.cpp | 11 +++---- sycl/source/detail/compression.hpp | 1 - sycl/test-e2e/CMakeLists.txt | 2 -- sycl/test-e2e/Compression/no_zstd_warning.cpp | 4 +-- sycl/test-e2e/lit.cfg.py | 30 +++++++++++++++++-- sycl/test-e2e/lit.site.cfg.py.in | 2 -- 6 files changed, 35 insertions(+), 15 deletions(-) diff --git a/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp b/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp index ef3d4fc372da..07bdf7254a8b 100644 --- a/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp +++ b/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp @@ -1109,12 +1109,13 @@ class BinaryWrapper { Fbin = *FBinOrErr; } else { - // If '--offload-compress' option is specified and zstd is not available - // then warn the user that the image will not be compressed. + // If '--offload-compress' option is specified and zstd is not + // available, throw an error. if (OffloadCompressDevImgs && !llvm::compression::zstd::isAvailable()) { - WithColor::warning(errs(), ToolName) - << "'--offload-compress' option is specified but zstd is not " - "available. The device image will not be compressed.\n"; + createStringError(inconvertibleErrorCode(), + "'--offload-compress' option is specified but zstd " + "is not available. The device image will not be " + "compressed."); } // Don't compress if the user explicitly specifies the binary image diff --git a/sycl/source/detail/compression.hpp b/sycl/source/detail/compression.hpp index 56894a4de0dd..4810f446f6b7 100644 --- a/sycl/source/detail/compression.hpp +++ b/sycl/source/detail/compression.hpp @@ -144,4 +144,3 @@ class ZSTDCompressor { } // namespace sycl #endif // SYCL_RT_ZSTD_NOT_AVAIABLE - diff --git a/sycl/test-e2e/CMakeLists.txt b/sycl/test-e2e/CMakeLists.txt index 6c1ce9208269..2379d7859e6a 100644 --- a/sycl/test-e2e/CMakeLists.txt +++ b/sycl/test-e2e/CMakeLists.txt @@ -83,8 +83,6 @@ if(NOT SYCL_TEST_E2E_STANDALONE) ) endif() # Standalone. -find_package(zstd) - add_custom_target(check-sycl-e2e COMMAND ${Python3_EXECUTABLE} ${LLVM_LIT} ${SYCL_E2E_TESTS_LIT_FLAGS} . COMMENT "Running SYCL End-to-End tests" diff --git a/sycl/test-e2e/Compression/no_zstd_warning.cpp b/sycl/test-e2e/Compression/no_zstd_warning.cpp index 635ed96acd3d..bf67e4232de9 100644 --- a/sycl/test-e2e/Compression/no_zstd_warning.cpp +++ b/sycl/test-e2e/Compression/no_zstd_warning.cpp @@ -1,5 +1,5 @@ -// Test to check warnings when using --offload-compress without zstd. +// using --offload-compress without zstd should throw an error. // REQUIRES: !zstd // RUN: %{build} -O0 -g --offload-compress %S/Inputs/single_kernel.cpp -o %t_compress.out 2>&1 | FileCheck %s -// CHECK: warning: '--offload-compress' option is specified but zstd is not available. The device image will not be compressed. +// XFAIL: * diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 12aba3248c45..998971ced0ab 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -308,6 +308,33 @@ def open_check_file(file_name): if sp[0] == 0: config.available_features.add("preview-breaking-changes-supported") +# Check if clang is built with ZSTD and compression support. +check_zstd_file = os.path.join(config.sycl_obj_root, "compression_available.cpp") +with open(check_zstd_file, "w") as fp: + print( + textwrap.dedent( + """ + #include + using namespace sycl; + void kernel1(buffer &b, queue q) { + q.submit([&](sycl::handler &cgh) { + auto acc = sycl::accessor(b, cgh); + q.single_task([=] {acc[0] = acc[0] + 1;}); + }); + } + """ + ), + file=fp, + ) + +sp = subprocess.getstatusoutput( + config.dpcpp_compiler + + " -fsycl --offload-compress -shared -fPIC " + + check_zstd_file +) +if sp[0] == 0: + config.available_features.add("zstd") + # Check for CUDA SDK check_cuda_file = "cuda_include.cpp" with open_check_file(check_cuda_file) as fp: @@ -594,9 +621,6 @@ def open_check_file(file_name): if lit_config.params.get("ze_debug"): config.available_features.add("ze_debug") -if config.zstd_found and config.zstd_found == "TRUE": - config.available_features.add("zstd") - if config.run_launcher: config.substitutions.append(("%e2e_tests_root", config.test_source_root)) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index b67d84c3a614..dfa5003c1a2f 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -44,8 +44,6 @@ config.vulkan_include_dir = "@Vulkan_INCLUDE_DIRS@" config.vulkan_lib = "@Vulkan_LIBRARY@" config.vulkan_found = "@Vulkan_FOUND@" -config.zstd_found = "@zstd_FOUND@" - config.run_launcher = lit_config.params.get('run_launcher', "@SYCL_E2E_RUN_LAUNCHER@") config.allow_unknown_arch = "@SYCL_E2E_LIT_ALLOW_UNKNOWN_ARCH@"