Skip to content

Commit 1bfe117

Browse files
committed
opencl: add backend_synchronize
* This is not needed by the normal use where the result is read using `tensor_get`, but it allows perf mode of `test-backend-ops` to properly measure performance.
1 parent e0e3aa2 commit 1bfe117

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ggml/src/ggml-opencl/ggml-opencl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,12 @@ static bool ggml_backend_opencl_cpy_tensor_async(ggml_backend_t backend, const g
18631863
}
18641864

18651865
static void ggml_backend_opencl_synchronize(ggml_backend_t backend) {
1866-
GGML_UNUSED(backend);
1866+
auto * backend_ctx = static_cast<ggml_backend_opencl_context *>(backend->context);
1867+
1868+
cl_event evt;
1869+
CL_CHECK(clEnqueueBarrierWithWaitList(backend_ctx->queue, 0, nullptr, &evt));
1870+
CL_CHECK(clWaitForEvents(1, &evt));
1871+
CL_CHECK(clReleaseEvent(evt));
18671872
}
18681873

18691874
// Syncronizes the 'backend_ctx's device with others so that commands
@@ -2052,7 +2057,7 @@ static ggml_backend_i ggml_backend_opencl_i = {
20522057
/* .set_tensor_async = */ NULL, /* ggml_backend_opencl_set_tensor_async */
20532058
/* .get_tensor_async = */ NULL, /* ggml_backend_opencl_get_tensor_async */
20542059
/* .cpy_tensor_async = */ NULL, /* ggml_backend_opencl_cpy_tensor_async */
2055-
/* .synchronize = */ NULL, /* ggml_backend_opencl_synchronize */
2060+
/* .synchronize = */ ggml_backend_opencl_synchronize,
20562061
/* .graph_plan_create = */ NULL,
20572062
/* .graph_plan_free = */ NULL,
20582063
/* .graph_plan_update = */ NULL,

0 commit comments

Comments
 (0)