|
14 | 14 | //===----------------------------------------------------------------------===//
|
15 | 15 |
|
16 | 16 | #pragma once
|
| 17 | +<<<<<<< HEAD |
17 | 18 | #define ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
|
| 19 | +======= |
| 20 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
18 | 21 |
|
19 | 22 | #include "../mutator.hpp"
|
20 | 23 | #include "common.hpp"
|
21 | 24 |
|
| 25 | +<<<<<<< HEAD |
22 | 26 | namespace esimd = sycl::ext::intel::esimd;
|
| 27 | +======= |
| 28 | +namespace esimd = sycl::ext::intel::experimental::esimd; |
| 29 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
23 | 30 | namespace esimd_functional = esimd_test::api::functional;
|
24 | 31 |
|
25 | 32 | namespace esimd_test::api::functional::operators {
|
@@ -112,6 +119,41 @@ struct post_increment {
|
112 | 119 | static constexpr bool is_increment() { return true; }
|
113 | 120 | };
|
114 | 121 |
|
| 122 | +<<<<<<< HEAD |
| 123 | +======= |
| 124 | +template <typename DataT, int NumElems, typename TestCaseT> |
| 125 | +class IncrementAndDecrementTestDescription : public ITestDescription { |
| 126 | +public: |
| 127 | + IncrementAndDecrementTestDescription(size_t index, DataT retrieved_val, |
| 128 | + DataT expected_val, |
| 129 | + const std::string &error_details, |
| 130 | + const std::string &data_type) |
| 131 | + : m_data_type(data_type), m_retrieved_val(retrieved_val), |
| 132 | + m_expected_val(expected_val), m_index(index), |
| 133 | + m_error_details(error_details) {} |
| 134 | + |
| 135 | + std::string to_string() const override { |
| 136 | + std::string log_msg("Failed for simd<"); |
| 137 | + |
| 138 | + log_msg += m_data_type + ", " + std::to_string(NumElems) + ">"; |
| 139 | + log_msg += ", retrieved: " + std::to_string(m_retrieved_val); |
| 140 | + log_msg += ", expected: " + std::to_string(m_expected_val); |
| 141 | + log_msg += ", at index: " + std::to_string(m_index); |
| 142 | + log_msg += " for " + TestCaseT::get_description() + " operator: "; |
| 143 | + log_msg += m_error_details; |
| 144 | + |
| 145 | + return log_msg; |
| 146 | + } |
| 147 | + |
| 148 | +private: |
| 149 | + const std::string m_data_type; |
| 150 | + const DataT m_retrieved_val; |
| 151 | + const DataT m_expected_val; |
| 152 | + const size_t m_index; |
| 153 | + const std::string m_error_details; |
| 154 | +}; |
| 155 | + |
| 156 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
115 | 157 | struct base_test {
|
116 | 158 | template <typename DataT, int NumElems, typename TestCaseT>
|
117 | 159 | static std::vector<DataT> generate_input_data() {
|
@@ -168,7 +210,10 @@ template <typename IsAccuracyTestT, typename DataT, typename SizeT,
|
168 | 210 | typename TestCaseT>
|
169 | 211 | class run_test {
|
170 | 212 | static constexpr int NumElems = SizeT::value;
|
| 213 | +<<<<<<< HEAD |
171 | 214 | using TestDescriptionT = operators::TestDescription<NumElems, TestCaseT>;
|
| 215 | +======= |
| 216 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
172 | 217 |
|
173 | 218 | public:
|
174 | 219 | bool operator()(sycl::queue &queue, const std::string &data_type) {
|
@@ -198,7 +243,10 @@ class run_test {
|
198 | 243 | "Reference data size is not equal to the simd vector length.");
|
199 | 244 |
|
200 | 245 | bool passed = true;
|
| 246 | +<<<<<<< HEAD |
201 | 247 | log::trace<TestDescriptionT>(data_type);
|
| 248 | +======= |
| 249 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
202 | 250 |
|
203 | 251 | shared_allocator<DataT> allocator(queue);
|
204 | 252 | shared_vector<DataT> source_simd_out(NumElems, allocator);
|
@@ -226,31 +274,61 @@ class run_test {
|
226 | 274 | TestCaseT::apply_operator(expected_source_value);
|
227 | 275 |
|
228 | 276 | passed &= verify_result(i, expected_source_value, source_simd_out[i],
|
| 277 | +<<<<<<< HEAD |
229 | 278 | "argument modification", data_type);
|
230 | 279 | passed &= verify_result(i, expected_return_value, result_simd_out[i],
|
231 | 280 | "return value", data_type);
|
| 281 | +======= |
| 282 | + "unexpected argument modification", data_type); |
| 283 | + passed &= verify_result(i, expected_return_value, result_simd_out[i], |
| 284 | + "unexpected return value", data_type); |
| 285 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
232 | 286 | }
|
233 | 287 |
|
234 | 288 | return passed;
|
235 | 289 | }
|
236 | 290 |
|
237 | 291 | bool verify_result(size_t i, DataT expected, DataT retrieved,
|
| 292 | +<<<<<<< HEAD |
238 | 293 | const std::string &value_description,
|
| 294 | +======= |
| 295 | + const std::string &simd_type, |
| 296 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
239 | 297 | const std::string &data_type) {
|
240 | 298 | bool passed = true;
|
241 | 299 | if constexpr (type_traits::is_sycl_floating_point_v<DataT>) {
|
242 | 300 | if (std::isnan(expected) && !std::isnan(retrieved)) {
|
243 | 301 | passed = false;
|
| 302 | +<<<<<<< HEAD |
244 | 303 | log::fail(TestDescriptionT(data_type), "Unexpected ",
|
245 | 304 | value_description, "at index ", i, ", retrieved: ", retrieved,
|
246 | 305 | ", expected: any NaN value");
|
| 306 | +======= |
| 307 | + |
| 308 | + // TODO: Make ITestDescription architecture more flexible. |
| 309 | + // We are assuming that the NaN opcode may differ |
| 310 | + std::string log_msg("Failed for simd<"); |
| 311 | + log_msg += data_type + ", " + std::to_string(NumElems) + ">"; |
| 312 | + log_msg += ". The element at index: " + std::to_string(i) + |
| 313 | + ", is not nan, but it should."; |
| 314 | + |
| 315 | + log::note(log_msg); |
| 316 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
247 | 317 | }
|
248 | 318 | }
|
249 | 319 | if (!are_bitwise_equal(expected, retrieved)) {
|
250 | 320 | passed = false;
|
| 321 | +<<<<<<< HEAD |
251 | 322 | log::fail(TestDescriptionT(data_type), "Unexpected ",
|
252 | 323 | value_description, "at index ", i, ", retrieved: ", retrieved,
|
253 | 324 | ", expected: ", expected);
|
| 325 | +======= |
| 326 | + |
| 327 | + const auto description = |
| 328 | + IncrementAndDecrementTestDescription<DataT, NumElems, TestCaseT>( |
| 329 | + i, retrieved, expected, simd_type, data_type); |
| 330 | + log::fail(description); |
| 331 | +>>>>>>> d6527a558 ([SYCL][ESIMD] Add tests on simd increment and decrement operators (#827)) |
254 | 332 | }
|
255 | 333 | return passed;
|
256 | 334 | }
|
|
0 commit comments