Skip to content

OpenCL: give each NN server thread its own command queue - #1267

Open
Sagebati wants to merge 1 commit into
lightvector:masterfrom
Sagebati:opencl-per-handle-command-queue
Open

Sagebati wants to merge 1 commit into
lightvector:masterfrom
Sagebati:opencl-per-handle-command-queue

Conversation

@Sagebati

@Sagebati Sagebati commented Oct 15, 2026 •

Copy link
Copy Markdown

Every OpenCL ComputeHandleInternal used the device's single in-order command queue (commandQueue = device->commandQueue), so with numNNServerThreadsPerModel > 1 the server threads' batches and blocking reads ran one after another. This gives each handle its own queue on the shared context and releases it in the destructor. Handles already own their weights, buffers and kernels, so nothing else needs locking.

katago testgpuerror -quick output is identical before and after (8 server threads, b10c128 and b20c256x2).

RX 6800 XT, ROCm OpenCL, analysis engine on 17 games, maxVisits 100, 256 analysis threads with 1 search thread each. Positions per second:

Model Before (best: 4 threads x batch 64) After (best: 8 threads x batch 32)
g170e-b10c128 74-77 151-152
g170e-b20c256x2 27 36

GPU busy goes from about 60% (b10) and 86% (b20) to 99%. Before the change, 8 server threads was slower than 4. I've only tested on AMD.

Every ComputeHandle on a device used the device's single in-order command
queue, so with numNNServerThreadsPerModel > 1 the server threads' batches
and blocking reads ran one after another and the GPU sat partly idle.
Create a queue per handle on the shared context and release it in the
destructor. Each handle already owns its weights, buffers and kernels, so
no other synchronization is needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant