Repository navigation
opencl: print property lists and 64-bit enum infos correctly - #569
Merged
Merged
Conversation
The OpenCL pretty printer had two problems (#567): - clGet*Info results unpacked every enum as 32 bits, but cl_device_partition_property and cl_context_properties are intptr_t: each element printed as two, and values without a name as blanks. Unpack an enum as its C type, and print an unnamed value as a number. - Device-partition property lists (clCreateSubDevices(EXT) properties, CL_DEVICE_PARTITION_TYPE) were printed element by element through the key enum: every 0 printed as CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, a count equal to a key printed as that key, the affinity domain as a number. Walk the list instead, like the tracer does to size it: keys by the key enum, values by their key, terminators by their list. Also name CL_DEVICE_PARTITION_BY_NAMES_INTEL, which cl.xml lacks. Checked on Sunspot (Intel CPU OpenCL runtime, and a GPU trace) by replaying the same traces with the old and new printer. Only these lines change, for example: CL_DEVICE_PARTITION_PROPERTIES old [ CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_EQUALLY, ... (8 entries for 4 values) ] new [ CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_EQUALLY, CL_DEVICE_PARTITION_BY_NAMES_INTEL, CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN ] clCreateSubDevices BY_AFFINITY_DOMAIN old ["CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN", 1, "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END"] new ["CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN", "CL_DEVICE_AFFINITY_DOMAIN_NUMA", 0] CL_CONTEXT_PROPERTIES old [ CL_CONTEXT_PLATFORM, , , , , ] new [ CL_CONTEXT_PLATFORM, 348607456, 0 ] A cl_vadd trace prints identically. Fixes #567 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They evaluate values from opencl_model.yaml and the code the file generates; rubocop now fails the file on them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 13, 2026
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 #567.
Bug
The OpenCL pretty printer (
backends/opencl/babeltrace_opencl_lib.rb) had two problems:clGet*Inforesults were unpacked as 32-bit values for every enum, butcl_device_partition_propertyandcl_context_propertiesareintptr_t. Each element printed as two entries, and a value with no name printed as a blank. This affectsCL_DEVICE_PARTITION_PROPERTIES,CL_DEVICE_PARTITION_TYPEandCL_CONTEXT_PROPERTIES.clCreateSubDevices(EXT)properties andCL_DEVICE_PARTITION_TYPE) were printed one element at a time through the key enum. So every0printed asCL_DEVICE_PARTITION_BY_COUNTS_LIST_END, a count equal to a key printed as that key, and the affinity domain printed as a number.Fix
type_map), and print a value with no name as a number.PartitionList, which walks a partition list the way the tracer does to size it (opencl: size device-partition property lists by their keys #566). Keys are named by the key enum, values by their key, and each terminator by its own list. Terminators are no longer in the key enums, so a0outside a list prints as0.CL_DEVICE_PARTITION_BY_NAMES_INTEL, whichcl.xmllacks.Checked
I replayed the same traces with the old and new printer on Sunspot and diffed the output. Only these lines change:
CL_DEVICE_PARTITION_PROPERTIES(CPU)[ CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_EQUALLY, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, , CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END ][ CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_EQUALLY, CL_DEVICE_PARTITION_BY_NAMES_INTEL, CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN ]CL_DEVICE_PARTITION_PROPERTIES(GPU, SYCL trace)[ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END ][ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, 0 ]clCreateSubDevicesBY_COUNTS4230["CL_DEVICE_PARTITION_BY_COUNTS", "CL_DEVICE_PARTITION_EQUALLY", "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END", "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END"]["CL_DEVICE_PARTITION_BY_COUNTS", 4230, "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END", 0]clCreateSubDevicesBY_AFFINITY_DOMAIN["CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN", 1, "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END"]["CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN", "CL_DEVICE_AFFINITY_DOMAIN_NUMA", 0]CL_DEVICE_PARTITION_TYPEof that sub-device[ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, , CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END ][ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0 ]clCreateSubDevicesBY_NAMES_INTEL0,1[16466, "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END", 1, -1, "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END"]["CL_DEVICE_PARTITION_BY_NAMES_INTEL", 0, 1, "CL_PARTITION_BY_NAMES_LIST_END_INTEL", 0]clCreateSubDevicesEXTBY_NAMES_EXT0,1["CL_DEVICE_PARTITION_BY_NAMES_EXT", "CL_PARTITION_BY_COUNTS_LIST_END_EXT", 1, 18446744073709551615, "CL_PARTITION_BY_COUNTS_LIST_END_EXT"]["CL_DEVICE_PARTITION_BY_NAMES_EXT", 0, 1, "CL_PARTITION_B 8000 Y_NAMES_LIST_END_EXT", 0]CL_CONTEXT_PROPERTIES[ CL_CONTEXT_PLATFORM, , , , , ][ CL_CONTEXT_PLATFORM, 348607456, 0 ]cl_vaddtrace (info queries, properties, kernels, events) prints identically.make checkpasses 9/9.HashEachMethodsoffense gone, oneOneClassPerFileadded, becausePartitionListsits besideBitfield).🤖 Generated with Claude Code