Skip to content

Add 'group' attribute to enum definitions - #1636

Open
Kerilk wants to merge 7 commits into
KhronosGroup:mainfrom
bricevideau-ai:corwin/enum-group-registry
Open

Kerilk wants to merge 7 commits into
KhronosGroup:mainfrom
bricevideau-ai:corwin/enum-group-registry

Conversation

@Kerilk

@Kerilk Kerilk commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Adds an optional 'group' attribute to definitions in cl.xml, following the gl.xml convention: each token names the C value-set type(s) it belongs to (comma-separated for multi-role tokens). The RNC schema is extended with 'attribute group { text } ?' on enums.

Attributions were derived from the OpenCL core and extension specifications (cross-checked against the Khronos registry chapters and cl.xml's own containers), not from container names alone.

Changes xml/cl.xml and xml/registry.rnc only; generated headers are byte-identical (the attribute is metadata no current generator reads).

Chose not to implement the group property at the container level to avoid breaking the existing tooling.

Adds an optional 'group' attribute to <enum> definitions in cl.xml,
following the gl.xml convention: each token names the C value-set
type(s) it belongs to (comma-separated for multi-role tokens). The
RNC schema is extended with 'attribute group { text } ?' on enums.

Attributions were derived from the OpenCL core and extension
specifications (cross-checked against the Khronos registry chapters
and cl.xml's own containers), not from container names alone.

Changes xml/cl.xml and xml/registry.rnc only; generated headers are
byte-identical (the attribute is metadata no current generator reads).
@CLAassistant

CLAassistant commented Oct 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bashbaug bashbaug left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Mostly LGTM, but here are a few things I would check.

The biggest question IMHO is what to do when a type / "group" starts as an extension and get promoted to a core feature, or moves from one extension type to another (e.g. vendor -> ext -> khr).

Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment on lines +856 to +859
<enum value="0x0" name="CL_COMPLETE" group="clCommandExecutionStatus"/>
<enum value="0x1" name="CL_RUNNING" group="clCommandExecutionStatus"/>
<enum value="0x2" name="CL_SUBMITTED" group="clCommandExecutionStatus"/>
<enum value="0x3" name="CL_QUEUED" group="clCommandExecutionStatus"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little strange that we don't name a type for this. Should we? Regardless, clCommandExecutionStatus looks a lot more like an API function name than a type name, so we might want to consider something different for it. Maybe just CommandExecutionStatus?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add a typedef cl_int cl_command_execution_status?

I agree with the above suggestion in the meantime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I changed the name of the group to CommandExecutionStatus I did not notice that the enum carries a name of clCommandExecutionStatus.

<enums name="clCommandExecutionStatus" vendor="Khronos">

Also we need to update CL_ECC_RECOVERED_IMG which for now carries clCommandExecutionStatus for a group.

@bashbaug what is your take on this? I am worried that changing the name field above might lead to problems for project that were relying on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have a perfect answer, but here are a few options to consider:

  1. Rename the enum name and group to cl_command_execution_status. This seems like the right thing to do with the benefit of hindsight. If we can convince ourselves that there is no problem actually adding the type (as you suggested above), then we can do so, but even if not I think this is the right name for the group.

  2. Rename the enum name and group to CommandExecutionStatus so it doesn't look like an API name or an official type name. We wouldn't add a typedef if we did this.

  3. Don't consider these enums part of any group (note that CL_COMMAND_EXECUTION_STATUS just returns a cl_int). I suspect this was probably done because the "command execution status" can also be an error code if the command is abnormally terminated.

    • Note, at some point in the future, maybe we should name error codes and address the command execution status at the same time - I think one of these PRs proposed doing something like this - but this would be a much bigger change.
  4. Just stick with clCommandExecutionStatus for now. It's a little weird, but we've been living with it, and we may as well stick with it if we aren't sure what a better name is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 seems reasonable to me, We'd need to revert one of the suggestions I merged, but that seems rather straightforward.

Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment on lines +1102 to +1104
<enums name="cl_arm_svm_alloc.flags" vendor="Arm" type="bitmask">
<enum bitpos="10" name="CL_MEM_SVM_FINE_GRAIN_BUFFER_ARM"/>
<enum bitpos="11" name="CL_MEM_SVM_ATOMICS_ARM"/>
<enum bitpos="10" name="CL_MEM_SVM_FINE_GRAIN_BUFFER_ARM" group="cl_arm_svm_alloc.flags"/>
<enum bitpos="11" name="CL_MEM_SVM_ATOMICS_ARM" group="cl_arm_svm_alloc.flags"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, these should probably be cl_svm_mem_flags_arm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this one. Other SVM flags that were accepted by the clSVMAllocARM should maby get cl_svm_mem_flags_arm a second tag, what do you think?

Comment thread xml/cl.xml
Comment on lines +1743 to +1744
<enum value="0x1093" name="CL_QUEUE_PROPERTIES" group="cl_command_queue_info,cl_queue_properties,cl_queue_properties_khr"/>
<enum value="0x1094" name="CL_QUEUE_SIZE" group="cl_command_queue_info,cl_queue_properties,cl_queue_properties_khr"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little confusing to me to list both cl_queue_properties and cl_queue_properties_khr here, but I do think this is correct. As a consideration for the future, if we ever do another extension like cl_khr_create_command_queue, are there things we should do differently that would be less confusing? Could we reuse the cl_queue_properties type, for example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this instance, the WithProperties API appeared first in an extension, and the type with it, so I am unsure how to get around this particular sequencing.

@Kerilk

Kerilk commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for doing this! Mostly LGTM, but here are a few things I would check.

Thanks for looking through it, and catching all those things I missed.

The biggest question IMHO is what to do when a type / "group" starts as an extension and get promoted to a core feature, or moves from one extension type to another (e.g. vendor -> ext -> khr).

Good question. I would prioritize the approach that would help type safety when creating bindings from the xml file, since I believe this is the main benefit from these changes.

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml Outdated
Comment thread xml/cl.xml
Comment on lines +1824 to +1825
<enum value="0x1112" name="CL_IMAGE_ROW_PITCH" group="cl_image_info"/>
<enum value="0x1113" name="CL_IMAGE_SLICE_PITCH" group="cl_image_info"/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<enum value="0x1112" name="CL_IMAGE_ROW_PITCH" group="cl_image_info"/>
<enum value="0x1113" name="CL_IMAGE_SLICE_PITCH" group="cl_image_info"/>
<enum value="0x1112" name="CL_IMAGE_ROW_PITCH" group="cl_image_info,cl_image_pitch_info_qcom"/>
<enum value="0x1113" name="CL_IMAGE_SLICE_PITCH" group="cl_image_info,cl_image_pitch_info_qcom"/>

@bashbaug I think this is also correct, and was proposed by earlier attempts at doing this.

bricevideau-ai added a commit to bricevideau-ai/OpenCL-Docs that referenced this pull request Oct 21, 2026
…istry branch

Brice opened KhronosGroup#1636 from the (squashed) registry
branch and applied 13-line review fixes via web UI (bashbaug + Kerilk
reviews, 2026-10-20). This branch now carries the identical cl.xml and
updated overrides/self-tests so re-running the engine cannot revert
them:

- CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL: group REMOVED (misc API constant)
- CL_LAYER_API_VERSION_100: cl_layer_info -> cl_layer_api_version
- CL_COMPLETE/RUNNING/SUBMITTED/QUEUED: clCommandExecutionStatus ->
  CommandExecutionStatus (reads as a type, not a function)
- CL_MIGRATE_MEM_OBJECT_HOST_EXT: cl_mem_migration_flags ->
  cl_mem_migration_flags_ext (the actual EXT param type)
- 4x CL_DEVICE_SVM_*_ARM -> cl_device_svm_capabilities_arm
- 2x CL_MEM_SVM_*_ARM -> cl_svm_mem_flags_arm

Battery: 319 overrides, 85/85 self-tests, XML valid, 1334/1334 agree,
cl.xml byte-identical to registry tip 03eabf3 (round-trip proof).
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.

4 participants