@@ -42,10 +42,11 @@ template <typename... Ts> class KernelNameGroup;
42
42
template <typename SpecializationKernelName, typename T, int Dim,
43
43
class BinaryOperation >
44
44
void testKnown (T Identity, BinaryOperation BOp, T A, T B) {
45
- buffer<T, 1 > ReduBuf (1 );
46
-
47
45
static_assert (has_known_identity<BinaryOperation, T>::value);
48
46
queue Q;
47
+ buffer<T, 1 > ReduBuf (1 );
48
+ T* ReduUSMPtr = malloc_host<T>(1 , Q);
49
+
49
50
Q.submit ([&](handler &CGH) {
50
51
// Reduction needs a global_buffer accessor as a parameter.
51
52
// This accessor is not really used in this test.
@@ -55,29 +56,41 @@ void testKnown(T Identity, BinaryOperation BOp, T A, T B) {
55
56
ReduDWAcc (ReduBuf, CGH);
56
57
auto ReduRW = ONEAPI::reduction (ReduRWAcc, BOp);
57
58
auto ReduDW = ONEAPI::reduction (ReduDWAcc, BOp);
59
+ auto ReduRWUSM = ONEAPI::reduction (ReduUSMPtr, BOp);
58
60
auto ReduRW2020 = sycl::reduction (ReduBuf, CGH, BOp);
61
+ auto ReduRWUSM2020 = sycl::reduction (ReduUSMPtr, BOp);
62
+
59
63
assert (toBool (ReduRW.getIdentity () == Identity) &&
60
64
toBool (ReduDW.getIdentity () == Identity) &&
65
+ toBool (ReduRWUSM.getIdentity () == Identity) &&
61
66
toBool (ReduRW2020.getIdentity () == Identity) &&
67
+ toBool (ReduRWUSM2020.getIdentity () == Identity) &&
62
68
toBool (known_identity<BinaryOperation, T>::value == Identity) &&
63
69
" Failed getIdentity() check()." );
64
70
test_reducer (ReduRW, A, B);
65
71
test_reducer (ReduDW, A, B);
72
+ test_reducer (ReduRWUSM, A, B);
66
73
test_reducer (ReduRW2020, A, B);
74
+ test_reducer (ReduRWUSM2020, A, B);
75
+
67
76
test_reducer (ReduRW, Identity, BOp, A, B);
68
77
test_reducer (ReduDW, Identity, BOp, A, B);
78
+ test_reducer (ReduRWUSM, Identity, BOp, A, B);
69
79
test_reducer (ReduRW2020, Identity, BOp, A, B);
80
+ test_reducer (ReduRWUSM2020, Identity, BOp, A, B);
70
81
71
82
// Command group must have at least one task in it. Use an empty one.
72
83
CGH.single_task <SpecializationKernelName>([=]() {});
73
84
});
85
+ free (ReduUSMPtr, Q);
74
86
}
75
87
76
88
template <typename SpecializationKernelName, typename T, int Dim,
77
89
class BinaryOperation >
78
90
void testUnknown (T Identity, BinaryOperation BOp, T A, T B) {
79
- buffer<T, 1 > ReduBuf (1 );
80
91
queue Q;
92
+ buffer<T, 1 > ReduBuf (1 );
93
+ T* ReduUSMPtr = malloc_host<T>(1 , Q);
81
94
Q.submit ([&](handler &CGH) {
82
95
// Reduction needs a global_buffer accessor as a parameter.
83
96
// This accessor is not really used in this test.
@@ -87,18 +100,25 @@ void testUnknown(T Identity, BinaryOperation BOp, T A, T B) {
87
100
ReduDWAcc (ReduBuf, CGH);
88
101
auto ReduRW = ONEAPI::reduction (ReduRWAcc, Identity, BOp);
89
102
auto ReduDW = ONEAPI::reduction (ReduDWAcc, Identity, BOp);
103
+ auto ReduRWUSM = ONEAPI::reduction (ReduUSMPtr, Identity, BOp);
90
104
auto ReduRW2020 = sycl::reduction (ReduBuf, CGH, Identity, BOp);
105
+ auto ReduRWUSM2020 = sycl::reduction (ReduUSMPtr, Identity, BOp);
91
106
assert (toBool (ReduRW.getIdentity () == Identity) &&
92
107
toBool (ReduDW.getIdentity () == Identity) &&
108
+ toBool (ReduRWUSM.getIdentity () == Identity) &&
93
109
toBool (ReduRW2020.getIdentity () == Identity) &&
110
+ toBool (ReduRWUSM2020.getIdentity () == Identity) &&
94
111
" Failed getIdentity() check()." );
95
112
test_reducer (ReduRW, Identity, BOp, A, B);
96
113
test_reducer (ReduDW, Identity, BOp, A, B);
114
+ test_reducer (ReduRWUSM, Identity, BOp, A, B);
97
115
test_reducer (ReduRW2020, Identity, BOp, A, B);
116
+ test_reducer (ReduRWUSM2020, Identity, BOp, A, B);
98
117
99
118
// Command group must have at least one task in it. Use an empty one.
100
119
CGH.single_task <SpecializationKernelName>([=]() {});
101
120
});
121
+ free (ReduUSMPtr, Q);
102
122
}
103
123
104
124
template <typename SpecializationKernelName, typename T, class BinaryOperation >
0 commit comments