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

[SYCL][ESIMD] Change logic for tests on simd default constructor #852

Merged
merged 4 commits into from
Feb 22, 2022
Merged
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
41 changes: 22 additions & 19 deletions SYCL/ESIMD/api/functional/ctors/ctor_default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,30 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {

bool operator()(sycl::queue &queue, const std::string &data_type) {
bool passed = true;
DataT default_val{};

// We use it to avoid empty functions being optimized out by compiler
// checking the result of the simd calling because values of the constructed
// object's elements are undefined.
shared_vector<DataT> result(NumElems, shared_allocator<DataT>(queue));

queue.submit([&](sycl::handler &cgh) {
DataT *const out = result.data();
cgh.single_task<Kernel<DataT, NumElems, TestCaseT>>(
[=]() SYCL_ESIMD_KERNEL {
TestCaseT::template call_simd_ctor<DataT, NumElems>(out);
});
});

for (size_t i = 0; i < result.size(); ++i) {
if (result[i] != default_val) {
passed = false;

const auto description =
ctors::TestDescription<DataT, NumElems, TestCaseT>(
i, result[i], default_val, data_type);
log::fail(description);
}
// We do not re-throw an exception to test all combinations of types and
// vector sizes.
try {
queue.submit([&](sycl::handler &cgh) {
DataT *const out = result.data();
cgh.single_task<Kernel<DataT, NumElems, TestCaseT>>(
[=]() SYCL_ESIMD_KERNEL {
TestCaseT::template call_simd_ctor<DataT, NumElems>(out);
});
});
queue.wait_and_throw();
} catch (const sycl::exception &e) {
passed = false;
std::string error_msg("A SYCL exception was caught:");
error_msg += std::string(e.what());
error_msg += " for simd<" + data_type;
error_msg += ", " + std::to_string(NumElems) + ">";
error_msg += ", with context: " + TestCaseT::get_description();
log::note(error_msg);
}

return passed;
Expand Down