Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.
We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.
Thank you for your understanding.
## Summary
I've encountered a deadlock in the Mali-G52 OpenCL driver when creating circular event dependencies between two command queues. The `clFinish()` call hangs indefinitely.
## Environment
- **Device**: Radxa Rock 5 Model B- **GPU**: Mali-G52- **Driver**: ARM Mali OpenCL driver (latest available)- **OS**: Linux (ARM64)
## Reproducer
The following minimal C program demonstrates the issue:
```
#define CL_TARGET_OPENCL_VERSION 120#include <CL/cl.h>#include <stdio.h>#include <stdlib.h>
int main() { cl_platform_id platform; cl_device_id device; cl_context context; cl_command_queue q1, q2; cl_event e1, e2; cl_int err;
// Get platform and GPU device (code omitted for brevity) // ... standard OpenCL initialization ...
context = clCreateContext(NULL, 1, &device, NULL, NULL, &err); q1 = clCreateCommandQueue(context, device, 0, &err); q2 = clCreateCommandQueue(context, device, 0, &err);
for (int i = 0; i < 500; i++) { printf("Test %d\n", i); fflush(stdout);
// Create circular dependency err = clEnqueueMarkerWithWaitList(q1, 0, NULL, &e1); err = clEnqueueMarkerWithWaitList(q2, 1, &e1, NULL); // q2 waits for e1 err = clEnqueueMarkerWithWaitList(q2, 0, NULL, &e2); err = clEnqueueMarkerWithWaitList(q1, 1, &e2, NULL); // q1 waits for e2 clReleaseEvent(e1); clReleaseEvent(e2);
err = clEnqueueMarkerWithWaitList(q1, 0, NULL, &e1);
clFinish(q1); // <-- HANGS HERE on Mali-G52 clReleaseEvent(e1); }
// cleanup... printf("PASSED\n"); return 0;}
Does it work if you call clFlush(q2) before calling clFinish(q1)?
OpenCL doesn't track cross-queue dependencies so won't automatically flush q2.
From the clFlush API docs (edited for clarity):
To use event objects that refer to commands enqueued in a command-queue as event objects to wait on by commands enqueued in a different command-queue, the application must call a clFlush or use a blocking command that performs an implicit flush of the command-queue.