Skip to content

Commit 280300d

Browse files
committed
opencl: bugfix increment ref_count in ggml_backend_opencl_init()
Incrementing `ref_count` at the beginning is important later in the `free()` method of the `ggml_backend_opencl_context` at program end. If we do not increment the `ref_count`, the result would be -1 here, and consequently, the profiling data would not be flushed and written. ( #ifdef GGML_OPENCL_PROFILING )
1 parent 88b47a7 commit 280300d

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7495,6 +7495,7 @@ static ggml_backend_i ggml_backend_opencl_i = {
74957495
ggml_backend_t ggml_backend_opencl_init(void) {
74967496
ggml_backend_dev_t dev = ggml_backend_reg_dev_get(ggml_backend_opencl_reg(), 0);
74977497
ggml_backend_opencl_context *backend_ctx = ggml_cl_init(dev);
7498+
backend_ctx->ref_count++;
74987499

74997500
ggml_backend_t backend = new ggml_backend {
75007501
/* .guid = */ ggml_backend_opencl_guid(),

0 commit comments

Comments
 (0)