Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add framework for extensions in API spec #950

Merged
merged 54 commits into from
Mar 20, 2024
Merged

Add framework for extensions in API spec #950

merged 54 commits into from
Mar 20, 2024

Conversation

oddhack
Copy link
Contributor

@oddhack oddhack commented Jul 11, 2023

Now integrates all khr extensions. Build with all extensions via

$ python3 makeSpec -clean -spec khr apihtml chtml (other 'make' arguments if needed)

or build with no extensions included via

$ python3 makeSpec -clean -spec core

Note: 'makeAll' script has been replaced by 'makeSpec' which has slightly different syntax.

oddhack added 20 commits July 11, 2023 04:47
cl_khr_integer_dot_product and cl_khr_command_buffer.
api/draft/ -> working versions of extension specs
api/draft/Snapshot/ -> latest snapshotted versions of ext/

Initially, these were identical to the published extension specs.
This was followed by a lot of markup cleanup and reorganization, moving
sections around to separate spec changes from extension appendix /
descriptions, adding refpage block headers, cleaning up C function
tables, making table headings uniform, using Title Case consistently in
section headers, and marking all khr extensions Ratified.
Resulting PDFs tend to be considerably smaller, and also runs about 15%
faster when doing a full PDF build (2:39 vs. 3:06 on my machine).

The hexapdf tool does need to be installed in the build environment - it
is in the khronosgroup/docker-images:asciidoctor-spec Docker image.
Add a workaround for safely importing api.py, so that a missing api.py +
empty 'api/' directory don't cause exceptions.

Update XML schema to sync with Vulkan insofar as possible.
Add depends / promotedto / supersededby / ratified attributes to XML
based on comments in extension specs and feedback from Ben, and start
converting extension appendices to use metadata includes.

Add missing OpenCL C extensions to cl.xml. This might impact downstream
header generation - to be checked.

Minor updates to metadocgenerator and conventions for OpenCL
split all extension documents into appendix and body (in draft/app/)
files. Move appendices into API spec directory, leaving the bodies to be
integrated in api/draft/.
And use Title Case consistently throughout the spec
Really just improve language describing them, since all the functions
were already in the OpenCL C spec as part of OpenCL 1.1.
@bashbaug
Copy link
Contributor

bashbaug commented Dec 4, 2023

This is looking really nice! A few comments from a brief review:

  1. It looks like some of the heading levels are slightly off for the extensions so the table of contents looks really bad. I think the extension name should be at the current level, but all other heading should be increased one level.
  2. The extension APIs don't seem to be linking at all, see for example clCreateCommandQueueWithPropertiesKHR.
  3. Most of the extension types don't seem to be linking at all either, though for some of these it's not clear what they would be linking to. The one exception I found is the new structure for cl_device_integer_dot_product_acceleration_properties_khr, which is linking nicely.
  4. The extension enums I tried are links, but they don't seem to be linking to anything. Not sure what's going on here.
  5. Editorial comment: some of the column widths seem to be "off" now, especially the clGetDeviceInfo table, where the leftmost column is very wide now. I suspect this is because it's sizing the column to fit the very long enum CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR text, which doesn't have <wbr> tags like the asciidoctor attributes do? One "solution" to fix this would be to omit the duplicated enum name from the text "CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR requires cl_khr_integer_dot_product", and just say something like "Requires cl_khr_integer_dot_product", which would be consistent with our other version text like "Missing before version 1.1."
  6. It'd be nice if there were some indicator tying an extension structure (like cl_device_integer_dot_product_acceleration_properties_khr) to the extension name, similar to the extension enums.

@oddhack
Copy link
Contributor Author

oddhack commented Dec 5, 2023

This is looking really nice! A few comments from a brief review:

  1. It looks like some of the heading levels are slightly off for the extensions so the table of contents looks really bad. I think the extension name should be at the current level, but all other heading should be increased one level.

Yes. I'm holding off on adjusting that sort of stuff in order to do it in one pass. Also there will be some increased autogeneration in the extension appendices before I'm done, for the interface summaries - the existing markup is largely a placeholder from the separate documents.

  1. The extension APIs don't seem to be linking at all, see for example clCreateCommandQueueWithPropertiesKHR.
  2. Most of the extension types don't seem to be linking at all either, though for some of these it's not clear what they would be linking to. The one exception I found is the new structure for cl_device_integer_dot_product_acceleration_properties_khr, which is linking nicely.
  3. The extension enums I tried are links, but they don't seem to be linking to anything. Not sure what's going on here.

All the extension appendices in the API spec have been done now, but the actual integration of changes / additions to the spec body remains TBD for a lot of them, which is what I'm focusing on now. Also, I'm not entirely clear on the conventions for the various asciidoctor attributes in the dictionaries so would appreciate some thoughts on (for example) these attributes extracted from the generated api-dictionary.asciidoc:

  • cl_device_integer_dot_product_capabilities_khr_TYPE - formatted text with breaks
  • cl_mutable_dispatch_exec_info_khr_TYPE_label - formatted text with breaks
  • cl_mutable_dispatch_exec_info_khr_TYPE - xref
  • clGetPlatformIDs_label - formatted text (perhaps with breaks?)
  • clGetPlatformIDs - xref
  • CL_CHAR_BIT_label - formatted text with breaks
  • CL_CHAR_BIT - xref
  • CL_CHAR_BIT_anchor - anchor

This is somewhat inconsistent:

  • why are the type names suffixed with '_TYPE' but the command / enum names are not?
  • cl_device_integer_dot_product_capabilities_khr (enumerated type) and cl_mutable_dispatch_exec_info_khr (struct) are treated differently even though they're both types:
    • the former gets only the formatted text attribute
    • the latter gets both formatted text and xref attributes

ISTM it would be more consistent to have

  • {API_label} -> text (always)
  • {API} -> xref (always),
  • {API_anchor} -> anchor (only needed for enum names, I think)

and no _TYPE suffixes at all (except for API names that actually contain _TYPE, as some enums do). That would cause some markup changes, though most of the 400-odd uses are just basic scalar (cl_uint etc.) names.

  1. Editorial comment: some of the column widths seem to be "off" now, especially the clGetDeviceInfo table, where the leftmost column is very wide now. I suspect this is because it's sizing the column to fit the very long enum CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR text, which doesn't have <wbr> tags like the asciidoctor attributes do? One "solution" to fix this would be to omit the duplicated enum name from the text "CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR requires cl_khr_integer_dot_product", and just say something like "Requires cl_khr_integer_dot_product", which would be consistent with our other version text like "Missing before version 1.1."

Will do.

  1. It'd be nice if there were some indicator tying an extension structure (like cl_device_integer_dot_product_acceleration_properties_khr) to the extension name, similar to the extension enums.

Also will do. Thanks for the feedback!

@bashbaug
Copy link
Contributor

bashbaug commented Dec 6, 2023

This is somewhat inconsistent:

  • why are the type names suffixed with '_TYPE' but the command / enum names are not?

  • cl_device_integer_dot_product_capabilities_khr (enumerated type) and cl_mutable_dispatch_exec_info_khr (struct) are treated differently even though they're both types:

    • the former gets only the formatted text attribute
    • the latter gets both formatted text and xref attributes

Yes, I agree this is a little confusing.

The reason the type names are suffixed with _TYPE is because asciidoctor attributes are not case-sensitive so we cannot otherwise differentiate between cl_float (the type) and CL_FLOAT (the enum). More info here: #444

We could have added a suffix to everything but that hasn't been needed so far.

IIRC the struct types get handled differently because the struct description gets generated from the XML and included in the spec so we have something to link to. The non-struct types do not, so we do not include a link for them. If we added a description for the other types (say, in an appendix) then we could link to them also, but we do not do this currently, and I'm not sure how much value it would add.

@oddhack oddhack changed the title Draft: Add framework for extensions in API spec Add framework for extensions in API spec Mar 11, 2024
@oddhack
Copy link
Contributor Author

oddhack commented Mar 11, 2024

@neiltrevett @bashbaug this is ready now. If possible, I recommend merging #1081 to the branch underlying #950 before merging #950. If the WG is not willing to take that step (removing the separate khr extension documents) yet, it can be retargeted to main and deferred. Any outstanding khr extension work in branches should be re-done as part of the API and C specs ASAP, to avoid divergences and rebasing pain.

I am pretty confident in how this looks now, but definitely review needed before publishing. I'm sure there will be some minor cleanup to deal with, and it would be an excellent idea to run a link-checker over the C and API specs prior to publication - there are many more internal links and a fair number of external links from the API spec extension appendices into the C spec.

I strongly recommend squash-on-merge when accepting #950. There is a huge amount of churn in the commits as this took many months to do incrementally, none of which is of particular interest to downstream extension work.

@oddhack
Copy link
Contributor Author

oddhack commented Mar 11, 2024

Another good consistency check will be a careful comparison of 'makeSpec -spec core chtml apihtml' with the current HTML from main branch. I have not done this for a while and while the differences should not be big, there are unavoidable diffs. N.b. I find 'wdiff -3 new.html old.html' to be quite useful when changes are small. There are some HTML comparison tools we use in Vulkan but they are... not great. I wish I knew of a great one.

Once we integrate all the khr extensions into the API and C specs, the
separate documents under ext/ will serve no purpose and will have the
risk of creating divergences between the sme content in the API / C
specs and the separate extension spec.

This removes the separate khr extension documents from the repo, and
strips down the OpenCL Extension spec to just point to the corresponding
extension appendix in the API spec. It will also serve as a forcing
function for all future extension development to be done against the API
/ C specs. Any outstanding PRs against these documents will have to be
rebased and the same edits reapplied to those specs, whether changes to
published extensions or in-flight, but as yet unpublished khr
extensions.

Ideally this would merge into #950 before that is merged to main, if the
WG can agree to that. It could also be retargeted to main instead, if
this decision will take longer than the timeframe for merging #950.
@bashbaug
Copy link
Contributor

Discussed in the March 12th teleconference and agreed to merge these changes in principle. We'll wait for the CI builds to complete and give one more quick review now that #1081 is merged, but assuming all goes well we'll merge these changes ASAP.

…1084)

Net effect is to rearrange the extension appendices so these extensions
are no longer in a 'provisional' subsection, and to remove the generated
comments about their being provisional from the extension refpages.
@bashbaug
Copy link
Contributor

@outofcontrol can you please check what's happening with the CLA bot for this PR? Thanks!

@KhronosWebservices
Copy link
Member

My bad. Used the wrong account for something which ate up the API rate limit for the account we use for cla-assisstant. :(

Will be up and running again within the hour.

@oddhack
Copy link
Contributor Author

oddhack commented Mar 20, 2024

@bashbaug if you want, I can just go ahead and merge this - not sure if you have those permissions on the repo or not? You probably should.

Since I'm a Khronos member I'm already covered for my contributions.

@KhronosWebservices
Copy link
Member

CLA-Assistant is responding again. Might be good to close and re-open this PR, have the reviewer sign-off, and the CLA check should then be available.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Merging as discussed in the March 12th and March 19th teleconferences.

@bashbaug bashbaug merged commit 774425a into main Mar 20, 2024
3 checks passed
@SunSerega
Copy link
Contributor

Can someone please explain what exactly being ratified means here? Is it something similar to being an ARB extension in OpenGL? Does it mean an extension is planned to be added to the future version of the core spec?

@oddhack
Copy link
Contributor Author

oddhack commented Mar 22, 2024

Can someone please explain what exactly being ratified means here? Is it something similar to being an ARB extension in OpenGL? Does it mean an extension is planned to be added to the future version of the core spec?

Yes, it is similar. Ratification has no effect on developers or users, but is of concern to implementers who want to be sure they do not implement functionality that is not covered by the reciprocal IP licensing obligations of the Khronos IP agreements. It means that Khronos has agreed that a core version or extension is covered by those agreements. There is no obligation or expectation that a ratified extension will become part of a future core API version, and many will not. Conversely non-ratified vendor or multivendor extensions are sometimes promoted to the core API, at which time they are ratified.

@SunSerega
Copy link
Contributor

SunSerega commented Mar 22, 2024

Thanks. Also, in registry.rnc:

#   depends - boolean expression of API and/or extension names
#       upon which this extension depends.

I would intuitively expect and/& as operators since this value is said to be a boolean expression, but currently I only see a + operator.
Well, it can be seen as a boolean operator too (but maybe or, not and?), but how about specifying this in the registry.rnc in more detail?
And does this mean the value can be something like (a+b) * (c+d) in the future?

And another thing:

        <extension name="cl_arm_get_core_id" condition="defined(CL_VERSION_1_2)" supported="opencl">
        <extension name="cl_ext_image_requirements_info" condition="defined(CL_VERSION_1_2)" supported="opencl">
        <extension name="cl_ext_image_from_buffer" condition="defined(CL_VERSION_1_2)" supported="opencl">

These were probably supposed to use this depends attribute instead of condition, since it now supports both extension and feature dependencies?

EwanC added a commit to EwanC/OpenCL-Docs that referenced this pull request Mar 25, 2024
After PR KhronosGroup#950 merged the cl_khr_command_buffer spec needs
updated in a couple of places:

* Error around _num_queues_ to `clCreateCommandBufferKHR` should
  be in terms of `cl_khr_command_buffer_multi_device`.
* "New Structure" heading can be deleted as these are listed under
  "New Types"
* Typos in rendering of some types
EwanC added a commit to EwanC/OpenCL-Docs that referenced this pull request Mar 26, 2024
After PR KhronosGroup#950 merged the cl_khr_command_buffer spec needs
updated in a couple of places:

* Error around _num_queues_ to `clCreateCommandBufferKHR` should
  be in terms of `cl_khr_command_buffer_multi_device`.
* "New Structure" heading can be deleted as these are listed under
  "New Types"
* Typos in rendering of some types
bashbaug pushed a commit that referenced this pull request Mar 26, 2024
After PR #950 merged the cl_khr_command_buffer spec needs
updated in a couple of places:

* Error around _num_queues_ to `clCreateCommandBufferKHR` should
  be in terms of `cl_khr_command_buffer_multi_device`.
* "New Structure" heading can be deleted as these are listed under
  "New Types"
* Typos in rendering of some types
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.

6 participants