Skip to content

Commit 07d1220

Browse files
committed
Print message about skipping tests when aspect not supported for a certain data type
1 parent de090f7 commit 07d1220

File tree

4 files changed

+62
-37
lines changed

4 files changed

+62
-37
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
3+
#include <cassert>
4+
#include <iostream>
5+
#include <sycl/atomic_ref.hpp>
6+
#include <sycl/detail/core.hpp>
7+
#include <sycl/ext/oneapi/experimental/work_group_memory.hpp>
8+
#include <sycl/ext/oneapi/free_function_queries.hpp>
9+
#include <sycl/group_barrier.hpp>
10+
#include <sycl/marray.hpp>
11+
#include <sycl/usm.hpp>
12+
#include <sycl/vector.hpp>
13+
14+
using namespace sycl;
15+
16+
template <typename T> bool check_half_aspect(queue &q) {
17+
if (std::is_same_v<sycl::half, T> &&
18+
!q.get_device().has(sycl::aspect::fp16)) {
19+
std::cout << "Device does not support fp16 aspect. Skipping all tests with "
20+
"sycl::half type!"
21+
<< std::endl;
22+
return false;
23+
}
24+
return true;
25+
}
26+
27+
template <typename T> bool check_double_aspect(queue &q) {
28+
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64)) {
29+
std::cout << "Device does not support fp64 aspect. Skipping all tests with "
30+
"double type!"
31+
<< std::endl;
32+
return false;
33+
}
34+
return true;
35+
}
36+
37+
template <typename T> struct S { T val; };
38+
39+
template <typename T> struct M { T val; };
40+
41+
union U {
42+
S<int> s;
43+
M<int> m;
44+
};
45+
46+
template <typename T>
47+
void sum_helper(sycl::ext::oneapi::experimental::work_group_memory<T[]> mem,
48+
sycl::ext::oneapi::experimental::work_group_memory<T> ret,
49+
size_t WGSIZE) {
50+
for (int i = 0; i < WGSIZE; ++i) {
51+
ret = ret + mem[i];
52+
}
53+
}

sycl/test-e2e/WorkGroupMemory/common_free_function.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@
66
#include <sycl/ext/oneapi/free_function_queries.hpp>
77
#include <sycl/group_barrier.hpp>
88
#include <sycl/usm.hpp>
9+
#include "common.hpp"
910

1011
using namespace sycl;
1112

12-
template <typename T>
13-
void sum_helper(sycl::ext::oneapi::experimental::work_group_memory<T[]> mem,
14-
sycl::ext::oneapi::experimental::work_group_memory<T> ret,
15-
size_t WGSIZE) {
16-
for (int i = 0; i < WGSIZE; ++i) {
17-
ret = ret + mem[i];
18-
}
19-
}
20-
2113
template <typename T>
2214
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
2315
(ext::oneapi::experimental::nd_range_kernel<1>))

sycl/test-e2e/WorkGroupMemory/reduction_free_function.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ constexpr size_t SIZE = 128;
2828
constexpr size_t VEC_SIZE = 16;
2929

3030
template <typename T, typename... Ts> void test_marray() {
31-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
32-
return;
33-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
31+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
3432
return;
3533

3634
constexpr size_t WGSIZE = VEC_SIZE;
@@ -60,9 +58,7 @@ template <typename T, typename... Ts> void test_marray() {
6058
}
6159

6260
template <typename T, typename... Ts> void test_vec() {
63-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
64-
return;
65-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
61+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
6662
return;
6763

6864
constexpr size_t WGSIZE = VEC_SIZE;
@@ -93,9 +89,7 @@ template <typename T, typename... Ts> void test_vec() {
9389

9490
template <typename T, typename... Ts>
9591
void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
96-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
97-
return;
98-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
92+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
9993
return;
10094

10195
T *buf = malloc_shared<T>(WGSIZE, q);

sycl/test-e2e/WorkGroupMemory/reduction_lambda.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %{build} -o %t.out
33
// RUN: %{run} %t.out
44

5-
#include "common_lambda.hpp"
5+
#include "common.hpp"
66

77
queue q;
88
context ctx = q.get_context();
@@ -11,11 +11,8 @@ constexpr size_t SIZE = 128;
1111

1212
template <typename T, typename... Ts>
1313
void test_struct(size_t SIZE, size_t WGSIZE) {
14-
if (std::is_same_v<T, half> && !q.get_device().has(aspect::fp16))
14+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
1515
return;
16-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
17-
return;
18-
1916
S<T> *buf = malloc_shared<S<T>>(WGSIZE, q);
2017
assert(buf && "Shared USM allocation failed!");
2118
T expected = 0;
@@ -78,11 +75,8 @@ void test_union(size_t SIZE, size_t WGSIZE) {
7875

7976
template <typename T, typename... Ts>
8077
void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
81-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
82-
return;
83-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
78+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
8479
return;
85-
8680
T *buf = malloc_shared<T>(WGSIZE, q);
8781
assert(buf && "Shared USM allocation failed!");
8882
T expected = 0;
@@ -117,11 +111,8 @@ void test(size_t SIZE, size_t WGSIZE, bool UseHelper) {
117111
}
118112

119113
template <typename T, typename... Ts> void test_marray() {
120-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
121-
return;
122-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
114+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
123115
return;
124-
125116
constexpr size_t WGSIZE = SIZE;
126117
T *buf = malloc_shared<T>(WGSIZE, q);
127118
assert(buf && "Shared USM allocation failed!");
@@ -158,11 +149,8 @@ template <typename T, typename... Ts> void test_marray() {
158149
}
159150

160151
template <typename T, typename... Ts> void test_vec() {
161-
if (std::is_same_v<sycl::half, T> && !q.get_device().has(sycl::aspect::fp16))
162-
return;
163-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
152+
if (!check_half_aspect<T>(q) || !check_double_aspect<T>(q))
164153
return;
165-
166154
constexpr size_t WGSIZE = 8;
167155
T *buf = malloc_shared<T>(WGSIZE, q);
168156
assert(buf && "Shared USM allocation failed!");
@@ -198,8 +186,6 @@ template <typename T, typename... Ts> void test_vec() {
198186
template <typename T, typename... Ts> void test_atomic_ref() {
199187
assert(sizeof(T) == 4 ||
200188
(sizeof(T) == 8 && q.get_device().has(aspect::atomic64)));
201-
if (std::is_same_v<T, double> && !q.get_device().has(aspect::fp64))
202-
return;
203189
constexpr size_t WGSIZE = 8;
204190
T *buf = malloc_shared<T>(WGSIZE, q);
205191
assert(buf && "Shared USM allocation failed!");

0 commit comments

Comments
 (0)