Skip to content

Commit

Permalink
Merge pull request #790 from KornevNikita/fix-generic-accessor-core-api
Browse files Browse the repository at this point in the history
Fix generic_accessor_api_core test
  • Loading branch information
bader authored Aug 28, 2023
2 parents 447bceb + 87111b7 commit cf7a30c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tests/accessor/generic_accessor_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,25 @@ class run_api_tests {
SECTION(
get_section_name<dims>(type_name, access_mode_name, target_name,
"Check api for ranged accessor with offset")) {
constexpr size_t acc_range_size = 4;
constexpr size_t buff_range_size = 8;
constexpr size_t buff_size = (dims == 3) ? 8 * 8 * 8
: (dims == 2) ? 8 * 8
: 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;
// Partially duplicates tests/accessor/host_accessor_api_common.h
// The maximum value of the linear_index variable should not be more
// than CHAR_MAX (usually 127 for schar). Otherwise the test fails here
// with the char type:
// CHECK(value_operations::are_equal(acc_ref1, linear_index));
// CHECK(value_operations::are_equal(acc_ref2, first_elem));
// As data[x] contains corrupted by the overflow value.
constexpr size_t acc_range_size = 2;
constexpr size_t buff_range_size = 4;
constexpr size_t buff_size = (dims == 3) ? 4 * 4 * 4
: (dims == 2) ? 4 * 4
: 4;
constexpr size_t offset = 2;
constexpr size_t index = 1;
constexpr size_t first_elem = (dims == 3 ? offset * 4 * 4 : 0) +
(dims >= 2 ? offset * 4 : 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) +
(dims == 3 ? (acc_range_size - 1) * 4 * 4 : 0) +
(dims >= 2 ? (acc_range_size - 1) * 4 : 0) + (acc_range_size - 1) +
first_elem;
int linear_index = 0;
for (size_t i = 0; i < dims; i++) {
Expand Down
1 change: 1 addition & 0 deletions tests/accessor/host_accessor_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class run_api_tests {
SECTION(get_section_name<dims>(
type_name, access_mode_name,
"Check api for ranged host_accessor with offset")) {
// Partially duplicates tests/accessor/generic_accessor_api_common.h
// The maximum value of the linear_index variable should not be more
// than CHAR_MAX (usually 127 for schar). Otherwise the test fails here
// with the char type:
Expand Down

0 comments on commit cf7a30c

Please sign in to comment.