@@ -150,6 +150,46 @@ void test2() {
150
150
}
151
151
}
152
152
153
+ // Same as above but with queue constructed out of context
154
+ void test2_1 () {
155
+ static constexpr int COUNT = 4 ;
156
+ buffer<int , 1 > Buffer1{BUFFER_SIZE};
157
+ buffer<int , 1 > Buffer2{BUFFER_SIZE};
158
+
159
+ auto Device = default_selector ().select_device ();
160
+ auto Context = context (Device);
161
+ // init the buffer with a'priori invalid data
162
+ {
163
+ queue Q (Context, Device);
164
+ init<int , -1 , -2 >(Buffer1, Buffer2, Q);
165
+ }
166
+
167
+ // Repeat a couple of times
168
+ for (size_t Idx = 0 ; Idx < COUNT; ++Idx) {
169
+ queue Q (Context, Device);
170
+ copy (Buffer1, Buffer2, Q);
171
+ modify (Buffer2, Q);
172
+ copy (Buffer2, Buffer1, Q);
173
+ }
174
+
175
+ {
176
+ auto Acc = Buffer1.get_access <mode::read>();
177
+
178
+ for (size_t Idx = 0 ; Idx < Acc.get_count (); ++Idx) {
179
+ std::cout << " First buffer [" << Idx << " ] = " << Acc[Idx] << std::endl;
180
+ assert ((Acc[Idx] == COUNT - 1 ) && " Invalid data in the first buffer" );
181
+ }
182
+ }
183
+ {
184
+ auto Acc = Buffer2.get_access <mode::read>();
185
+
186
+ for (size_t Idx = 0 ; Idx < Acc.get_count (); ++Idx) {
187
+ std::cout << " Second buffer [" << Idx << " ] = " << Acc[Idx] << std::endl;
188
+ assert ((Acc[Idx] == COUNT - 1 ) && " Invalid data in the second buffer" );
189
+ }
190
+ }
191
+ }
192
+
153
193
// A test that does a clEnqueueWait inside the interop scope, for an event
154
194
// captured outside the command group. The OpenCL event can be set after the
155
195
// command group finishes. Must not deadlock according to implementation and
@@ -251,6 +291,7 @@ void test6() {
251
291
int main () {
252
292
test1 ();
253
293
test2 ();
294
+ test2_1 ();
254
295
test3 ();
255
296
test4 ();
256
297
test5 ();
0 commit comments