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

Commit f9fbbf9

Browse files
committed
Exclude half testing at runtime for supporting cpu && opencl
1 parent f318ad5 commit f9fbbf9

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed
Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-device-code-split=per_kernel %s -o %t.out
22
// RUN: %HOST_RUN_PLACEHOLDER %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out
55
// RUN: %ACC_RUN_PLACEHOLDER %t.out
66

7-
// OpenCL CPU driver does not support cl_khr_fp16 extension
8-
// UNSUPPORTED: cpu && opencl
7+
// OpenCL CPU driver does not support cl_khr_fp16 extension for this reason this
8+
// test is compiled with the -fsycl-device-code-split flag
99

1010
#include <CL/sycl.hpp>
1111
#include <cassert>
@@ -25,14 +25,13 @@ void assert_out_of_bound<sycl::half>(sycl::half val, sycl::half lower,
2525
assert(lower < val && val < upper);
2626
}
2727

28-
template <typename T> void native_tanh_tester() {
28+
template <typename T> void native_tanh_tester(sycl::queue q) {
2929
T r{0};
3030

3131
#ifdef SYCL_EXT_ONEAPI_NATIVE_MATH
3232
{
3333
sycl::buffer<T, 1> BufR(&r, sycl::range<1>(1));
34-
sycl::queue myQueue;
35-
myQueue.submit([&](sycl::handler &cgh) {
34+
q.submit([&](sycl::handler &cgh) {
3635
auto AccR = BufR.template get_access<sycl::access::mode::write>(cgh);
3736
cgh.single_task([=]() {
3837
AccR[0] = sycl::ext::oneapi::experimental::native::tanh(T(1.0f));
@@ -44,14 +43,13 @@ template <typename T> void native_tanh_tester() {
4443
#endif
4544
}
4645

47-
template <typename T> void native_exp2_tester() {
46+
template <typename T> void native_exp2_tester(sycl::queue q) {
4847
T r{0};
4948

5049
#ifdef SYCL_EXT_ONEAPI_NATIVE_MATH
5150
{
5251
sycl::buffer<T, 1> BufR(&r, sycl::range<1>(1));
53-
sycl::queue myQueue;
54-
myQueue.submit([&](sycl::handler &cgh) {
52+
q.submit([&](sycl::handler &cgh) {
5553
auto AccR = BufR.template get_access<sycl::access::mode::write>(cgh);
5654
cgh.single_task([=]() {
5755
AccR[0] = sycl::ext::oneapi::experimental::native::exp2(T(0.5f));
@@ -65,26 +63,30 @@ template <typename T> void native_exp2_tester() {
6563

6664
int main() {
6765

68-
native_tanh_tester<float>();
69-
native_tanh_tester<sycl::float2>();
70-
native_tanh_tester<sycl::float3>();
71-
native_tanh_tester<sycl::float4>();
72-
native_tanh_tester<sycl::float8>();
73-
native_tanh_tester<sycl::float16>();
74-
75-
native_tanh_tester<sycl::half>();
76-
native_tanh_tester<sycl::half2>();
77-
native_tanh_tester<sycl::half3>();
78-
native_tanh_tester<sycl::half4>();
79-
native_tanh_tester<sycl::half8>();
80-
native_tanh_tester<sycl::half16>();
81-
82-
native_exp2_tester<sycl::half>();
83-
native_exp2_tester<sycl::half2>();
84-
native_exp2_tester<sycl::half3>();
85-
native_exp2_tester<sycl::half4>();
86-
native_exp2_tester<sycl::half8>();
87-
native_exp2_tester<sycl::half16>();
66+
sycl::queue q;
67+
68+
native_tanh_tester<float>(q);
69+
native_tanh_tester<sycl::float2>(q);
70+
native_tanh_tester<sycl::float3>(q);
71+
native_tanh_tester<sycl::float4>(q);
72+
native_tanh_tester<sycl::float8>(q);
73+
native_tanh_tester<sycl::float16>(q);
74+
75+
if (q.get_device().has(sycl::aspect::fp16)) {
76+
native_tanh_tester<sycl::half>(q);
77+
native_tanh_tester<sycl::half2>(q);
78+
native_tanh_tester<sycl::half3>(q);
79+
native_tanh_tester<sycl::half4>(q);
80+
native_tanh_tester<sycl::half8>(q);
81+
native_tanh_tester<sycl::half16>(q);
82+
83+
native_exp2_tester<sycl::half>(q);
84+
native_exp2_tester<sycl::half2>(q);
85+
native_exp2_tester<sycl::half3>(q);
86+
native_exp2_tester<sycl::half4>(q);
87+
native_exp2_tester<sycl::half8>(q);
88+
native_exp2_tester<sycl::half16>(q);
89+
}
8890

8991
return 0;
9092
}

0 commit comments

Comments
 (0)