Repository navigation
OpenCL: remove the OpenCL-only generator paths, share the readers and the tracer helpers - #575
Open
TApplencourt wants to merge 20 commits into
Open
TApplencourt wants to merge 20 commits into
TApplencourt wants to merge 20 commits into
Conversation
The NULL-check, tracepoint-argument and declaration spellings, the traced type names, the tracepoint preamble and the libffi int override were kept by #564 so that it changed no generated file. The generated C now reads like the other backends: same events, same fields. clGetKernelArgInfo records its index as arg_indx, the name the header gives it (the registry says arg_index). The libffi wrappers ze and opencl print are one helper. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
OpenCL kept its own blob rule so that #564 changed no generated file: a void array was an octet-stream blob, a pointed-to struct was cast to uint8_t *, and an array of structs was a blob as long as its element count. The shared rule records the same bytes for the first two, and all the bytes of the third: clGetSupportedImageFormats recorded num_entries bytes of image_formats, it now records num_entries structs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
print_bt_model replaces OpenCL own model generator. For that the shared helper learns what OpenCL events have: ctf_enum fields, hand-written events with an entry and an exit, a result field named by the backend, and literal rows on by-value parameters (_param_name, #570). The headers #define the values of the enums, so OpenCLApi takes the enum and flag types from the registry groups. The model now names the class of each enum and flag field, records pointers as unsigned, and keeps _param_name in the clGet*Info exits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
cl_library.rb and babeltrace_opencl_lib.rb are generated by the shared library and printer generators; the hand-written printer and opencl_model.yaml, the file it read, are gone. The enum and flag classes come from the registry groups, the structs from the headers. What only OpenCL has stays in babeltrace_opencl_values.rb and a render hook: device-partition property lists, and what a clGet*Info call returned, read as opencl_infos.yaml says. The output takes the shared format (braces, padded hex). It names what it named before: error codes, enums, flags, partition lists, info values. Pointers the old printer showed in decimal are now in hex, and the exits of clGet*Info show the key they answered. For that the shared generators name the elements of an array of enums or flags, and a bitmask reads a composite flag back by its name (CL_DEVICE_TYPE_ALL). Both show in ze, cuda, hip and omp output too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…m groups The type map, the struct, scalar and handle lists and the CL_OBJECTS check only fed opencl_model.yaml: the readers now take them from the headers. cl_bool is a line of supported_enums.yaml like the other types, and the command-execution-status group, which nothing read, is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The registry converter no longer reads the types, so the two typedef hunks change nothing; neither do two of the bitfield comments. Found by dropping each hunk in turn: opencl_xml.yaml is identical. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Both tracers kept the same closure struct, hash and mutex, and the generated lookup epilogue repeated the same forty lines of libffi calls for every extension function. function_pointer_utils.h has them once: thapi_closure_for() finds or makes the closure of a real pointer, under one lock. The generated epilogue is a call to it per function (tracer_opencl.c: 2100 lines shorter). cuda carried a commented-out copy of the struct; removed. The opencl and cuda helpers are clang-formatted since they are touched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
result_field: result_name is one name for the API or a callable naming each command result, which is what OpenCL needs. duration: _duration is a tracer-filled parameter and a literal field, like any other (HostDuration, in opencl_model.rb), with the clock started by the last prologue. The shared generators no longer know about it. The events are laid out as before; the babeltrace model now lists _duration, which the trace always had, so the test inputs carry it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The twelve gen_<namespace>[_structs]_tracepoints.rb differed by the namespace alone. gen_ze_tracepoints.rb takes it from the name of the file the build asks for. The generated .tp files are identical. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
hip, mpi, cuda, cudart, opencl and ze each carried the same code to open the real library (the path from an environment variable, the check that dlopen did not hand the tracer back, the exit when there is none) and the same run-once guard around it. tracer_init_utils.h has both: thapi_dlopen_real() and THAPI_INIT_ONCE(). The failure message is now the same for all, on stderr: "THAPI: Failure: could not load <name> library!" (opencl printed it on stdout, hip, cudart and ze without the prefix). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…cl_model.yaml Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…me-version structs The printer named the class of the key of every clGet*Info call, but clGetICDLoaderInfoOCLICD has a key (cl_icdl_info) the registry gives no enum for: uninitialized constant CL::IcdlInfo, found by the integration test (clinfo). Such a value is printed as bytes, as before this branch. cl_name_version structs print their version as major.minor.patch again (the hand-written printer got that from opencl_ruby_ffi). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
_duration timed the real call alone (tracer_opencl.sh -h, 2020). iprof never set the option, so the field was always 0 there, and nothing reads it: the interval plugin takes exit minus entry, like the other backends. Gone with it: HostDuration and the prologue that had to stay the last one, do_host_profile, LTTNG_UST_OPENCL_HOST_PROFILE, and the field in the test inputs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… its key The key was looked up by the name its value reads back as, and the registry gives some keys two names: clGetKernelSubGroupInfo values were printed as bytes (the infos list CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, the value reads back as ..._KHR). Also: - uintptr_t values (SVM and USM pointers) are in hex again. - a set of flags is "[ A, B ]" everywhere. - the keys of a partition list that take a list of values come from the table the tracer walks the list with, through cl_library.rb. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- print_bt_model takes several declared-event files, so OpenCL does not pass a callable for its second one; a declared event is one event class or one per phase through the same code. - one expression names an enum or a set of flags, for a field and for an array of them. - a by-value parameter is told by its type, not by respond_to?. - two comments back on the code they describe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
README: the host-profile option, opencl_ruby_ffi (nothing requires it anymore, CI does not install it), opencl_result_name. .gitignore: the two generated readers instead of opencl_model.yaml. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The babeltrace2 gem built from the branch is installed with --local and needs ffi, which came in only as a dependency of opencl_ruby_ffi. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Follow-up of #564. That PR moved OpenCL onto the shared generators without changing a generated file. This one removes what it kept only for that, and puts the reading side (babeltrace model, Ruby printer) on the shared generators too. The generated files change; what is traced does not, except where listed below.
56 files, +715 −1533.
What changes
OpenCL-only settings removed from the shared generators. The NULL-check, argument and declaration spellings, the traced type names, the tracepoint preamble, the libffi
intoverride and the legacy blob rule are gone: the generated C reads like the other backends'.result_fieldbecameresult_nameaccepting a callable._durationand the--host-profileoption oftracer_opencl.share removed (see below). Onlypointer_type_suffixis left, and it is needed:cl_ext.handcl_egl.hdeclare<function>_t.Reading side on the shared generators.
btx_cl_model.yamlcomes fromprint_bt_model.cl_library.rbandbabeltrace_opencl_lib.rbare generated. The hand-written printer,opencl_model.yamland its generator are deleted.babeltrace_opencl_values.rb(device-partition property lists, what aclGet*Infocall returned), called through arender:hook ofprint_babeltrace_lib.gen_opencl_xml_yaml.rbnow gives only the traced functions and the enum groups. Four hunks ofcl.xml.patchthat no longer change anything are dropped.Shared C, in
utils/include.function_pointer_utils.h: the libffi closure struct, hash and mutex that ze and opencl each kept, plusthapi_closure_for(). The generated lookup epilogue is one call per extension function (tracer_opencl.cis 2100 lines shorter).tracer_init_utils.h: opening the real library and the run-once guard, which hip, mpi, cuda, cudart, opencl and ze each carried.ze. One
gen_ze_tracepoints.rbreplaces the twelve per-namespace generators. The.tpfiles are identical.Visible changes
propertiespointer is in hex instead of decimal. The exits ofclGet*Infoshow_param_name, the key they answered (this is opencl: keep _param_name in the babeltrace model #570, which this PR replaces).clGetKernelArgInforecordsarg_indx, the header's name; it wasarg_index, the registry's.clGetSupportedImageFormats:image_formats_valsholdsnum_entriesstructs; it heldnum_entriesbytes.x86-64/uint8_tinstead ofapplication/octet-stream.be_class: ze 2 fields, hip 2, omp 1, cuda 15); before, only a single enum or flag was named and an array printed as numbers.THAPI: Failure: could not load <name> library!on stderr. OpenCL printed it on stdout; hip, cudart and ze without the prefix._durationis gone from the OpenCL exit events, withtracer_opencl.sh -h/--host-profileandLTTNG_UST_OPENCL_HOST_PROFILE. It timed the real call alone (2020);iprofnever set the option, so the field was always 0 there, and nothing reads it: the interval plugin takes exit minus entry, like the other backends.opencl_ruby_ffiis no longer needed (README, CI).Checks (against devel 042fb3e)
make check: opencl 10/10, ze 9/9.clinfounder both tracers (406 OpenCL events, everyclGet*Info): same information; the new printer also decodescl_versionand capability values that were printed as bytes.iprof -b mpi: same events._durationremoved, info lookup by key value):make check, the 6 replays, the 11 apps andclinfoon the CPU runtime, and the printer fuzzer were run again. The GPU-node and MPI runs above are from before them.zexfunction was called through a closure in the ze runs; the OpenCL apps exercise the same closure code.be_classof their enum arrays (above)."Assert generated files are equivalent" fails by design: the workflow builds the same target list in both trees, and it now names
cl_library.rb, which devel does not have (it namedopencl_model.yaml, deleted here). It runs again once this is merged.🤖 Generated with Claude Code