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
2
2
// RUN: %HOST_RUN_PLACEHOLDER %t.out
3
3
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4
4
// RUN: %GPU_RUN_PLACEHOLDER %t.out
5
5
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6
6
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
9
9
10
10
#include < CL/sycl.hpp>
11
11
#include < cassert>
@@ -25,14 +25,13 @@ void assert_out_of_bound<sycl::half>(sycl::half val, sycl::half lower,
25
25
assert (lower < val && val < upper);
26
26
}
27
27
28
- template <typename T> void native_tanh_tester () {
28
+ template <typename T> void native_tanh_tester (sycl::queue q ) {
29
29
T r{0 };
30
30
31
31
#ifdef SYCL_EXT_ONEAPI_NATIVE_MATH
32
32
{
33
33
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) {
36
35
auto AccR = BufR.template get_access <sycl::access::mode::write>(cgh);
37
36
cgh.single_task ([=]() {
38
37
AccR[0 ] = sycl::ext::oneapi::experimental::native::tanh (T (1 .0f ));
@@ -44,14 +43,13 @@ template <typename T> void native_tanh_tester() {
44
43
#endif
45
44
}
46
45
47
- template <typename T> void native_exp2_tester () {
46
+ template <typename T> void native_exp2_tester (sycl::queue q ) {
48
47
T r{0 };
49
48
50
49
#ifdef SYCL_EXT_ONEAPI_NATIVE_MATH
51
50
{
52
51
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) {
55
53
auto AccR = BufR.template get_access <sycl::access::mode::write>(cgh);
56
54
cgh.single_task ([=]() {
57
55
AccR[0 ] = sycl::ext::oneapi::experimental::native::exp2 (T (0 .5f ));
@@ -65,26 +63,30 @@ template <typename T> void native_exp2_tester() {
65
63
66
64
int main () {
67
65
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
+ }
88
90
89
91
return 0 ;
90
92
}
0 commit comments