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

Commit a59dca5

Browse files
committed
Add test for buffer and vec byte_size() function
1 parent 718688c commit a59dca5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

SYCL/Basic/buffer/buffer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,13 @@ int main() {
693693
});
694694
}
695695

696+
{
697+
int data = 5;
698+
buffer<int, 1> Buffer(&data, range<1>(1));
699+
assert(Buffer.size() == 1);
700+
assert(Buffer.byte_size() == 1 * sizeof(int));
701+
}
702+
696703
// TODO tests with mutex property
697704
return failed;
698705
}

SYCL/Basic/vector_operators.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ void check_result_length_4(ResultVecT &res, ResultVecT &expected_res) {
3030
expected_res.template swizzle<s::elem::s3>()));
3131
}
3232

33+
template <typename T, int N> void check_vector_size() {
34+
using vec_type = s::vec<T, N>;
35+
vec_type Vec;
36+
constexpr auto length = (N == 3 ? 4 : N);
37+
assert(Vec.size() == N);
38+
assert(Vec.byte_size() == sizeof(T) * length);
39+
}
40+
3341
int main() {
3442

3543
/* Separate checks for NumElements=1 edge case */
@@ -267,5 +275,13 @@ int main() {
267275
check_result_length_4<res_vec_type>(res, expected);
268276
}
269277

278+
// size() and byte_size() functions
279+
{
280+
check_vector_size<char, 1>();
281+
check_vector_size<int, 2>();
282+
check_vector_size<float, 3>();
283+
check_vector_size<double, 4>();
284+
}
285+
270286
return 0;
271287
}

0 commit comments

Comments
 (0)