Skip to content

Commit 0c717f8

Browse files
Andrew Savonichevromanovvlad
authored andcommitted
[SYCL][TEST] Fix sporadic failure in kernel-and-program.cpp (#870)
clEnqueueWriteBuffer operation with `blocking == CL_TRUE' is *not* guaranteed to complete before it returns. It only guarantees that the host pointer (data) can now be re-used or free'ed: an OpenCL runtime either already completed the operation, or (the faulty case) an OpenCL runtime copied data to an internal (temporary) memory and the operation will be executed later. We have to explicitly finish the operation in order to avoid a data race when the faulty case happens. Signed-off-by: Andrew Savonichev <[email protected]>
1 parent 2abb131 commit 0c717f8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sycl/test/kernel-and-program/kernel-and-program.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ int main() {
6363
err = clEnqueueWriteBuffer(clQ, clBuffer, CL_TRUE, 0, sizeof(int),
6464
&data, 0, NULL, NULL);
6565
assert(err == CL_SUCCESS);
66+
clFinish(clQ);
6667
cl::sycl::program prog(ctx);
6768
prog.build_with_source(
6869
"kernel void SingleTask(global int* a) {*a+=1; }\n");

0 commit comments

Comments
 (0)