Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix faulty accessor tests #731

Merged
Merged
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
45 changes: 25 additions & 20 deletions tests/accessor/generic_accessor_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ class run_api_tests {
: 8;
constexpr size_t offset = 4;
constexpr size_t index = 2;
constexpr size_t first_elem = (dims == 3 ? offset * 8 * 8 : 0) +
(dims >= 2 ? offset * 8 : 0) + offset;
constexpr size_t last_elem =
(dims == 3 ? (acc_range_size - 1) * 8 * 8 : 0) +
(dims >= 2 ? (acc_range_size - 1) * 8 : 0) + (acc_range_size - 1) +
first_elem;
int linear_index = 0;
for (size_t i = 0; i < dims; i++) {
linear_index += (offset + index) * pow(buff_range_size, dims - i - 1);
Expand Down Expand Up @@ -337,13 +343,13 @@ class run_api_tests {
cgh.host_task([=] {
test_accessor_ptr_host(acc, T());
test_begin_end_host(
acc, value_operations::init<T>(0),
value_operations::init<T>(buff_size - 1), false);
acc, value_operations::init<T>(first_elem),
value_operations::init<T>(last_elem), false);
auto &acc_ref1 =
get_subscript_overload<T, AccT, dims>(acc, index);
auto &acc_ref2 = acc[sycl::id<dims>()];
CHECK(value_operations::are_equal(acc_ref1, linear_index));
CHECK(value_operations::are_equal(acc_ref2, 0));
CHECK(value_operations::are_equal(acc_ref2, first_elem));
if constexpr (AccessMode != sycl::access_mode::read) {
value_operations::assign(acc_ref1, changed_val);
value_operations::assign(acc_ref2, expected_val);
Expand All @@ -355,14 +361,15 @@ class run_api_tests {
cgh.single_task<kname>([=]() {
test_accessor_ptr_device(acc, T(), res_acc);
res_acc[0] &= test_begin_end_device(
acc, value_operations::init<T>(0),
value_operations::init<T>(buff_size - 1), true);
acc, value_operations::init<T>(first_elem),
value_operations::init<T>(last_elem), true);
auto &acc_ref1 =
get_subscript_overload<T, AccT, dims>(acc, index);
auto &acc_ref2 = acc[sycl::id<dims>()];
res_acc[0] &=
value_operations::are_equal(acc_ref1, linear_index);
res_acc[0] &= value_operations::are_equal(acc_ref2, 0);
res_acc[0] &=
value_operations::are_equal(acc_ref2, first_elem);
if constexpr (AccessMode != sycl::access_mode::read) {
value_operations::assign(acc_ref1, changed_val);
value_operations::assign(acc_ref2, expected_val);
Expand All @@ -375,7 +382,7 @@ class run_api_tests {
if constexpr (Target == sycl::target::device) CHECK(res);
if constexpr (AccessMode != sycl::access_mode::read) {
CHECK(value_operations::are_equal(data[linear_index], changed_val));
CHECK(value_operations::are_equal(data[0], expected_val));
CHECK(value_operations::are_equal(data[first_elem], expected_val));
}
}
}
Expand Down Expand Up @@ -410,19 +417,17 @@ class run_api_tests {
using kname = kernel_swap<T, AccessT, DimensionT, TargetT>;
sycl::accessor res_acc(res_buf, cgh);
cgh.single_task<kname>([=]() {
if constexpr (0 < dims) {
typename AccT::reference acc_ref1 =
get_accessor_reference<dims>(acc1);
typename AccT::reference acc_ref2 =
get_accessor_reference<dims>(acc2);
res_acc[0] =
value_operations::are_equal(acc_ref1, changed_val);
res_acc[0] &=
value_operations::are_equal(acc_ref2, expected_val);
if constexpr (AccessMode != sycl::access_mode::read) {
value_operations::assign(acc_ref1, expected_val);
value_operations::assign(acc_ref2, changed_val);
}
typename AccT::reference acc_ref1 =
get_accessor_reference<dims>(acc1);
typename AccT::reference acc_ref2 =
get_accessor_reference<dims>(acc2);
res_acc[0] =
value_operations::are_equal(acc_ref1, changed_val);
res_acc[0] &=
value_operations::are_equal(acc_ref2, expected_val);
if constexpr (AccessMode != sycl::access_mode::read) {
value_operations::assign(acc_ref1, expected_val);
value_operations::assign(acc_ref2, changed_val);
}
});
}
Expand Down