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

Commit dacacdf

Browse files
authored
[SYCL][ESIMD] Add checks that device has fp16/fp64 aspects (#839)
* [SYCL][ESIMD] Add verifications that device has necessary aspects
1 parent d6527a5 commit dacacdf

File tree

8 files changed

+51
-0
lines changed

8 files changed

+51
-0
lines changed

SYCL/ESIMD/api/functional/common.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ using shared_allocator = sycl::usm_allocator<DataT, sycl::usm::alloc::shared>;
5555
template <typename DataT>
5656
using shared_vector = std::vector<DataT, shared_allocator<DataT>>;
5757

58+
// Provides verification that provided device has necessary aspects to interact
59+
// with current data type.
60+
template <typename T>
61+
inline bool should_skip_test_with(const sycl::device &device) {
62+
if constexpr (std::is_same_v<T, sycl::half>) {
63+
if (!device.has(sycl::aspect::fp16)) {
64+
log::note(
65+
"Device does not support half precision floating point operations");
66+
return true;
67+
}
68+
} else if constexpr (std::is_same_v<T, double>) {
69+
if (!device.has(sycl::aspect::fp64)) {
70+
log::note(
71+
"Device does not support double precision floating point operations");
72+
return true;
73+
}
74+
} else {
75+
// Suppress compilation warnings
76+
static_cast<void>(device);
77+
}
78+
79+
return false;
80+
}
81+
5882
// A wrapper to speed-up bitwise comparison
5983
template <typename T> bool are_bitwise_equal(T lhs, T rhs) {
6084
// We are safe to compare unsigned integral types using `==` operator.

SYCL/ESIMD/api/functional/ctors/ctor_array.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
9696

9797
public:
9898
bool operator()(sycl::queue &queue, const std::string &data_type) {
99+
if (should_skip_test_with<DataT>(queue.get_device())) {
100+
return true;
101+
}
99102

100103
bool passed = true;
101104
const std::vector<DataT> ref_data = generate_ref_data<DataT, NumElems>();

SYCL/ESIMD/api/functional/ctors/ctor_copy.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
9393

9494
public:
9595
bool operator()(sycl::queue &queue, const std::string &data_type) {
96+
if (should_skip_test_with<DataT>(queue.get_device())) {
97+
return true;
98+
}
99+
96100
bool passed = true;
97101
const std::vector<DataT> ref_data = generate_ref_data<DataT, NumElems>();
98102

SYCL/ESIMD/api/functional/ctors/ctor_default.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
8080
static constexpr int NumElems = SizeT::value;
8181

8282
bool operator()(sycl::queue &queue, const std::string &data_type) {
83+
if (should_skip_test_with<DataT>(queue.get_device())) {
84+
return true;
85+
}
86+
8387
bool passed = true;
8488

8589
// We use it to avoid empty functions being optimized out by compiler

SYCL/ESIMD/api/functional/ctors/ctor_fill.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ class run_test {
205205

206206
public:
207207
bool operator()(sycl::queue &queue, const std::string &data_type) {
208+
if (should_skip_test_with<DataT>(queue.get_device())) {
209+
return true;
210+
}
211+
208212
shared_vector<DataT> result(NumElems, shared_allocator<DataT>(queue));
209213

210214
const auto base_value = get_value<DataT, BaseVal>();

SYCL/ESIMD/api/functional/ctors/ctor_move.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
8989

9090
public:
9191
bool operator()(sycl::queue &queue, const std::string &data_type) {
92+
if (should_skip_test_with<DataT>(queue.get_device())) {
93+
return true;
94+
}
95+
9296
bool passed = true;
9397
bool was_moved = false;
9498

SYCL/ESIMD/api/functional/ctors/ctor_vector.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
8888

8989
public:
9090
bool operator()(sycl::queue &queue, const std::string &data_type) {
91+
if (should_skip_test_with<DataT>(queue.get_device())) {
92+
return true;
93+
}
94+
9195
bool passed = true;
9296
const std::vector<DataT> ref_data = generate_ref_data<DataT, NumElems>();
9397

SYCL/ESIMD/api/functional/operators/operator_assignment.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
2929

3030
public:
3131
bool operator()(sycl::queue &queue, const std::string &data_type) {
32+
if (should_skip_test_with<DataT>(queue.get_device())) {
33+
return true;
34+
}
35+
3236
bool passed = true;
3337
const std::vector<DataT> ref_data = generate_ref_data<DataT, NumElems>();
3438

0 commit comments

Comments
 (0)