From: akleine Date: Sun, 2 Aug 2026 13:43:00 +0000 (+0200) Subject: opencl: bugfix increment ref_count in ggml_backend_opencl_init() (#26162) X-Git-Tag: upstream/0.0.10438~209 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=c745be2a2c5aefbf9f3ced0440804373731890b6;p=pkg%2Fggml%2Fsources%2Fllama.cpp opencl: bugfix increment ref_count in ggml_backend_opencl_init() (#26162) 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 ) --- diff --git a/ggml/src/ggml-opencl/ggml-opencl.cpp b/ggml/src/ggml-opencl/ggml-opencl.cpp index d07b8fe41..388c585fa 100644 --- a/ggml/src/ggml-opencl/ggml-opencl.cpp +++ b/ggml/src/ggml-opencl/ggml-opencl.cpp @@ -7495,6 +7495,7 @@ static ggml_backend_i ggml_backend_opencl_i = { ggml_backend_t ggml_backend_opencl_init(void) { ggml_backend_dev_t dev = ggml_backend_reg_dev_get(ggml_backend_opencl_reg(), 0); ggml_backend_opencl_context *backend_ctx = ggml_cl_init(dev); + backend_ctx->ref_count++; ggml_backend_t backend = new ggml_backend { /* .guid = */ ggml_backend_opencl_guid(),