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

Commit 6122c40

Browse files
[SYCL] Adjust reduction_ctor test and check reducer identity (#1577)
This commit changes the reduction_ctor test to use the new implementation details for reducer. This also adds a check for the identity() member function on reducer. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent e7dff93 commit 6122c40

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

SYCL/Reduction/reduction_ctor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// This performs basic checks such as reduction creation, getIdentity() method,
77
// and the combine() method of the aux class 'reducer'.
8+
// Note: This test relies on non-standard implementation details.
89

910
#include "reduction_utils.hpp"
1011
#include <cassert>
@@ -24,8 +25,10 @@ void test_reducer(Reduction &Redu, T A, T B) {
2425

2526
typename Reduction::binary_operation BOp;
2627
T ExpectedValue = BOp(A, B);
27-
assert(ExpectedValue == Reducer.MValue &&
28+
assert(ExpectedValue == detail::ReducerAccess{Reducer}.getElement(0) &&
2829
"Wrong result of binary operation.");
30+
assert(toBool(Reducer.identity() == Redu.getIdentity()) &&
31+
"Failed identity() check().");
2932
}
3033

3134
template <typename T, typename Reduction, typename BinaryOperation>
@@ -35,8 +38,11 @@ void test_reducer(Reduction &Redu, T Identity, BinaryOperation BOp, T A, T B) {
3538
Reducer.combine(B);
3639

3740
T ExpectedValue = BOp(A, B);
38-
assert(toBool(ExpectedValue == Reducer.MValue) &&
39-
"Wrong result of binary operation.");
41+
assert(
42+
toBool(ExpectedValue == detail::ReducerAccess{Reducer}.getElement(0)) &&
43+
"Wrong result of binary operation.");
44+
assert(toBool(Reducer.identity() == Redu.getIdentity()) &&
45+
"Failed identity() check().");
4046
}
4147

4248
template <typename... Ts> class KernelNameGroup;

0 commit comments

Comments
 (0)