|
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -DOPTIMIZATIONS_DISABLED=0 %s -o %t_opt.out |
| 2 | +// RUN: %CPU_RUN_PLACEHOLDER %t_opt.out |
| 3 | +// RUN: %GPU_RUN_PLACEHOLDER %t_opt.out |
| 4 | +// RUN: %ACC_RUN_PLACEHOLDER %t_opt.out |
| 5 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fno-sycl-early-optimizations -DOPTIMIZATIONS_DISABLED=1 %s -o %t_noopt.out |
| 6 | +// RUN: %CPU_RUN_PLACEHOLDER %t_noopt.out |
| 7 | +// RUN: %GPU_RUN_PLACEHOLDER %t_noopt.out |
| 8 | +// RUN: %ACC_RUN_PLACEHOLDER %t_noopt.out |
| 9 | + |
| 10 | +// Tests that aspect::fp64 requirements are affected by optimizations. |
| 11 | + |
| 12 | +#include <sycl/sycl.hpp> |
| 13 | + |
| 14 | +int main() { |
| 15 | + sycl::queue Q; |
| 16 | + try { |
| 17 | + Q.single_task([=]() { |
| 18 | + // Double will be optimized out as LoweredFloat can be set directly to a |
| 19 | + // lowered value. |
| 20 | + double Double = 3.14; |
| 21 | + volatile float LoweredFloat = Double; |
| 22 | + }); |
| 23 | +#if (OPTIMIZATIONS_DISABLED == 1) |
| 24 | + assert(Q.get_device().has(sycl::aspect::fp64) && |
| 25 | + "Exception should have been thrown."); |
| 26 | +#endif // OPTIMIZATIONS_DISABLED |
| 27 | + } catch (sycl::exception &E) { |
| 28 | + std::cout << "Caught exception: " << E.what() << std::endl; |
| 29 | + assert(OPTIMIZATIONS_DISABLED && |
| 30 | + "Optimizations should have removed the fp64 requirement."); |
| 31 | + assert(!Q.get_device().has(sycl::aspect::fp64) && |
| 32 | + "Exception thrown despite fp64 support."); |
| 33 | + assert(E.code() == sycl::errc::kernel_not_supported && |
| 34 | + "Exception did not have the expected error code."); |
| 35 | + } catch (...) { |
| 36 | + std::cout << "Unexpected exception thrown!" << std::endl; |
| 37 | + throw; |
| 38 | + } |
| 39 | + |
| 40 | + return 0; |
| 41 | +} |
0 commit comments