Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 967e255

Browse files
authored
[SYCL] Check that fp16 aspect is supported before using half (#1487)
1 parent 623d110 commit 967e255

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

SYCL/Regression/half_operators.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-unnamed-lambda %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-device-code-split=per_kernel -fsycl-unnamed-lambda %s -o %t.out
22
// RUN: %GPU_RUN_PLACEHOLDER %t.out
33
// REQUIRES: gpu
44
#include <iostream>
@@ -26,9 +26,7 @@ template <typename T> bool are_bitwise_equal(T lhs, T rhs) {
2626
return result;
2727
}
2828

29-
template <typename T> bool test() {
30-
sycl::queue queue{};
31-
29+
template <typename T> bool test(sycl::queue &queue) {
3230
constexpr int NumElems{32};
3331
bool pass{true};
3432

@@ -69,8 +67,10 @@ template <typename T> bool test() {
6967
}
7068

7169
int main(int argc, char **argv) {
70+
sycl::queue queue{};
7271
bool passed = true;
73-
passed &= test<float>();
74-
passed &= test<sycl::half>();
72+
passed &= test<float>(queue);
73+
if (queue.get_device().has(sycl::aspect::fp16))
74+
passed &= test<sycl::half>(queue);
7575
return passed ? 0 : 1;
7676
}

0 commit comments

Comments
 (0)