Skip to content

opencl: bugfix: missing increment of ref_count in ggml_backend_opencl_init() - #26162

Merged
lhez merged 1 commit into
ggml-org:masterfrom
akleine:master
Aug 2, 2026
Merged

opencl: bugfix: missing increment of ref_count in ggml_backend_opencl_init()#26162
lhez merged 1 commit into
ggml-org:masterfrom
akleine:master

Conversation

@akleine

@akleine akleine commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Overview

Add missing increment ref_count in ggml_backend_opencl_init()
Compare the similar method ggml_backend_opencl_device_init(), here we find the needed increment already.

Additional information

This is important later in the free() method of ggml_backend_opencl_context at program end.
If we do not increment the ref_count, the result would be -1 here, and consequently, some parts of free() would not executed. For example the profiling data would not be flushed and written. ( #ifdef GGML_OPENCL_PROFILING )

Requirements

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 )
@akleine
akleine requested a review from a team as a code owner July 27, 2026 05:38
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning OpenCL Issues specific to the OpenCL backend labels Jul 27, 2026
@akleine akleine changed the title opencl: bugfix increment ref_count in ggml_backend_opencl_init() opencl: bugfix: missing increment of ref_count in ggml_backend_opencl_init() Jul 28, 2026
@lhez

lhez commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Just as a note, this fixes a legacy API; now applications will likely go through the new backend API. But the fix does make sense.

@lhez
lhez merged commit c745be2 into ggml-org:master Aug 2, 2026
24 of 27 checks passed
kashif pushed a commit to kashif/llama.cpp that referenced this pull request Aug 2, 2026
…l-org#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 )
TheTom pushed a commit to TheTom/llama-cpp-turboquant that referenced this pull request Aug 3, 2026
…l-org#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 )
belarusian pushed a commit to belarusian/llama.cpp that referenced this pull request Aug 4, 2026
…l-org#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 )
smalinin pushed a commit to smalinin/llama.cpp that referenced this pull request Aug 4, 2026
…l-org#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 )
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 11, 2026
…l-org#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 )
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
…l-org#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 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning OpenCL Issues specific to the OpenCL backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants