8000 opencl: print property lists and 64-bit enum infos correctly by TApplencourt · Pull Request #569 · argonne-lcf/THAPI · GitHub
[go: up one dir, main page]

Skip to content

opencl: print property lists and 64-bit enum infos correctly - #569

Merged
TApplencourt merged 2 commits into
develfrom
fix-cl-print-property-lists
Nov 9, 2026
Merged

TApplencourt merged 2 commits into
develfrom
fix-cl-print-property-lists

Conversation

@TApplencourt
Copy link
Copy Markdown
Collaborator

Fixes #567.

Bug

The OpenCL pretty printer (backends/opencl/babeltrace_opencl_lib.rb) had two problems:

  • clGet*Info results were unpacked as 32-bit values for every enum, but cl_device_partition_property and cl_context_properties are intptr_t. Each element printed as two entries, and a value with no name printed as a blank. This affects CL_DEVICE_PARTITION_PROPERTIES, CL_DEVICE_PARTITION_TYPE and CL_CONTEXT_PROPERTIES.
  • Device-partition property lists (clCreateSubDevices(EXT) properties and CL_DEVICE_PARTITION_TYPE) were printed one element at a time through the key enum. So every 0 printed as CL_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

  • Unpack each enum as its C type (from the model's type_map), and print a value with no name as a number.
  • Add 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 a 0 outside a list prints as 0.
  • Name CL_DEVICE_PARTITION_BY_NAMES_INTEL, which cl.xml lacks.

Checked

I replayed the same traces with the old and new printer on Sunspot and diffed the output. Only these lines change:

old new
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 ]
clCreateSubDevices BY_COUNTS 4230 ["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]
clCreateSubDevices BY_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_TYPE of 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 ]
clCreateSubDevices BY_NAMES_INTEL 0,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]
clCreateSubDevicesEXT BY_NAMES_EXT 0,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 ]
  • A cl_vadd trace (info queries, properties, kernels, events) prints identically.
  • OpenCL make check passes 9/9.
  • rubocop: no net change for the file (one existing HashEachMethods offense gone, one OneClassPerFile added, because PartitionList sits beside Bitfield).

🤖 Generated with Claude Code

TApplencourt and others added 2 commits November 9, 2026 22:18
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>
@TApplencourt
TApplencourt merged commit 9b275e8 into devel Nov 9, 2026
27 checks passed
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.

OpenCL pretty-print: property lists and 64-bit enum info values are decoded wrongly

1 participant

0