Skip to content

Commit 3964f27

Browse files
committed
Fix missing aspect runtime errors in tests
1 parent 17c4003 commit 3964f27

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

sycl/test-e2e/WorkGroupMemory/reduction_free_function.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void sum_marray(
9595
T expected) {
9696
const auto it = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
9797
size_t local_id = it.get_local_id();
98-
constexpr float tolerance = 0.01f;
98+
constexpr T tolerance = 0.0001;
9999
sycl::marray<T, 16> &data = mem;
100100
data[local_id] = buf[local_id];
101101
group_barrier(it.get_group());
@@ -129,7 +129,7 @@ void sum_vec(
129129
T expected) {
130130
const auto it = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
131131
size_t local_id = it.get_local_id();
132-
constexpr float tolerance = 0.01f;
132+
constexpr T tolerance = 0.0001;
133133
sycl::vec<T, 16> &data = mem;
134134
data[local_id] = buf[local_id];
135135
group_barrier(it.get_group());
@@ -157,12 +157,15 @@ SUM_VEC(half);
157157
template <typename T, typename... Ts> void test_marray() {
158158
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
159159
return;
160+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
161+
return;
162+
160163
constexpr size_t WGSIZE = VEC_SIZE;
161164
T *buf = malloc_shared<T>(WGSIZE, q);
162165
assert(buf && "Shared USM allocation failed!");
163166
T expected = 0;
164167
for (int i = 0; i < WGSIZE; ++i) {
165-
buf[i] = ext::intel::math::sqrt(T(i));
168+
buf[i] = T(i) / WGSIZE;
166169
expected = expected + buf[i];
167170
}
168171
nd_range ndr{{SIZE}, {WGSIZE}};
@@ -186,12 +189,15 @@ template <typename T, typename... Ts> void test_marray() {
186189
template <typename T, typename... Ts> void test_vec() {
187190
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
188191
return;
192+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
193+
return;
194+
189195
constexpr size_t WGSIZE = VEC_SIZE;
190196
T *buf = malloc_shared<T>(WGSIZE, q);
191197
assert(buf && "Shared USM allocation failed!");
192198
T expected = 0;
193199
for (int i = 0; i < WGSIZE; ++i) {
194-
buf[i] = ext::intel::math::sqrt(T(i));
200+
buf[i] = T(i) / WGSIZE;
195201
expected = expected + buf[i];
196202
}
197203
nd_range ndr{{SIZE}, {WGSIZE}};
@@ -216,6 +222,9 @@ template <typename T, typename... Ts>
216222
void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
217223
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
218224
return;
225+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
226+
return;
227+
219228
T *buf = malloc_shared<T>(WGSIZE, q);
220229
assert(buf && "Shared USM allocation failed!");
221230
T expected = 0;

sycl/test-e2e/WorkGroupMemory/reduction_lambda.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ context ctx = q.get_context();
2020

2121
constexpr size_t SIZE = 128;
2222

23-
template <typename T> struct S {
24-
T val;
25-
};
23+
template <typename T> struct S { T val; };
2624

27-
template <typename T> struct M {
28-
T val;
29-
};
25+
template <typename T> struct M { T val; };
3026

3127
union U {
3228
S<int> s;
@@ -35,6 +31,11 @@ union U {
3531

3632
template <typename T, typename... Ts>
3733
void test_struct(size_t SIZE, size_t WGSIZE) {
34+
if (std::is_same_v<T, half> && !q.get_device().has(aspect::fp16))
35+
return;
36+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
37+
return;
38+
3839
S<T> *buf = malloc_shared<S<T>>(WGSIZE, q);
3940
assert(buf && "Shared USM allocation failed!");
4041
T expected = 0;
@@ -44,7 +45,7 @@ void test_struct(size_t SIZE, size_t WGSIZE) {
4445
}
4546
nd_range ndr{{SIZE}, {WGSIZE}};
4647
q.submit([&](sycl::handler &cgh) {
47-
ext::oneapi::experimental::work_group_memory<S<T>[]> mem{WGSIZE, cgh};
48+
ext::oneapi::experimental::work_group_memory<S<T>[]> mem { WGSIZE, cgh };
4849
ext::oneapi::experimental ::work_group_memory<T> result{cgh};
4950
cgh.parallel_for(ndr, [=](nd_item<> it) {
5051
size_t local_id = it.get_local_id();
@@ -108,6 +109,9 @@ template <typename T, typename... Ts>
108109
void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
109110
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
110111
return;
112+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
113+
return;
114+
111115
T *buf = malloc_shared<T>(WGSIZE, q);
112116
assert(buf && "Shared USM allocation failed!");
113117
T expected = 0;
@@ -144,12 +148,15 @@ void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
144148
template <typename T, typename... Ts> void test_marray() {
145149
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
146150
return;
151+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
152+
return;
153+
147154
constexpr size_t WGSIZE = SIZE;
148155
T *buf = malloc_shared<T>(WGSIZE, q);
149156
assert(buf && "Shared USM allocation failed!");
150157
T expected = 0;
151158
for (int i = 0; i < WGSIZE; ++i) {
152-
buf[i] = T(i);
159+
buf[i] = T(i) / WGSIZE;
153160
expected = expected + buf[i];
154161
}
155162
nd_range ndr{{SIZE}, {WGSIZE}};
@@ -182,12 +189,15 @@ template <typename T, typename... Ts> void test_marray() {
182189
template <typename T, typename... Ts> void test_vec() {
183190
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
184191
return;
192+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
193+
return;
194+
185195
constexpr size_t WGSIZE = 8;
186196
T *buf = malloc_shared<T>(WGSIZE, q);
187197
assert(buf && "Shared USM allocation failed!");
188198
T expected = 0;
189199
for (int i = 0; i < WGSIZE; ++i) {
190-
buf[i] = ext::intel::math::sqrt(T(i));
200+
buf[i] = T(i) / WGSIZE;
191201
expected = expected + buf[i];
192202
}
193203
nd_range ndr{{SIZE}, {WGSIZE}};
@@ -217,6 +227,8 @@ template <typename T, typename... Ts> void test_vec() {
217227
template <typename T, typename... Ts> void test_atomic_ref() {
218228
assert(sizeof(T) == 4 ||
219229
(sizeof(T) == 8 && q.get_device().has(aspect::atomic64)));
230+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
231+
return;
220232
constexpr size_t WGSIZE = 8;
221233
T *buf = malloc_shared<T>(WGSIZE, q);
222234
assert(buf && "Shared USM allocation failed!");

0 commit comments

Comments
 (0)