Repository navigation
opencl: map sub-devices created with a NULL count in the interval plugin - #573
Merged
Merged
Conversation
TApplencourt
force-pushed
the
fix-cl-sub-devices-count
branch
2 times, most recently
from
November 12, 2026 22:57
03ddde3 to
6cc9c7a
Compare
The interval plugin maps sub-devices to their root device by looping over the count clCreateSubDevices(EXT) returns. When the application passes NULL for that count, the tracer records 0, so the sub-devices were never mapped and a command on a sub-device was reported as running on a root device (did = <sub-device>, sdid = 0). The tracer records what the application did, so the fix is in the interval plugin: a successful call creates at least one sub-device, so a count of 0 means NULL. The plugin then maps every recorded entry of out_devices (the requested capacity), as it cannot know where the sub-devices end. New integration test backend_opencl.bats: create sub-devices with num_devices_ret = NULL, write a buffer on the first one, and check that iprof -e reports it with a Subdevice pointer. It fails before this change, and skips when the device cannot be partitioned. Fixes #572 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TApplencourt
force-pushed
the
fix-cl-sub-devices-count
branch
from
November 12, 2026 23:11
6cc9c7a to
d0b5284
Compare
Compile in the test, write the iprof analysis to a file and grep it, as backend_mpi.bats does. Drop the skip: CI (PoCL) partitions its device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…artitioned Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vices The program prints its root device and sub-device as the extended tally names them; the test greps that exact line in the analysis of the same run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iprof returns the program exit code, so one run gives both the skip status and the devices the program printed. Name the sub-device the program uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #572.
Bug
The interval plugin maps sub-devices to their root device by looping over the count
clCreateSubDevicesreturns (num_devices_ret_val). When the application passesnum_devices_ret = NULL, which is legal and common whenout_devicesis big enough, the tracer records 0. The loop then runs zero times, the sub-devices are never mapped, and thedevice_to_root_devicelookup at queue creation misses. A command on a sub-device is reported asdid = <sub-device>, sdid = 0, as if it were a root device. Same forclCreateSubDevicesEXT(num_devices).Fix
The tracer records what the application passed, so the fix is in the interval plugin (
btx_clinterval_callbacks.cpp), not in the tracer:NULL.out_devices. The tracer records that array with the requested capacity (num_devices), so the plugin cannot know where the sub-devices end. Entries past them are whatever the application left in its array.btx_clmatching_model.yamlpasses_out_devices_vals_lengthto both exit callbacks for this.When the count is known, nothing changes.
Checked
NULLcounts, a write on a sub-device is now reported asdid = <root>, sdid = <sub-device>, the same as when the application passes&n.integration_tests/backend_opencl.bats: the program creates sub-devices withnum_devices_ret = NULL, writes a buffer on one of them, and prints that root device and sub-device as the extended tally names them. The test runs it once underiprof -eand greps that line in the analysis. It fails without the fix (the tally reports the sub-device as the root device) and skips if the device can't be partitioned. The program builds against THAPI's own OpenCL headers andlibOpenCL.so.1, so the CI (PoCL) needs no new package.make checkpasses; shfmt and clang-format-18 are clean on the changed files.🤖 Generated with Claude Code