Skip to content

Commit 70871a8

Browse files
[SYCL] Move fp64_relaxed E2E test (#8829)
This commit moves the in-review fp64_relaxed.cpp test from the now archived intel/llvm-test-suite repo. See intel/llvm-test-suite#1668. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent cb6c058 commit 70871a8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

Comments
 (0)