8000 OpenCL: take include/CL and cl.xml from what Aurora applications use by TApplencourt · Pull Request #565 · argonne-lcf/THAPI · GitHub
[go: up one dir, main page]

Skip to content

OpenCL: take include/CL and cl.xml from what Aurora applications use - #565

Merged
TApplencourt merged 16 commits into
develfrom
opencl-headers
Nov 13, 2026
Merged

TApplencourt merged 16 commits into
develfrom
opencl-headers

Conversation

@TApplencourt
@TApplencourt TApplencourt commented Nov 9, 2026 •
Copy link
Copy Markdown
Collaborator

First of two PRs moving OpenCL onto the shared, header-driven generators. The second is #564, stacked on this one (it needs a rework for the new cl.xml).

Which version

The vendored headers dated from 2020 and cl.xml from 2021. Both now match what Aurora applications use (stack 26.181.0, same on Sunspot login and compute nodes):

  • The loader is the Khronos SDK v2023.12.14, but what matters is the extension signatures the Intel runtime (intel-opencl-25.18) implements, and applications compile against the headers oneAPI 2026.1 ships. Example: cl_khr_command_buffer 0.9.7 (CPU device), the revision of those headers: with the 2023 signatures, its calls get shifted arguments (CL_INVALID_VALUE). The reported revision does not always match the headers, though: the GPU reports cl_khr_external_memory 0.9.1, the headers declare 1.0.1 (its two prototypes are the same in both). What to compare is the prototypes, not the revision numbers.
  • include/CL/: KhronosGroup/OpenCL-Headers at 6eabe90 (2025-06-10), unmodified, identical to oneapi/compiler/2026.1/include/CL. Its core API is what the v2023.12.14 loader exports.
  • cl.xml: KhronosGroup/OpenCL-Docs at 5efafb0 (2025-06-10), unmodified. OpenCL-Headers' own generator, run on it, reproduces the headers except for 25 lines that declare no function. No OpenCL-Docs main commit of xml/cl.xml from 2024-11-12 to 2026-11-10 (46 tried) reproduces 6eabe90 exactly.

What

  • Headers and cl.xml as above. cl.xml.patch is rebased: it drops cl_icdl_info and clGetICDLoaderInfoOCLICD, which upstream now has, and three 2021 hunks that changed no generated file (cl_image_desc union, a cl_program_info comment, a blank line). The README lists what each remaining kind of hunk is for.
  • opencl_missing_apis.h (new, hand-written, like backends/hip/hip_missing_apis.h): the cl_execution_info_intel type and the 10 Intel entry points THAPI traces that no public header declares. Their signatures are the ones in cl.xml.patch.
  • The generated tracer_opencl.h workaround (gen_opencl_header.rb) is removed. It redefined types the old headers lacked, and these now clash with upstream. The build copies opencl_missing_apis.h under that name, because the probes include ./tracer_opencl.h.
  • cl.h.include drops cl_gl_ext.h and cl_ext_intel.h: upstream deprecated both, and opencl.h already includes their replacements.
  • The pointer typedefs are renamed <function>_t → <function>_ptr_t, because upstream now declares <function>_t as the function type of every entry point.
  • opencl_model.rb, so the generator reads the newer registry:
    • functions that only experimental extensions require are not traced (the headers hide them behind CL_ENABLE_BETA_EXTENSIONS, and their signatures change between revisions);
    • supported_extensions.yaml gets the 12 new KHR/EXT functions. No loader exports them, and the platform-less clGetExtensionFunctionAddress the tracer calls at load can return NULL even where the implementation provides the function (on the CPU platform, clCreateCommandBufferKHR is advertised and clGetExtensionFunctionAddressForPlatform returns it, but the platform-less call returns NULL). So they are traced per platform, through clGetExtensionFunctionAddress(ForPlatform) (otherwise the tracer prints Missing symbol for each when it loads). Every name listed there is now kept out of the load-time lookup automatically, so each function is listed once;
    • cl_khr_icd 2.0 driver entry points and PoCL functions are not traced;
    • cl_semaphore_khr is an object, and a returned cl_*_khr handle gets a field name without cl_/_khr;
    • libffi has no ffi_type_int (it's ffi_type_sint);
    • a function without parameters is still declared (void).
  • backends/opencl/README.md (new, like backends/ze/README.md): how to pick the version, find the matching cl.xml, rebase the patch and test, plus the problems this update ran into and their fixes. utils_spec_update/check_missing_apis.sh checks that opencl_missing_apis.h declares exactly the traced functions no header does. The build can't catch that: a missing prototype compiles, even with -Werror. utils_spec_update/extension_versions.sh lists, for each extension with host functions the node reports, the runtime's revision next to the headers'.

Generated output

161 → 173 traced functions, none removed: the semaphore and external-memory KHR functions, clGetImageRequirementsInfoEXT, clSetKernelArgDevicePointerEXT. Otherwise identical to devel except:

  1. clFoo_t → clFoo_ptr_t.
  2. No more #include <CL/cl_gl_ext.h>: it's now a stub with a #pragma message and no include guard, which gcc rejects inside lttng's re-inclusion.
  3. clCreateFromGLBuffer's errcode_ret is cl_int * (fixed in the registry; it was int *).
  4. clUnloadCompiler(void ) → clUnloadCompiler(void); CL_DEVICE_ID_INTEL (0x4251, asked by the SYCL runtime) is printed by name instead of 16977 (fix); clGetICDLoaderInfoOCLICD moves.
  5. opencl_model.yaml, which iprof -t reads for enum names, gains the new registry's names (device infos, error codes, command types, ...), types and structs; no existing name changes value. One removal: upstream moved the four CL_CONTEXT_DIAGNOSTICS_LEVEL_*_INTEL values out of cl_context_properties into their own type (cl_diagnostics_verbose_level renamed cl_diagnostic_verbose_level_intel). So an element of a context property list equal to 1, 2, 4 or 0xff is no longer printed as a diagnostics level: a fix for every element except the one after CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL, which now prints as a number. The printer should name each value by its key: OpenCL pretty-print: context property values are not named by their key #574.

Expected CI result: "Assert generated files are equivalent" fails on tracer_opencl.c, opencl_tracepoints.tp, opencl_model.yaml and btx_cl_model.yaml.

Checked

🤖 Generated with Claude Code

TApplencourt and others added 2 commits November 9, 2026 22:16
The official OpenCL headers declare `<function>_t` as the function type of
every entry point (cl_function_types.h, cl_ext.h, cl_egl.h ...), so the
tracer's own `<function>_t` pointer typedefs clash as soon as the vendored
headers are refreshed. Use `_ptr_t`, matching the `<function>_ptr` pointer
variables the tracer already has.

Generated tracer_opencl.c changes only by this rename (checked against
origin/devel modulo s/\bcl[A-Z]\w*_t\b/&ptr_t/); every other generated
file is identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The vendored headers were frozen in 2020. Take them from upstream
KhronosGroup/OpenCL-Headers at 82f6031 (2026-10-22), unmodified.

Upstream now declares everything the generated tracer_opencl.h worked
around (cl_icdl_info, the *_intel USM types ...) and clashed with it, so
that generator goes. What upstream still lacks moves to a hand-written
opencl_missing_apis.h, like backends/hip/hip_missing_apis.h: the
cl_execution_info_intel type and the 10 Intel entry points THAPI traces
that no public header declares (they live in Intel compute-runtime private
headers); signatures are those of cl.xml.patch. The probes include it as
./tracer_opencl.h, so the build copies it under that name.

cl.h.include no longer includes cl_gl_ext.h and cl_ext_intel.h: upstream
deprecated both (#pragma message), and opencl.h already includes cl_gl.h
and cl_ext.h.

This is the first step of moving OpenCL onto the h2yaml path: with these
headers, every one of the 161 traced functions is declared, with the same
parameter names as cl.xml.patch (the 2020 headers missed 12 and differed
on 3, e.g. clGetKernelArgInfo arg_indx).

Upstream cl_gl_ext.h is now a deprecated stub (an include of cl_gl.h plus
a #pragma message, no include guard). lttng-ust re-includes the probe
header inside expressions, where gcc rejects the #pragma, so the generated
tracer_opencl.c and opencl_tracepoints.tp stop including it; its content
lives in cl_gl.h, which both already include.

Generated files are unchanged but for that one include line. Builds with
-Werror (gcc 14, and clang with the CI flags).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TApplencourt
TApplencourt marked this pull request as ready for review November 9, 2026 22:38
TApplencourt and others added 2 commits November 12, 2026 23:49
backends/opencl/README.md gives the steps to refresh include/CL from
KhronosGroup/OpenCL-Headers, like backends/ze/README.md does for ze: copy
the headers unmodified, avoid the deprecated stubs, update
opencl_missing_apis.h, build, and compare the generated files.

utils_spec_update/check_missing_apis.sh diffs the functions THAPI traces
but no header declares against opencl_missing_apis.h. The build cannot
catch a stale list: a traced function without a prototype still compiles,
even with -Werror.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Needed to move cl.xml past 2021; no change to the generated code with the
current inputs, except cl_semaphore_khr in the opencl_model.yaml type list.

- Functions only experimental (formerly provisional) extensions require
  are not traced: the headers declare them only with
  CL_ENABLE_BETA_EXTENSIONS, and their signatures change between
  revisions (cl_khr_command_buffer 0.9.5 added an argument).
- ABSENT_FUNCTIONS includes supported_extensions.yaml: those are traced
  through clGetExtensionFunctionAddress(ForPlatform), so a new KHR/EXT
  function is listed once. Also the cl_khr_icd 2.0 driver entry points,
  which the loader calls.
- PoCL is a vendor suffix.
- cl_semaphore_khr is an object (libffi pointer, hex field), and the field
  of a returned cl_*_khr handle drops cl_ and _khr (`semaphore`, not a
  variable named after its type).
- libffi has no ffi_type_int: `int` is ffi_type_sint.
- A function without parameters is declared `(void)`: the registry used
  to list one `void` parameter, it now lists none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TApplencourt TApplencourt changed the title OpenCL: refresh include/CL from KhronosGroup/OpenCL-Headers OpenCL: take include/CL and cl.xml from what Aurora applications use Nov 13, 2026
TApplencourt and others added 7 commits November 13, 2026 15:56
Aurora (stack 26.181.0) has the Khronos loader v2023.12.14, but what
matters is the extension signatures the Intel runtime (25.18) implements,
and applications compile against the headers oneAPI 2026.1 ships. With
the 2023 signatures, cl_khr_command_buffer 0.9.7 (CPU device, the revision
of those headers) calls get shifted arguments. The reported revision can
still differ from the headers (GPU cl_khr_external_memory 0.9.1 vs 1.0.1,
same prototypes): compare prototypes, not revision numbers.

- include/CL: KhronosGroup/OpenCL-Headers 6eabe90 (2025-06-10), unmodified,
  identical to oneapi/compiler/2026.1/include/CL. Its core API is what the
  v2023.12.14 loader exports.
- cl.xml: KhronosGroup/OpenCL-Docs 5efafb0 (2025-06-10), unmodified. It
  regenerates the headers but for 25 lines declaring no function
  (cl_khr_external_semaphore_dx_fence, cl_khr_kernel_clock version). No
  OpenCL-Docs main commit of xml/cl.xml from 2024-11-12 to 2026-11-10
  reproduces 6eabe90 exactly.
- cl.xml.patch: rebased; drops cl_icdl_info and clGetICDLoaderInfoOCLICD,
  which upstream now has.
- supported_extensions.yaml: the 12 new KHR/EXT functions (semaphores,
  external memory, clGetImageRequirementsInfoEXT,
  clSetKernelArgDevicePointerEXT). No loader exports them, and the
  platform-less clGetExtensionFunctionAddress the tracer calls at load can
  return NULL even where the platform provides the function: without this,
  the tracer prints "Missing symbol" for each at load. They are traced per
  platform instead.

Generated code: 161 -> 173 traced functions, none removed. Other changes:
clCreateFromGLBuffer errcode_ret is `cl_int *` (registry fix),
`clUnloadCompiler(void )` -> `(void)`, CL_DEVICE_ID_INTEL now has a name,
and clGetICDLoaderInfoOCLICD moves.

Checked on a Sunspot GPU node: cl_vadd and SYCL-on-OpenCL traces have the
same events as devel, nothing on stderr, the same tally; old traces replay
the same. A cl_khr_command_buffer app still works under the tracer (CPU
device).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin to the implementation Aurora provides (the oneAPI headers), find the
cl.xml that regenerates the headers, rebase cl.xml.patch, test on a GPU
node, and the build or trace problems this update ran into, with their
fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Additions upstream now has must leave cl.xml.patch. A hunk that still
applies cleanly then defines the name twice, which patch does not report:
utils_spec_update/cl_xml_duplicates.sh lists the names a cl.xml defines
more than once, to compare with upstream's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cl.xml keeps some retired enum values in <!-- -->, such as
CL_DEVICE_PARENT_DEVICE_EXT 0x4030, defined once as 0x4054. Counting them
made four cl_ext_device_fission enums look defined twice upstream. Without
comments, upstream (2021, 5efafb0 and current main) defines every name
once, so the patched cl.xml must simply print nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Missing symbol: the platform-less clGetExtensionFunctionAddress the tracer
  uses at load can return NULL even where the implementation provides the
  function (clCreateCommandBufferKHR on the CPU platform).
- Which Version: the reported extension revision can differ from the
  headers (GPU cl_khr_external_memory 0.9.1 vs 1.0.1); compare prototypes.
- cl.xml: no OpenCL-Docs main commit since 2024-11 reproduces 6eabe90,
  rather than "never was on main".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the Intel commands (and cl_execution_info_intel) match
opencl_missing_apis.h; the other hunks adapt the registry to
gen_opencl_model.rb and the Ruby pretty printer. Each kind was reverted
and the files regenerated to record what breaks without it; the
cl_image_desc union and the cl_program_info comment hunks change nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- opencl_model.rb: the clIcd*/layer names get their own constant, and the
  extension-object return name a local, for Layout/ArrayAlignment and
  Layout/LineLength (CI also runs --display-only-safe-correctable).
- supported_extensions.yaml: drop the leading "---" (yamlfmt; devel has it
  too, linted now that the file changes), and say why the new functions are
  traced per platform: the platform-less lookup at load can return NULL.

Generated files unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- cl.xml.patch: drop the cl_image_desc union rewrite, the cl_program_info
  comment rewording (the upstream comment already matches) and a stray
  blank line. All generated files are byte-identical without them.
- opencl_model.rb: the per-platform reason is the platform-less lookup at
  load, not a missing implementation.
- opencl_missing_apis.h: say where Intel declares those functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TApplencourt and others added 4 commits November 13, 2026 17:53
The README grepped clinfo for cl_khr_command_buffer only, so it could not
catch a revision mismatch elsewhere (GPU cl_khr_external_memory 0.9.1 vs
the headers 1.0.1). utils_spec_update/extension_versions.sh lists, for each
extension with host functions (per cl.xml) that the node reports, the
revision the runtime reports next to CL_<EXT>_EXTENSION_VERSION.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each driver reports its own extensions, per device; the loader only
reports its own name and version and forwards the lookups to the drivers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the details of this particular update (search results, which hunks
were rejected, CPU/GPU anecdotes, sample output) and keep what to do and
why. The "Current" section still records the versions in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TApplencourt
TApplencourt merged commit ba1739a into devel Nov 13, 2026
26 of 27 checks passed
@TApplencourt
TApplencourt deleted the opencl-headers branch November 13, 2026 18:27
TApplencourt added a commit that referenced this pull request Nov 13, 2026
OpenCL was the one backend with a code generator of its own: cl.xml read
with Nokogiri by a 1300-line opencl_model.rb, with its own Command,
Parameter and meta-parameter classes and its own type-to-lttng mapping.
It now goes the way of ze, cuda and hip: the headers through h2yaml
(opencl_api.yaml), utils/command.rb's Command, utils/meta_parameters.rb,
print_tracepoint_provider and print_traced_wrappers.

The registry is still read, but only to produce data, by
gen_opencl_xml_yaml.rb (opencl_xml.yaml):
- the functions traced, in registry order, core vs. extension;
- every function's meta-parameter rows: the ones OpenCL's naming implies
  (event_wait_list, errcode_ret, param_value ...), the hand-written ones,
  and the queried param_name of clGet*Info;
- the declarations as the registry writes them, which the wrappers repeat;
- the enum/bitfield groups, typedef map and struct list opencl_model.yaml
  carries for the babeltrace model and the pretty-printer.
It also checks that the headers declare every traced function, with as
many parameters. The tracepoints keep the registry's parameter names
(opencl_model.rb renames the AST's): the oneAPI cl.h calls
clGetKernelArgInfo's arg_index `arg_indx`.

The registry rules of the header update (#565) move with the rest:
functions only experimental extensions require are not traced; the
clIcd*KHR and layer functions, and supported_extensions.yaml's, are not
looked up at load; PoCL is a vendor suffix; cl_semaphore_khr is a handle
(its result field is `semaphore`). OpenCL keeps spelling a C int
`ffi_type_sint` and an empty parameter list `(void)`.

opencl_meta_parameters.yaml spells out two things the old classes implied:
the `num_entries` size of four arrays, and clCreateSubBuffer's
buffer_create_info blob (an InLTTng row).

opencl_model.rb keeps what is OpenCL's own: its BackendContext settings,
the device-fission property list, and the prologues/epilogues (dump,
profiling, source capture, extension-function dispatch ...), unchanged.

Generated files are identical. Checked against origin/devel: every
generated file and exported symbol of every backend; make check; and iprof
pretty-print and tally of real OpenCL and SYCL-on-OpenCL traces.

CommandIndex no longer needs `pointer_name_of`, which existed for the
old OpenCL Command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TApplencourt added a commit that referenced this pull request Nov 13, 2026
* opencl: parse the headers with h2yaml into opencl_api.yaml

Like every other AST-driven backend: extract/opencl_api.h includes the
refreshed OpenCL headers plus opencl_missing_apis.h, and h2yaml turns them
into opencl_api.yaml. Nothing consumes it yet.

cl_platform.h includes the x86 intrinsic headers, and declares the vector
types of cl_float4 & co., when __SSE__, __SSE2__, __MMX__ or __AVX__ is
defined. A libclang without its own resource headers (the pip wheel CI
installs) falls back to GCC's intrinsics and cannot parse them, and
h2yaml 0.4.3 has no vector kind. No traced function takes a vector type,
so the h2yaml call undefines those four macros.

All 173 functions the XML path traces are in opencl_api.yaml, with the
same parameter names but for one: the oneAPI cl.h calls clGetKernelArgInfo's
arg_index `arg_indx`. Generated files are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* utils: let the shared generators say what OpenCL's output says

Preparation for moving OpenCL onto the shared, header-driven generators.
No generated file changes: every addition below is off unless a backend
asks for it, and none does yet.

Shared features any API needs:
- Typedefs of float classify as :float and trace with ctf_float.
- An unsized array parameter (`T x[]`) is the pointer C decays it to.
- A meta-parameter row may end in a mapping of keyword options; OutScalar
  takes `nocheck:`, for a pointer the tracer has already made non-NULL.
- load_meta_parameters accepts an absolute path, for a generated spec.
- A declared event with `start`/`stop` field lists wraps a call: it
  declares an entry and an exit tracepoint, like a traced function.
- print_tracepoint_provider takes a `preamble` printed before lttng's own
  header.
- get_ffi_type moves from ze_model.rb to utils/command.rb, so ze and
  OpenCL build their libffi closures with the same one.

Per-backend settings that keep the C OpenCL generated before byte-for-byte
(to be dropped in a follow-up that accepts the output change):
- ApiModel `trace_as:` traces a scalar typedef as the base type its chain
  reaches (cl_mem_flags as cl_ulong).
- BackendContext: result_field, duration, null_guard, null_test,
  xml_arg_spelling, legacy_blobs, pointer_type_suffix, declarations
  (documented where BackendContext is defined).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* opencl: generate from the headers, through the shared generators

OpenCL was the one backend with a code generator of its own: cl.xml read
with Nokogiri by a 1300-line opencl_model.rb, with its own Command,
Parameter and meta-parameter classes and its own type-to-lttng mapping.
It now goes the way of ze, cuda and hip: the headers through h2yaml
(opencl_api.yaml), utils/command.rb's Command, utils/meta_parameters.rb,
print_tracepoint_provider and print_traced_wrappers.

The registry is still read, but only to produce data, by
gen_opencl_xml_yaml.rb (opencl_xml.yaml):
- the functions traced, in registry order, core vs. extension;
- every function's meta-parameter rows: the ones OpenCL's naming implies
  (event_wait_list, errcode_ret, param_value ...), the hand-written ones,
  and the queried param_name of clGet*Info;
- the declarations as the registry writes them, which the wrappers repeat;
- the enum/bitfield groups, typedef map and struct list opencl_model.yaml
  carries for the babeltrace model and the pretty-printer.
It also checks that the headers declare every traced function, with as
many parameters. The tracepoints keep the registry's parameter names
(opencl_model.rb renames the AST's): the oneAPI cl.h calls
clGetKernelArgInfo's arg_index `arg_indx`.

The registry rules of the header update (#565) move with the rest:
functions only experimental extensions require are not traced; the
clIcd*KHR and layer functions, and supported_extensions.yaml's, are not
looked up at load; PoCL is a vendor suffix; cl_semaphore_khr is a handle
(its result field is `semaphore`). OpenCL keeps spelling a C int
`ffi_type_sint` and an empty parameter list `(void)`.

opencl_meta_parameters.yaml spells out two things the old classes implied:
the `num_entries` size of four arrays, and clCreateSubBuffer's
buffer_create_info blob (an InLTTng row).

opencl_model.rb keeps what is OpenCL's own: its BackendContext settings,
the device-fission property list, and the prologues/epilogues (dump,
profiling, source capture, extension-function dispatch ...), unchanged.

Generated files are identical. Checked against origin/devel: every
generated file and exported symbol of every backend; make check; and iprof
pretty-print and tally of real OpenCL and SYCL-on-OpenCL traces.

CommandIndex no longer needs `pointer_name_of`, which existed for the
old OpenCL Command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* opencl: simpler traced-function lists; README for the h2yaml path

gen_opencl_xml_yaml.rb:
- The traced lists are list operations, not regexes built from the lists.
- `spelled` loses its `strip:` option: it kept the trailing space of the
  one `void` parameter cl.xml no longer has.
- A supported_enums.yaml type that no <require comment> names stops the
  generator with a message. The XML generator crashed on it; the new one
  gave the type no values, silently.

README: point at where the code now lives (gen_opencl_xml_yaml.rb,
opencl_result_field, with_registry_names) and at the errors
gen_opencl_xml_yaml.rb raises; list CL_HDR_ROOT in the header steps.
Drop the `ffi_type_...` problem: the libffi types now come from the shared
map and the headers, as do the handles (CL_OBJECTS only feeds
opencl_model.yaml). Correct what the cl_affinity_domain_ext typedef hunk
does: without it, nothing crashes, type_map just lacks the entry.

Generated files are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* utils: take OpenCL's traced scalar names from the registry, not the AST

ApiModel's `trace_as` walked each typedef chain in the AST to find the
cl_* (or C) base type OpenCL records a scalar under (cl_mem_flags as
cl_ulong). gen_opencl_xml_yaml.rb already writes that mapping from the
registry (`type_map`): for every typedef both know, the two agree, and the
registry also covers types the parsed headers do not declare (beta,
Windows, layer). ApiModel now takes the map itself (`trace_names:`), and
find_trace_names goes.

Generated files are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* opencl: compute the implied meta-parameters next to the prologues

The meta-parameter rows OpenCL's naming conventions imply (event_wait_list,
errcode_ret, param_value_size_ret, param_value, event, and the queried
param_name of clGet*Info) were computed from the registry by
gen_opencl_xml_yaml.rb and read back as a generated spec. They depend on
the prologues of opencl_model.rb: errcode_ret and param_value_size_ret skip
their NULL check only because a prologue points them at a local. They are
now computed there, from the same AST the prologues read, and
opencl_xml.yaml only carries what the registry says.

Two utils changes made only to read that generated spec go back to
devel's code: load_meta_parameters takes a path under SRC_DIR again, and
no longer parses a trailing mapping of keyword options (the hand-written
specs never use one).

Generated files are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* opencl: rebuild the tracer and probes when the shared generators change

gen_opencl.rb and gen_opencl_probes.rb now require utils/gen_tracer_base.rb
and utils/gen_probe_base.rb, but tracer_opencl.c and opencl_tracepoints.tp
did not depend on them, as they do in every other backend: an edit to
either left OpenCL's generated files stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* utils: one libffi closure generator for ze and OpenCL

ze (zeDriverGetExtensionFunctionAddress) and OpenCL
(clGetExtensionFunctionAddress[ForPlatform]) hand out extension functions
that no library exports, and each driver returns its own: the tracer wraps
each real pointer in a libffi closure calling its `<command>_ffi` wrapper,
cached by pointer. Both models carried the same ~35-line C template for
it; now that both build their commands with utils/command.rb, it is one
function there, ffi_closure_epilogue, next to get_ffi_type. The callers
only say what differs: the lookup's provider and name variable, the
closure prefix, where the real pointer is, and how the lookup returns.

Generated files are identical (every backend).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* opencl: one source for handles, pointer parameters, and extension lookups

- CL_OBJECTS repeated what the registry and the headers say: the handles
  are the registry's pointer typedefs (`struct _cl_foo *`, `void *`) that
  the headers declare. The list stays, in the order opencl_model.yaml has
  it, but gen_opencl_xml_yaml.rb now stops when it is not exactly those, so
  a new handle can no longer be missed. The registry's `*`-before-<name>
  test is one function, also used for parameters.
- supported_extensions.yaml: a name cl.xml does not have stops the
  generator instead of being dropped silently.
- "Takes a pointer named x" was computed twice in opencl_model.rb: for the
  `nocheck` meta-parameters and for the prologues that make them safe. One
  pointer_parameter? now serves both.
- The two "named like an extension" selections (handed back by
  clGetExtensionFunctionAddress; looked up with it at load) sit together in
  opencl_model.rb instead of in two files.

Generated files are identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant

0