Skip to content

Commit 0cdf646

Browse files
committed
Additional changes per reviewer's comments + fixed a warning (unused var)
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 9bc6e86 commit 0cdf646

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

sycl/include/CL/sycl/ONEAPI/reduction.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ class reduction_impl : private reduction_impl_base {
673673
}
674674

675675
/// Constructs a new temporary buffer to hold partial sums and returns
676-
/// the accessor that that buffer. Non-placeholder case.
676+
/// the accessor for that buffer. Non-placeholder case.
677677
template <bool IsOneWG, access::placeholder _IsPlaceholder = IsPlaceholder>
678678
std::enable_if_t<!IsOneWG && _IsPlaceholder == access::placeholder::false_t,
679679
accessor_type>
@@ -684,7 +684,7 @@ class reduction_impl : private reduction_impl_base {
684684
}
685685

686686
/// Constructs a new temporary buffer to hold partial sums and returns
687-
/// the accessor that that buffer. Placeholder case.
687+
/// the accessor for that buffer. Placeholder case.
688688
template <bool IsOneWG, access::placeholder _IsPlaceholder = IsPlaceholder>
689689
std::enable_if_t<!IsOneWG && _IsPlaceholder == access::placeholder::true_t,
690690
accessor_type>

sycl/include/CL/sycl/reduction.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::enable_if_t<has_known_identity<BinaryOperation, T>::value,
4343
ONEAPI::detail::reduction_impl<T, BinaryOperation, 1, false,
4444
access::mode::read_write,
4545
access::placeholder::true_t>>
46-
reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, BinaryOperation Combiner,
46+
reduction(buffer<T, 1, AllocatorT> Var, handler &CGH, BinaryOperation,
4747
const property_list &PropList = {}) {
4848
// TODO: need to handle 'PropList'.
4949
if (PropList.has_property<property::reduction::initialize_to_identity>())

sycl/test/basic_tests/reduction_ctor.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ template <typename... Ts> class KernelNameGroup;
4242
template <typename SpecializationKernelName, typename T, int Dim,
4343
class BinaryOperation>
4444
void testKnown(T Identity, BinaryOperation BOp, T A, T B) {
45-
buffer<T, 1> ReduBuf(1);
46-
4745
static_assert(has_known_identity<BinaryOperation, T>::value);
4846
queue Q;
47+
buffer<T, 1> ReduBuf(1);
48+
T* ReduUSMPtr = malloc_host<T>(1, Q);
49+
4950
Q.submit([&](handler &CGH) {
5051
// Reduction needs a global_buffer accessor as a parameter.
5152
// This accessor is not really used in this test.
@@ -55,29 +56,41 @@ void testKnown(T Identity, BinaryOperation BOp, T A, T B) {
5556
ReduDWAcc(ReduBuf, CGH);
5657
auto ReduRW = ONEAPI::reduction(ReduRWAcc, BOp);
5758
auto ReduDW = ONEAPI::reduction(ReduDWAcc, BOp);
59+
auto ReduRWUSM = ONEAPI::reduction(ReduUSMPtr, BOp);
5860
auto ReduRW2020 = sycl::reduction(ReduBuf, CGH, BOp);
61+
auto ReduRWUSM2020 = sycl::reduction(ReduUSMPtr, BOp);
62+
5963
assert(toBool(ReduRW.getIdentity() == Identity) &&
6064
toBool(ReduDW.getIdentity() == Identity) &&
65+
toBool(ReduRWUSM.getIdentity() == Identity) &&
6166
toBool(ReduRW2020.getIdentity() == Identity) &&
67+
toBool(ReduRWUSM2020.getIdentity() == Identity) &&
6268
toBool(known_identity<BinaryOperation, T>::value == Identity) &&
6369
"Failed getIdentity() check().");
6470
test_reducer(ReduRW, A, B);
6571
test_reducer(ReduDW, A, B);
72+
test_reducer(ReduRWUSM, A, B);
6673
test_reducer(ReduRW2020, A, B);
74+
test_reducer(ReduRWUSM2020, A, B);
75+
6776
test_reducer(ReduRW, Identity, BOp, A, B);
6877
test_reducer(ReduDW, Identity, BOp, A, B);
78+
test_reducer(ReduRWUSM, Identity, BOp, A, B);
6979
test_reducer(ReduRW2020, Identity, BOp, A, B);
80+
test_reducer(ReduRWUSM2020, Identity, BOp, A, B);
7081

7182
// Command group must have at least one task in it. Use an empty one.
7283
CGH.single_task<SpecializationKernelName>([=]() {});
7384
});
85+
free(ReduUSMPtr, Q);
7486
}
7587

7688
template <typename SpecializationKernelName, typename T, int Dim,
7789
class BinaryOperation>
7890
void testUnknown(T Identity, BinaryOperation BOp, T A, T B) {
79-
buffer<T, 1> ReduBuf(1);
8091
queue Q;
92+
buffer<T, 1> ReduBuf(1);
93+
T* ReduUSMPtr = malloc_host<T>(1, Q);
8194
Q.submit([&](handler &CGH) {
8295
// Reduction needs a global_buffer accessor as a parameter.
8396
// This accessor is not really used in this test.
@@ -87,18 +100,25 @@ void testUnknown(T Identity, BinaryOperation BOp, T A, T B) {
87100
ReduDWAcc(ReduBuf, CGH);
88101
auto ReduRW = ONEAPI::reduction(ReduRWAcc, Identity, BOp);
89102
auto ReduDW = ONEAPI::reduction(ReduDWAcc, Identity, BOp);
103+
auto ReduRWUSM = ONEAPI::reduction(ReduUSMPtr, Identity, BOp);
90104
auto ReduRW2020 = sycl::reduction(ReduBuf, CGH, Identity, BOp);
105+
auto ReduRWUSM2020 = sycl::reduction(ReduUSMPtr, Identity, BOp);
91106
assert(toBool(ReduRW.getIdentity() == Identity) &&
92107
toBool(ReduDW.getIdentity() == Identity) &&
108+
toBool(ReduRWUSM.getIdentity() == Identity) &&
93109
toBool(ReduRW2020.getIdentity() == Identity) &&
110+
toBool(ReduRWUSM2020.getIdentity() == Identity) &&
94111
"Failed getIdentity() check().");
95112
test_reducer(ReduRW, Identity, BOp, A, B);
96113
test_reducer(ReduDW, Identity, BOp, A, B);
114+
test_reducer(ReduRWUSM, Identity, BOp, A, B);
97115
test_reducer(ReduRW2020, Identity, BOp, A, B);
116+
test_reducer(ReduRWUSM2020, Identity, BOp, A, B);
98117

99118
// Command group must have at least one task in it. Use an empty one.
100119
CGH.single_task<SpecializationKernelName>([=]() {});
101120
});
121+
free(ReduUSMPtr, Q);
102122
}
103123

104124
template <typename SpecializationKernelName, typename T, class BinaryOperation>

0 commit comments

Comments
 (0)