diff --git a/SYCL/DeprecatedFeatures/get-options.cpp b/SYCL/DeprecatedFeatures/get-options.cpp index 134f087147208..62f50abb075a4 100644 --- a/SYCL/DeprecatedFeatures/get-options.cpp +++ b/SYCL/DeprecatedFeatures/get-options.cpp @@ -3,7 +3,10 @@ // RUN: %CPU_RUN_PLACEHOLDER %t.out // RUN: %GPU_RUN_PLACEHOLDER %t.out // RUN: %ACC_RUN_PLACEHOLDER %t.out -// XFAIL: cuda || hip +// +// This test passes OpenCL specific compiler and linker swiches to the backend, +// so it is unsupported on any other backend. +// UNSUPPORTED: cuda || hip || level_zero #include diff --git a/SYCL/DeprecatedFeatures/level-zero-link-flags.cpp b/SYCL/DeprecatedFeatures/level-zero-link-flags.cpp new file mode 100644 index 0000000000000..04ce58e51a4b1 --- /dev/null +++ b/SYCL/DeprecatedFeatures/level-zero-link-flags.cpp @@ -0,0 +1,44 @@ +// RUN: %clangxx -fsycl -D__SYCL_INTERNAL_API %s -o %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// REQUIRES: level_zero +// +//==--- level-zero-link-flags.cpp - Error handling for link flags --==// +// +// The Level Zero backend does not accept any online linker options. +// This test validates that an error is raised if you attempt to pass any. +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--------------------------------------------------------------===// + +#include + +class MyKernel; + +void test() { + sycl::queue Queue; + sycl::context Context = Queue.get_context(); + + sycl::program Program(Context); + Program.compile_with_kernel_type(); + + try { + Program.link("-foo"); + assert(false && "Expected error linking program"); + } catch (const sycl::exception &e) { + assert((e.code() == sycl::errc::build) && "Wrong error code"); + } catch (...) { + assert(false && "Expected sycl::exception"); + } + + Queue.submit([&](sycl::handler &CGH) { CGH.single_task([=] {}); }) + .wait(); +} + +int main() { + test(); + + return 0; +} diff --git a/SYCL/DeprecatedFeatures/program_link.cpp b/SYCL/DeprecatedFeatures/program_link.cpp index dd79fa9dfd29c..9b6d0e9a98f5f 100644 --- a/SYCL/DeprecatedFeatures/program_link.cpp +++ b/SYCL/DeprecatedFeatures/program_link.cpp @@ -9,6 +9,10 @@ // // Hits an assertion on AMD with multiple GPUs available, fails trace on Nvidia. // XFAIL: hip_amd || hip_nvidia +// +// Unsupported on Level Zero because the test passes OpenCL specific compiler +// and linker switches. +// UNSUPPORTED: level_zero #include #include diff --git a/SYCL/KernelAndProgram/level-zero-link-flags.cpp b/SYCL/KernelAndProgram/level-zero-link-flags.cpp new file mode 100644 index 0000000000000..bd24f3fd6ea0d --- /dev/null +++ b/SYCL/KernelAndProgram/level-zero-link-flags.cpp @@ -0,0 +1,55 @@ +// RUN: %clangxx -fsycl -Xsycl-target-linker=spir64 -foo %s -o %t.out +// RUN: %GPU_RUN_PLACEHOLDER %t.out +// REQUIRES: level_zero +// +// This test is disabled because the runtime does not currently pass linker +// flags from "-Xsycl-target-linker=spir64 " when the program calls +// "sycl::link()". This seems like a bug. Note that the runtime does pass +// those "" to the online linker in other cases when it links device +// code. +// +// XFAIL: level_zero +// +//==--- level-zero-link-flags.cpp - Error handling for link flags --==// +// +// The Level Zero backend does not accept any online linker options. +// This test validates that an error is raised if you attempt to pass any. +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--------------------------------------------------------------===// + +#include + +class MyKernel; + +void test() { + sycl::queue Queue; + sycl::context Context = Queue.get_context(); + + auto BundleInput = + sycl::get_kernel_bundle(Context); + auto BundleObject = sycl::compile(BundleInput); + + try { + sycl::link(BundleObject); + assert(false && "Expected error linking kernel bundle"); + } catch (const sycl::exception &e) { + std::string Msg(e.what()); + assert((e.code() == sycl::errc::build) && "Wrong error code"); + assert(Msg.find("-foo") != std::string::npos); + } catch (...) { + assert(false && "Expected sycl::exception"); + } + + Queue.submit([&](sycl::handler &CGH) { CGH.single_task([=] {}); }) + .wait(); +} + +int main() { + test(); + + return 0; +}