From 1c0a3347270498c118f31a4c71712d093a618169 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 28 Mar 2023 06:19:27 -0700 Subject: [PATCH] [SYCL] Move fp64_relaxed E2E test This commit moves the in-review fp64_relaxed.cpp test from the now archived intel/llvm-test-suite repo. See https://github.com/intel/llvm-test-suite/pull/1668. Signed-off-by: Larsen, Steffen --- .../OptionalKernelFeatures/fp64_relaxed.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sycl/test-e2e/OptionalKernelFeatures/fp64_relaxed.cpp diff --git a/sycl/test-e2e/OptionalKernelFeatures/fp64_relaxed.cpp b/sycl/test-e2e/OptionalKernelFeatures/fp64_relaxed.cpp new file mode 100644 index 0000000000000..f225069e3732c --- /dev/null +++ b/sycl/test-e2e/OptionalKernelFeatures/fp64_relaxed.cpp @@ -0,0 +1,41 @@ +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -DOPTIMIZATIONS_DISABLED=0 %s -o %t_opt.out +// RUN: %CPU_RUN_PLACEHOLDER %t_opt.out +// RUN: %GPU_RUN_PLACEHOLDER %t_opt.out +// RUN: %ACC_RUN_PLACEHOLDER %t_opt.out +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fno-sycl-early-optimizations -DOPTIMIZATIONS_DISABLED=1 %s -o %t_noopt.out +// RUN: %CPU_RUN_PLACEHOLDER %t_noopt.out +// RUN: %GPU_RUN_PLACEHOLDER %t_noopt.out +// RUN: %ACC_RUN_PLACEHOLDER %t_noopt.out + +// Tests that aspect::fp64 requirements are affected by optimizations. + +#include + +int main() { + sycl::queue Q; + try { + Q.single_task([=]() { + // Double will be optimized out as LoweredFloat can be set directly to a + // lowered value. + double Double = 3.14; + volatile float LoweredFloat = Double; + }); +#if (OPTIMIZATIONS_DISABLED == 1) + assert(Q.get_device().has(sycl::aspect::fp64) && + "Exception should have been thrown."); +#endif // OPTIMIZATIONS_DISABLED + } catch (sycl::exception &E) { + std::cout << "Caught exception: " << E.what() << std::endl; + assert(OPTIMIZATIONS_DISABLED && + "Optimizations should have removed the fp64 requirement."); + assert(!Q.get_device().has(sycl::aspect::fp64) && + "Exception thrown despite fp64 support."); + assert(E.code() == sycl::errc::kernel_not_supported && + "Exception did not have the expected error code."); + } catch (...) { + std::cout << "Unexpected exception thrown!" << std::endl; + throw; + } + + return 0; +}