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

[SYCL][ESIMD] Add verifications that device has necessary aspects #839

Merged
merged 5 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions SYCL/ESIMD/api/functional/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ using shared_allocator = sycl::usm_allocator<DataT, sycl::usm::alloc::shared>;
template <typename DataT>
using shared_vector = std::vector<DataT, shared_allocator<DataT>>;

// Provides verification that provided device has necessary aspects to interact
// with current data type.
template <typename T>
inline bool should_skip_test_with(const sycl::device &device) {
if constexpr (std::is_same_v<T, sycl::half>) {
if (!device.has(sycl::aspect::fp16)) {
log::note(
"Device does not support half precision floating point operations");
return true;
}
} else if constexpr (std::is_same_v<T, double>) {
if (!device.has(sycl::aspect::fp64)) {
log::note(
"Device does not support double precision floating point operations");
return true;
}
} else {
// Suppress compilation warnings
static_cast<void>(device);
}

return false;
}

// A wrapper to speed-up bitwise comparison
template <typename T> bool are_bitwise_equal(T lhs, T rhs) {
// We are safe to compare unsigned integral types using `==` operator.
Expand Down
3 changes: 3 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

bool passed = true;
const std::vector<DataT> ref_data = generate_ref_data<DataT, NumElems>();
Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

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

Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
static constexpr int NumElems = SizeT::value;

bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

bool passed = true;
DataT default_val{};

Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_fill.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

shared_vector<DataT> result(NumElems, shared_allocator<DataT>(queue));

const auto base_value = get_value<DataT, BaseVal>();
Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

bool passed = true;
bool was_moved = false;

Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/ctors/ctor_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

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

Expand Down
4 changes: 4 additions & 0 deletions SYCL/ESIMD/api/functional/operators/operator_assignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ template <typename DataT, typename DimT, typename TestCaseT> class run_test {

public:
bool operator()(sycl::queue &queue, const std::string &data_type) {
if (should_skip_test_with<DataT>(queue.get_device())) {
return true;
}

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

Expand Down