Skip to content

Conversation

@martymichal
Copy link

@martymichal martymichal commented Nov 8, 2025

This is an RFC where I'd like to learn whether there's an interest in a Tracy-owned implementation of a OpenCL layer (https://github.com/KhronosGroup/OpenCL-ICD-Loader#about-layers) allowing to wrap around OpenCL calls to provide tracing functionality without direct modifications of application code.

This is an early PoC that works in my limited personal testing. Some considerations for further development would be

  • which functions to wrap around (probably all relevant for Buffer, Image and Memory objects, and for Pipes and SVM),
  • how many possible contexts to keep track of (currently hardcoded to 32 without proper checking of bounds),
  • how much extra detail to include for the individual objects (e.g., global/local workgroup size for kernel launches), and
  • whether keeping track of statistics makes sense.

Name, location, build system, name conventions are all up for discussion.

To test this, one needs to compile and launch their profiled application together with

  • OPENCL_LAYERS pointed to the appropriate shared object or
  • OPENCL_LAYER_PATH pointed at a directory where to scan for the shared object.

If the layer is loaded correctly, you should see a message at the top of the message log.

This adds a proof-of-concept of an OpenCL layer [0], a feature provided
by OpenCL-ICD-Loader, that adds the capability to trace OpenCL calls
without direct modifications to application code.

The current version only wraps around the

- clEnqueueNDRangeKernel
- clFinish

functions and is limited to 32 combinations of cl_context and
cl_device_id for getting their appropriate TracyCLCtx.

[0] https://github.com/KhronosGroup/OpenCL-ICD-Loader#about-layers
@martymichal martymichal force-pushed the wip/martymichal/opencl-layer branch from 01e4177 to 063367f Compare November 8, 2025 23:41
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