Skip to content

Commit 5aca788

Browse files
vasilytricbb-sycl
authored andcommitted
[SYCL][ESIMD] Change logic for tests on simd default constructor (intel#852)
* [SYCL][ESIMD] Change logic for tests on simd default constructor The documentation for simd default constructor has been changed and now values of the constructed object's elements are undefined.
1 parent 94c5198 commit 5aca788

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
127127

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

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

134137
queue.submit([&](sycl::handler &cgh) {
135138
DataT *const out = result.data();
@@ -149,6 +152,27 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
149152
log::fail(description);
150153
}
151154
>>>>>>> c1366f1d7 ([SYCL][ESIMD] Split tests on simd constructors into core and fp_extra (#748))
155+
=======
156+
// We do not re-throw an exception to test all combinations of types and
157+
// vector sizes.
158+
try {
159+
queue.submit([&](sycl::handler &cgh) {
160+
DataT *const out = result.data();
161+
cgh.single_task<Kernel<DataT, NumElems, TestCaseT>>(
162+
[=]() SYCL_ESIMD_KERNEL {
163+
TestCaseT::template call_simd_ctor<DataT, NumElems>(out);
164+
});
165+
});
166+
queue.wait_and_throw();
167+
} catch (const sycl::exception &e) {
168+
passed = false;
169+
std::string error_msg("A SYCL exception was caught:");
170+
error_msg += std::string(e.what());
171+
error_msg += " for simd<" + data_type;
172+
error_msg += ", " + std::to_string(NumElems) + ">";
173+
error_msg += ", with context: " + TestCaseT::get_description();
174+
log::note(error_msg);
175+
>>>>>>> deac1c6e6 ([SYCL][ESIMD] Change logic for tests on simd default constructor (#852))
152176
}
153177

154178
return passed;

0 commit comments

Comments
 (0)