@@ -26,7 +26,7 @@ using shared_vector = std::vector<DataT, shared_allocator<DataT>>;
26
26
27
27
using DataT = char ;
28
28
29
- template <int NumElems> int test_to_copy () {
29
+ template <int NumElems, bool IsAcc > int test_to_copy () {
30
30
sycl::queue queue;
31
31
constexpr int NumSelectedElems = NumElems / 3 ;
32
32
constexpr int Stride = 2 ;
@@ -47,21 +47,41 @@ template <int NumElems> int test_to_copy() {
47
47
ref_data_for_fill[i] =
48
48
initial_ref_data[i] + value_for_increase_ref_data_for_fill;
49
49
}
50
- queue.submit ([&](sycl::handler &cgh) {
51
- DataT *init_ref_ptr = initial_ref_data.data ();
52
- DataT *ref_data_for_fill_ptr = ref_data_for_fill.data ();
53
- DataT *const out_ptr = result.data ();
54
-
55
- cgh.single_task ([=]() SYCL_ESIMD_KERNEL {
56
- simd<DataT, NumElems> src_simd_obj;
57
- src_simd_obj.copy_from (init_ref_ptr);
58
- simd<DataT, NumSelectedElems> dst_simd_obj;
59
- dst_simd_obj.copy_from (ref_data_for_fill_ptr);
60
- src_simd_obj.template select <NumSelectedElems, Stride>(Offset) =
61
- dst_simd_obj;
62
- src_simd_obj.copy_to (out_ptr);
50
+ if constexpr (IsAcc) {
51
+ sycl::buffer<DataT> output_buf (result.data (), result.size ());
52
+ queue.submit ([&](sycl::handler &cgh) {
53
+ DataT *init_ref_ptr = initial_ref_data.data ();
54
+ DataT *ref_data_for_fill_ptr = ref_data_for_fill.data ();
55
+ auto acc =
56
+ output_buf.template get_access <sycl::access::mode::read_write>(cgh);
57
+
58
+ cgh.single_task ([=]() SYCL_ESIMD_KERNEL {
59
+ simd<DataT, NumElems> src_simd_obj;
60
+ src_simd_obj.copy_from (init_ref_ptr);
61
+ simd<DataT, NumSelectedElems> dst_simd_obj;
62
+ dst_simd_obj.copy_from (ref_data_for_fill_ptr);
63
+ src_simd_obj.template select <NumSelectedElems, Stride>(Offset) =
64
+ dst_simd_obj;
65
+ src_simd_obj.copy_to (acc, 0 );
66
+ });
63
67
});
64
- });
68
+ } else {
69
+ queue.submit ([&](sycl::handler &cgh) {
70
+ DataT *init_ref_ptr = initial_ref_data.data ();
71
+ DataT *ref_data_for_fill_ptr = ref_data_for_fill.data ();
72
+ DataT *const out_ptr = result.data ();
73
+
74
+ cgh.single_task ([=]() SYCL_ESIMD_KERNEL {
75
+ simd<DataT, NumElems> src_simd_obj;
76
+ src_simd_obj.copy_from (init_ref_ptr);
77
+ simd<DataT, NumSelectedElems> dst_simd_obj;
78
+ dst_simd_obj.copy_from (ref_data_for_fill_ptr);
79
+ src_simd_obj.template select <NumSelectedElems, Stride>(Offset) =
80
+ dst_simd_obj;
81
+ src_simd_obj.copy_to (out_ptr);
82
+ });
83
+ });
84
+ }
65
85
queue.wait_and_throw ();
66
86
67
87
std::vector<size_t > selected_indices;
@@ -114,13 +134,23 @@ template <int NumElems> int test_to_copy() {
114
134
int main () {
115
135
int test_result = 0 ;
116
136
117
- test_result |= test_to_copy<16 >();
118
- test_result |= test_to_copy<32 + 8 >();
119
- test_result |= test_to_copy<32 + 10 >();
120
- test_result |= test_to_copy<10 >();
121
- test_result |= test_to_copy<8 >();
122
- test_result |= test_to_copy<7 >();
123
- test_result |= test_to_copy<15 >();
137
+ test_result |= test_to_copy<16 , false >();
138
+ test_result |= test_to_copy<32 + 8 , false >();
139
+ test_result |= test_to_copy<32 + 10 , false >();
140
+ test_result |= test_to_copy<10 , false >();
141
+ test_result |= test_to_copy<8 , false >();
142
+ test_result |= test_to_copy<7 , false >();
143
+ test_result |= test_to_copy<15 , false >();
144
+ test_result |= test_to_copy<32 , false >();
145
+
146
+ test_result |= test_to_copy<16 , true >();
147
+ test_result |= test_to_copy<32 + 8 , true >();
148
+ test_result |= test_to_copy<32 + 10 , true >();
149
+ test_result |= test_to_copy<10 , true >();
150
+ test_result |= test_to_copy<8 , true >();
151
+ test_result |= test_to_copy<7 , true >();
152
+ test_result |= test_to_copy<15 , true >();
153
+ test_result |= test_to_copy<32 , true >();
124
154
125
155
if (!test_result) {
126
156
std::cout << " Test passed" << std::endl;
0 commit comments