9
9
// UNSUPPORTED: cuda
10
10
// RUN: %clangxx -fsycl %s -o %t.out
11
11
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12
+ // Enable when driver fixes will be propagated into the official release
13
+ // XFAIL: windows
12
14
13
15
// This test checks extended math operations.
14
16
15
17
#include " esimd_test_utils.hpp"
16
18
17
19
#include < CL/sycl.hpp>
18
20
#include < CL/sycl/INTEL/esimd.hpp>
21
+ #include < CL/sycl/builtins_esimd.hpp>
19
22
#include < iostream>
20
23
21
24
using namespace cl ::sycl;
@@ -35,7 +38,16 @@ struct InitDataFuncWide {
35
38
struct InitDataFuncNarrow {
36
39
void operator ()(float *In, float *Out, size_t Size) const {
37
40
for (auto I = 0 ; I < Size; ++I) {
38
- In[I] = 2 .0f + 16 .0f * ((float )I / (float )(Size - 1 )); // in [2..16] range
41
+ In[I] = 2 .0f + 16 .0f * ((float )I / (float )(Size - 1 )); // in [2..18] range
42
+ Out[I] = (float )0.0 ;
43
+ }
44
+ }
45
+ };
46
+
47
+ struct InitDataInRange0_5 {
48
+ void operator ()(float *In, float *Out, size_t Size) const {
49
+ for (auto I = 0 ; I < Size; ++I) {
50
+ In[I] = 5 .0f * ((float )I / (float )(Size - 1 )); // in [0..5] range
39
51
Out[I] = (float )0.0 ;
40
52
}
41
53
}
@@ -52,7 +64,7 @@ template <MathOp Op> float HostMathFunc(float X);
52
64
53
65
// --- Specializations per each extended math operation
54
66
55
- #define DEFINE_OP (Op, HostOp ) \
67
+ #define DEFINE_ESIMD_OP (Op, HostOp ) \
56
68
template <> float HostMathFunc<MathOp::Op>(float X) { return HostOp (X); } \
57
69
template <int VL> struct DeviceMathFunc <VL, MathOp::Op> { \
58
70
simd<float , VL> \
@@ -61,13 +73,22 @@ template <MathOp Op> float HostMathFunc(float X);
61
73
} \
62
74
}
63
75
64
- DEFINE_OP (sin, sin);
65
- DEFINE_OP (cos, cos);
66
- DEFINE_OP (exp, exp);
67
- DEFINE_OP (log, log);
68
- DEFINE_OP (inv, 1 .0f /);
69
- DEFINE_OP (sqrt, sqrt);
70
- DEFINE_OP (rsqrt, 1 .0f / sqrt);
76
+ #define DEFINE_SIMD_OVERLOADED_STD_SYCL_OP (Op, HostOp ) \
77
+ template <> float HostMathFunc<MathOp::Op>(float X) { return HostOp (X); } \
78
+ template <int VL> struct DeviceMathFunc <VL, MathOp::Op> { \
79
+ simd<float , VL> \
80
+ operator ()(const simd<float , VL> &X) const SYCL_ESIMD_FUNCTION { \
81
+ return sycl::Op<VL>(X); \
82
+ } \
83
+ }
84
+
85
+ DEFINE_SIMD_OVERLOADED_STD_SYCL_OP (sin, sin);
86
+ DEFINE_SIMD_OVERLOADED_STD_SYCL_OP (cos, cos);
87
+ DEFINE_SIMD_OVERLOADED_STD_SYCL_OP (exp, exp);
88
+ DEFINE_SIMD_OVERLOADED_STD_SYCL_OP (log, log);
89
+ DEFINE_ESIMD_OP (inv, 1 .0f /);
90
+ DEFINE_ESIMD_OP (sqrt, sqrt);
91
+ DEFINE_ESIMD_OP (rsqrt, 1 .0f / sqrt);
71
92
72
93
// --- Generic kernel calculating an extended math operation on array elements
73
94
@@ -159,13 +180,10 @@ template <int VL> bool test(queue &Q) {
159
180
Pass &= test<MathOp::sqrt, VL>(Q, " sqrt" , InitDataFuncWide{});
160
181
Pass &= test<MathOp::inv, VL>(Q, " inv" );
161
182
Pass &= test<MathOp::rsqrt, VL>(Q, " rsqrt" );
162
- // TODO enable these tests after the implementation is fixed
163
- #if ENABLE_SIN_COS_EXP_LOG
164
183
Pass &= test<MathOp::sin, VL>(Q, " sin" , InitDataFuncWide{});
165
184
Pass &= test<MathOp::cos, VL>(Q, " cos" , InitDataFuncWide{});
166
- Pass &= test<MathOp::exp, VL>(Q, " exp" );
185
+ Pass &= test<MathOp::exp, VL>(Q, " exp" , InitDataInRange0_5{} );
167
186
Pass &= test<MathOp::log, VL>(Q, " log" , InitDataFuncWide{});
168
- #endif
169
187
return Pass;
170
188
}
171
189
0 commit comments