Skip to content

Commit 7c50e3d

Browse files
vasilytricbb-sycl
authored andcommitted
[SYCL][ESIMD] Add tests for simd broadcast constructor (intel#690)
* [SYCL][ESIMD] Add test on simd broadcast constructor
1 parent 05a784f commit 7c50e3d

File tree

7 files changed

+62
-2
lines changed

7 files changed

+62
-2
lines changed

SYCL/ESIMD/api/functional/common.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ template <typename T> bool are_bitwise_equal(T lhs, T rhs) {
4848

4949
// Class used as a kernel ID.
5050
<<<<<<< HEAD
51+
<<<<<<< HEAD
5152
template <typename DataT, int NumElems, typename...> struct Kernel;
5253
=======
5354
template <typename DataT, int NumElems, typename T> struct Kernel;
5455
>>>>>>> 1017d075e ([SYCL][ESIMD] Add tests on simd copy and move assignment operators (#762))
56+
=======
57+
template <typename DataT, int NumElems, typename...> struct Kernel;
58+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
5559

5660
template <typename DataT>
5761
using shared_allocator = sycl::usm_allocator<DataT, sycl::usm::alloc::shared>;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#include "../value_conv.hpp"
1818
#include "common.hpp"
1919

20+
<<<<<<< HEAD
2021
namespace esimd = sycl::ext::intel::esimd;
22+
=======
23+
namespace esimd = sycl::ext::intel::experimental::esimd;
24+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
2125

2226
namespace esimd_test::api::functional::ctors {
2327

SYCL/ESIMD/api/functional/ctors/ctor_broadcast_core.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727

2828
#include "ctor_broadcast.hpp"
2929

30+
<<<<<<< HEAD
3031
using namespace sycl::ext::intel::esimd;
32+
=======
33+
using namespace sycl::ext::intel::experimental::esimd;
34+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
3135
using namespace esimd_test::api::functional;
3236

3337
int main(int, char **) {

SYCL/ESIMD/api/functional/ctors/ctor_broadcast_fp_extra.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727

2828
#include "ctor_broadcast.hpp"
2929

30+
<<<<<<< HEAD
3031
using namespace sycl::ext::intel::esimd;
32+
=======
33+
using namespace sycl::ext::intel::experimental::esimd;
34+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
3135
using namespace esimd_test::api::functional;
3236

3337
int main(int, char **) {

SYCL/ESIMD/api/functional/operators/operator_assignment.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ namespace esimd_test::api::functional::operators {
2929
// The main test routine.
3030
// Using functor class to be able to iterate over the pre-defined data types.
3131
<<<<<<< HEAD
32+
<<<<<<< HEAD
3233
template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
3334
static constexpr int NumElems = SizeT::value;
3435
using TestDescriptionT = TestDescription<NumElems, TestCaseT>;
3536
=======
3637
template <typename DataT, typename DimT, typename TestCaseT> class run_test {
3738
static constexpr int NumElems = DimT::value;
3839
>>>>>>> 1017d075e ([SYCL][ESIMD] Add tests on simd copy and move assignment operators (#762))
40+
=======
41+
template <typename DataT, typename SizeT, typename TestCaseT> class run_test {
42+
static constexpr int NumElems = SizeT::value;
43+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
3944

4045
public:
4146
bool operator()(sycl::queue &queue, const std::string &data_type) {

SYCL/ESIMD/api/functional/operators/operator_assignment_move_and_copy_core.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int main(int, char **) {
8585

8686
bool passed = true;
8787

88+
<<<<<<< HEAD
8889
<<<<<<< HEAD
8990
const auto types = get_tested_types<tested_types::all>();
9091
<<<<<<< HEAD
@@ -95,17 +96,26 @@ int main(int, char **) {
9596
>>>>>>> d26b27f31 (Hotfix types for operator_assignment_move_and_copy_core (#833))
9697
const auto dims = get_all_dimensions();
9798
>>>>>>> 1017d075e ([SYCL][ESIMD] Add tests on simd copy and move assignment operators (#762))
99+
=======
100+
const auto types = get_tested_types<tested_types::all>();
101+
const auto all_sizes = get_all_sizes();
102+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
98103

99104
const auto context =
100105
unnamed_type_pack<move_assignment, copy_assignment>::generate();
101106

107+
<<<<<<< HEAD
102108
<<<<<<< HEAD
103109
passed &= for_all_combinations<operators::run_test>(types, all_sizes, context,
104110
queue);
105111
=======
106112
passed &=
107113
for_all_combinations<operators::run_test>(types, dims, context, queue);
108114
>>>>>>> 1017d075e ([SYCL][ESIMD] Add tests on simd copy and move assignment operators (#762))
115+
=======
116+
passed &= for_all_combinations<operators::run_test>(types, all_sizes, context,
117+
queue);
118+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
109119

110120
std::cout << (passed ? "=== Test passed\n" : "=== Test FAILED\n");
111121
return passed ? 0 : 1;

SYCL/ESIMD/api/functional/value_conv.hpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515

1616
#pragma once
1717

18+
<<<<<<< HEAD
1819
<<<<<<< HEAD
1920
#include "type_traits.hpp"
2021
=======
2122
>>>>>>> cfb578f75 ([SYCL][ESIMD] Add utility function for constructing conversion ref data (#696))
23+
=======
24+
#include "type_traits.hpp"
25+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
2226
#include "value.hpp"
2327

2428
namespace esimd_test::api::functional {
@@ -29,11 +33,15 @@ namespace esimd_test::api::functional {
2933
// static_cast<int>(unsigned int).
3034
template <typename SrcT, typename DstT> struct value_conv {
3135
static inline SrcT denorm_min() {
36+
<<<<<<< HEAD
3237
<<<<<<< HEAD
3338
if constexpr (!type_traits::is_sycl_floating_point_v<SrcT>) {
3439
=======
3540
if constexpr (!type_traits::is_sycl_floating_point_v<DataT>) {
3641
>>>>>>> cfb578f75 ([SYCL][ESIMD] Add utility function for constructing conversion ref data (#696))
42+
=======
43+
if constexpr (!type_traits::is_sycl_floating_point_v<SrcT>) {
44+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
3745
// Return zero for any integral type the same way std::denorm_min does
3846
return 0;
3947
} else if constexpr (sizeof(SrcT) > sizeof(DstT)) {
@@ -59,6 +67,7 @@ std::vector<SrcT> generate_ref_conv_data() {
5967

6068
// TODO: Implement functions for obtain lowest and max values without UB
6169
// cases.
70+
<<<<<<< HEAD
6271
<<<<<<< HEAD
6372
static const SrcT positive = static_cast<SrcT>(126.75);
6473
static const SrcT max = 10;
@@ -72,18 +81,32 @@ std::vector<SrcT> generate_ref_conv_data() {
7281
static const SrcT denorm = value_conv<SrcT, DstT>::denorm_min();
7382
static const SrcT positive = static_cast<SrcT>(126.75);
7483
>>>>>>> cfb578f75 ([SYCL][ESIMD] Add utility function for constructing conversion ref data (#696))
84+
=======
85+
static const SrcT positive = static_cast<SrcT>(126.75);
86+
static const SrcT max = 10;
87+
// Use zero for unsigned types
88+
static const SrcT min = std::min<SrcT>(-max, 0);
89+
static const SrcT max_half = max / 2;
90+
static const SrcT min_half = min / 2;
91+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
7592

7693
std::vector<SrcT> ref_data;
7794

7895
if constexpr (type_traits::is_sycl_floating_point_v<SrcT> &&
7996
type_traits::is_sycl_floating_point_v<DstT>) {
8097
<<<<<<< HEAD
98+
<<<<<<< HEAD
99+
=======
100+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
81101
static const SrcT nan = value<SrcT>::nan();
82102
static const SrcT inf = value<SrcT>::inf();
83103
static const SrcT denorm = value_conv<SrcT, DstT>::denorm_min();
84104

105+
<<<<<<< HEAD
85106
=======
86107
>>>>>>> cfb578f75 ([SYCL][ESIMD] Add utility function for constructing conversion ref data (#696))
108+
=======
109+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
87110
ref_data = details::construct_ref_data<SrcT, NumElems>(
88111
{min, max, -0.0, +0.0, 0.1, denorm, nan, -inf});
89112
} else if constexpr (type_traits::is_sycl_floating_point_v<SrcT> &&
@@ -112,14 +135,20 @@ std::vector<SrcT> generate_ref_conv_data() {
112135
ref_data = details::construct_ref_data<SrcT, NumElems>(
113136
{-0.0, max, max_half, -max_half});
114137
} else if constexpr (type_traits::is_sycl_floating_point_v<SrcT> &&
115-
std::is_signed_v<DstT>) {
138+
type_traits::is_sycl_signed_v<DstT>) {
116139
ref_data = details::construct_ref_data<SrcT, NumElems>(
117140
{-0.0, max, max_half, min, min_half});
118-
} else if constexpr (std::is_signed_v<SrcT> && std::is_signed_v<DstT>) {
141+
} else if constexpr (type_traits::is_sycl_signed_v<SrcT> &&
142+
type_traits::is_sycl_signed_v<DstT>) {
119143
ref_data = details::construct_ref_data<SrcT, NumElems>(
120144
{min, min_half, 0, max_half, max});
145+
<<<<<<< HEAD
121146
} else if constexpr (std::is_signed_v<SrcT> && std::is_unsigned_v<DstT>) {
122147
>>>>>>> cfb578f75 ([SYCL][ESIMD] Add utility function for constructing conversion ref data (#696))
148+
=======
149+
} else if constexpr (type_traits::is_sycl_signed_v<SrcT> &&
150+
std::is_unsigned_v<DstT>) {
151+
>>>>>>> e737b795e ([SYCL][ESIMD] Add tests for simd broadcast constructor (#690))
123152
static const SrcT src_min = value<SrcT>::lowest();
124153
static const SrcT src_min_half = src_min / 2;
125154

0 commit comments

Comments
 (0)