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

[SYCL] Add test for buffer and vec byte_size() function #403

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions SYCL/Basic/buffer/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,13 @@ int main() {
});
}

{
int data = 5;
buffer<int, 1> Buffer(&data, range<1>(1));
assert(Buffer.size() == 1);
assert(Buffer.byte_size() == 1 * sizeof(int));
}

// TODO tests with mutex property
return failed;
}
16 changes: 16 additions & 0 deletions SYCL/Basic/vector_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ void check_result_length_4(ResultVecT &res, ResultVecT &expected_res) {
expected_res.template swizzle<s::elem::s3>()));
}

template <typename T, int N> void check_vector_size() {
using vec_type = s::vec<T, N>;
vec_type Vec;
constexpr auto length = (N == 3 ? 4 : N);
assert(Vec.size() == N);
assert(Vec.byte_size() == sizeof(T) * length);
}

int main() {

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

// size() and byte_size() functions
{
check_vector_size<char, 1>();
check_vector_size<int, 2>();
check_vector_size<float, 3>();
check_vector_size<double, 4>();
}

return 0;
}