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

Commit 729b4df

Browse files
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into esimd_emu_test_updates
2 parents 7d825a3 + c5012d6 commit 729b4df

26 files changed

+1005
-216
lines changed

SYCL/Basic/image/image_accessor_range.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// RUN: %CPU_RUN_PLACEHOLDER %t.out
1010
// RUN: %GPU_RUN_PLACEHOLDER %t.out
1111

12-
// XFAIL: level_zero
13-
1412
#include <CL/sycl.hpp>
1513
#include <CL/sycl/accessor.hpp>
1614
#include <iostream>

SYCL/ESIMD/api/functional/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Tests configuration options
2+
Tests within this directory has additional preprocessor definitions available.
3+
4+
`ESIMD_TESTS_VERBOSE_LOG` (default: not defined)
5+
Enables verbose log messages, including the trace messages for the current test
6+
case running. It could be usefull to investigate test failures, crashes or
7+
freezes.

SYCL/ESIMD/api/functional/common.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ template <typename T>
6161
inline bool should_skip_test_with(const sycl::device &device) {
6262
if constexpr (std::is_same_v<T, sycl::half>) {
6363
if (!device.has(sycl::aspect::fp16)) {
64-
log::note(
64+
// TODO: Use TestDescription after removal of the macro
65+
// ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
66+
log::print_line(
6567
"Device does not support half precision floating point operations");
6668
return true;
6769
}
6870
} else if constexpr (std::is_same_v<T, double>) {
6971
if (!device.has(sycl::aspect::fp64)) {
70-
log::note(
72+
log::print_line(
7173
"Device does not support double precision floating point operations");
7274
return true;
7375
}

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,44 @@
1414
#pragma once
1515

1616
#include "../common.hpp"
17+
#include <string>
1718

1819
namespace esimd_test::api::functional::ctors {
1920

20-
template <typename DataT, int NumElems, typename ContextT>
21+
#ifdef ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
22+
23+
template <int NumElems, typename ContextT>
2124
class TestDescription : public ITestDescription {
25+
public:
26+
TestDescription(const std::string &data_type) : m_data_type(data_type) {}
27+
28+
std::string to_string() const override {
29+
std::string test_description("simd<");
30+
31+
test_description += m_data_type + ", " + std::to_string(NumElems) + ">";
32+
test_description += ", with context: " + ContextT::get_description();
33+
34+
return test_description;
35+
}
36+
37+
private:
38+
const std::string m_data_type;
39+
};
40+
41+
#else
42+
43+
// Deprecated, use TestDescription<NumElems, ContextT> for new tests instead
44+
//
45+
// TODO: Remove deprecated TestDescription from all tests
46+
template <typename DataT, int NumElems, typename ContextT>
47+
class [[deprecated]] TestDescription : public ITestDescription {
2248
public:
2349
TestDescription(size_t index, DataT retrieved_val, DataT expected_val,
2450
const std::string &data_type)
2551
: m_data_type(data_type), m_retrieved_val(retrieved_val),
2652
m_expected_val(expected_val), m_index(index) {}
2753

2854
std::string to_string() const override {
29-
// TODO: Make strings for fp values more short during failure output, may be
30-
// by using hex representation
3155
std::string log_msg("Failed for simd<");
3256

3357
log_msg += m_data_type + ", " + std::to_string(NumElems) + ">";
@@ -46,4 +70,6 @@ class TestDescription : public ITestDescription {
4670
const size_t m_index;
4771
};
4872

73+
#endif // ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
74+
4975
} // namespace esimd_test::api::functional::ctors

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#pragma once
16+
#define ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
1617

1718
#include "common.hpp"
1819

@@ -93,14 +94,17 @@ class const_ref {
9394
// Using functor class to be able to iterate over the pre-defined data types.
9495
template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
9596
static constexpr int NumElems = SizeT::value;
97+
using TestDescriptionT = ctors::TestDescription<NumElems, TestCaseT>;
9698

9799
public:
98100
bool operator()(sycl::queue &queue, const std::string &data_type) {
101+
bool passed = true;
102+
log::trace<TestDescriptionT>(data_type);
103+
99104
if (should_skip_test_with<DataT>(queue.get_device())) {
100105
return true;
101106
}
102107

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

106110
// If current number of elements is equal to one, then run test with each
@@ -148,13 +152,13 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
148152
queue.wait_and_throw();
149153

150154
for (size_t i = 0; i < result.size(); ++i) {
151-
if (!are_bitwise_equal(ref_data[i], result[i])) {
152-
passed = false;
155+
const auto &expected = ref_data[i];
156+
const auto &retrieved = result[i];
153157

154-
const auto description =
155-
ctors::TestDescription<DataT, NumElems, TestCaseT>(
156-
i, result[i], ref_data[i], data_type);
157-
log::fail(description);
158+
if (!are_bitwise_equal(expected, retrieved)) {
159+
passed = false;
160+
log::fail(TestDescriptionT(data_type), "Unexpected value at index ", i,
161+
", retrieved: ", retrieved, ", expected: ", expected);
158162
}
159163
}
160164

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#pragma once
16+
#define ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
1617

1718
#include "common.hpp"
1819

@@ -90,14 +91,17 @@ class const_ref {
9091
// Using functor class to be able to iterate over the pre-defined data types.
9192
template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
9293
static constexpr int NumElems = SizeT::value;
94+
using TestDescriptionT = ctors::TestDescription<NumElems, TestCaseT>;
9395

9496
public:
9597
bool operator()(sycl::queue &queue, const std::string &data_type) {
98+
bool passed = true;
99+
log::trace<TestDescriptionT>(data_type);
100+
96101
if (should_skip_test_with<DataT>(queue.get_device())) {
97102
return true;
98103
}
99104

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

103107
// If current number of elements is equal to one, then run test with each
@@ -139,13 +143,13 @@ template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
139143
queue.wait_and_throw();
140144

141145
for (size_t i = 0; i < result.size(); ++i) {
142-
if (!are_bitwise_equal(ref_data[i], result[i])) {
143-
passed = false;
146+
const auto &expected = ref_data[i];
147+
const auto &retrieved = result[i];
144148

145-
const auto description =
146-
ctors::TestDescription<DataT, NumElems, TestCaseT>(
147-
i, result[i], ref_data[i], data_type);
148-
log::fail(description);
149+
if (!are_bitwise_equal(expected, retrieved)) {
150+
passed = false;
151+
log::fail(TestDescriptionT(data_type), "Unexpected value at index ", i,
152+
", retrieved: ", retrieved, ", expected: ", expected);
149153
}
150154
}
151155

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#pragma once
16+
#define ESIMD_TESTS_DISABLE_DEPRECATED_TEST_DESCRIPTION_FOR_LOGS
1617

1718
#include "common.hpp"
1819

@@ -78,14 +79,16 @@ struct const_ref {
7879
// Struct that calls simd in provided context and then verifies obtained result.
7980
template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
8081
static constexpr int NumElems = SizeT::value;
82+
using TestDescriptionT = ctors::TestDescription<NumElems, TestCaseT>;
8183

8284
bool operator()(sycl::queue &queue, const std::string &data_type) {
85+
bool passed = true;
86+
log::trace<TestDescriptionT>(data_type);
87+
8388
if (should_skip_test_with<DataT>(queue.get_device())) {
8489
return true;
8590
}
8691

87-
bool passed = true;
88-
8992
// We use it to avoid empty functions being optimized out by compiler
9093
// checking the result of the simd calling because values of the constructed
9194
// object's elements are undefined.
@@ -103,12 +106,8 @@ template <typename DataT, typename SizeT, typename TestCaseT> struct run_test {
103106
queue.wait_and_throw();
104107
} catch (const sycl::exception &e) {
105108
passed = false;
106-
std::string error_msg("A SYCL exception was caught:");
107-
error_msg += std::string(e.what());
108-
error_msg += " for simd<" + data_type;
109-
error_msg += ", " + std::to_string(NumElems) + ">";
110-
error_msg += ", with context: " + TestCaseT::get_description();
111-
log::note(error_msg);
109+
log::fail(TestDescriptionT(data_type), "A SYCL exception was caught: ",
110+
e.what());
112111
}
113112

114113
return passed;

0 commit comments

Comments
 (0)