14
14
// ===----------------------------------------------------------------------===//
15
15
16
16
#include < CL/sycl.hpp>
17
+ #include < algorithm>
17
18
#include < cstring>
18
19
#include < iostream>
20
+ #include < iterator>
19
21
20
22
using namespace cl ::sycl;
21
23
22
24
struct MyNestedStruct {
25
+ bool operator ==(const MyNestedStruct &Rhs) {
26
+ return (FldArr[0 ] == Rhs.FldArr [0 ] && FldFloat == Rhs.FldFloat );
27
+ }
23
28
cl::sycl::cl_char FldArr[1 ];
24
29
cl::sycl::cl_float FldFloat;
25
30
};
26
31
27
32
struct MyStruct {
33
+ bool operator ==(const MyStruct &Rhs) {
34
+ return (FldChar == Rhs.FldChar && FldLong == Rhs.FldLong &&
35
+ FldShort == Rhs.FldShort && FldUint == Rhs.FldUint &&
36
+ FldStruct == Rhs.FldStruct &&
37
+ std::equal (std::begin (FldArr), std::end (FldArr),
38
+ std::begin (Rhs.FldArr )) &&
39
+ FldInt == Rhs.FldInt );
40
+ }
28
41
cl::sycl::cl_char FldChar;
29
42
cl::sycl::cl_long FldLong;
30
43
cl::sycl::cl_short FldShort;
@@ -46,7 +59,7 @@ static void printStruct(const MyStruct &S0) {
46
59
47
60
bool test0 () {
48
61
MyStruct S = GlobS;
49
- MyStruct S0 = { 0 };
62
+ MyStruct S0 = {0 };
50
63
{
51
64
buffer<MyStruct, 1 > Buf (&S0, range<1 >(1 ));
52
65
queue myQueue;
@@ -55,7 +68,7 @@ bool test0() {
55
68
cgh.single_task <class MyKernel >([=] { B[0 ] = S; });
56
69
});
57
70
}
58
- bool Passed = (std::memcmp (&S0, &S, sizeof (MyStruct)) == 0 );
71
+ bool Passed = (S == S0 );
59
72
60
73
if (!Passed) {
61
74
std::cout << " test0 failed" << std::endl;
@@ -72,15 +85,14 @@ bool test0() {
72
85
bool test1 () {
73
86
range<3 > ice (8 , 9 , 10 );
74
87
uint ice2 = 888 ;
75
- uint result[4 ] = { 0 };
88
+ uint result[4 ] = {0 };
76
89
77
90
{
78
91
buffer<unsigned int , 1 > Buffer ((unsigned int *)result, range<1 >(4 ));
79
92
queue myQueue;
80
93
myQueue.submit ([&](handler &cgh) {
81
94
auto B = Buffer.get_access <access::mode::write>(cgh);
82
- cgh.parallel_for <class bufferByRange_cap >(range<1 >{ 4 },
83
- [=](id<1 > index) {
95
+ cgh.parallel_for <class bufferByRange_cap >(range<1 >{4 }, [=](id<1 > index) {
84
96
B[index.get (0 )] = index.get (0 ) > 2 ? ice2 : ice.get (index.get (0 ));
85
97
});
86
98
});
@@ -111,17 +123,16 @@ int main(int argc, char **argv) {
111
123
cl::sycl::cl_long PartLong = ((cl::sycl::cl_long)argc) << 32 ;
112
124
cl::sycl::cl_float PartFloat = argc;
113
125
114
- GlobS = { PartChar,
115
- PartLong,
116
- PartShort,
117
- PartUint,
118
- { { PartChar }, PartFloat },
119
- { PartShort, PartShort, PartShort },
120
- PartInt };
126
+ GlobS = {PartChar,
127
+ PartLong,
128
+ PartShort,
129
+ PartUint,
130
+ {{ PartChar}, PartFloat},
131
+ { PartShort, PartShort, PartShort},
132
+ PartInt};
121
133
122
134
bool Pass = test0 () & test1 ();
123
135
124
136
std::cout << " Test " << (Pass ? " passed" : " FAILED" ) << std::endl;
125
137
return Pass ? 0 : 1 ;
126
138
}
127
-
0 commit comments