1010
1111RESULT_NAME = 'zeResult'
1212
13- $ze_api_yaml = YAML . load_file ( 'ze_api.yaml' )
13+ $ze_api_yaml = YAML . load_file ( 'ze_api.yaml' ) # $var represents global var. @var Instance var, @@var class var, var local var, VAR constant
1414$zet_api_yaml = YAML . load_file ( 'zet_api.yaml' )
1515$zes_api_yaml = YAML . load_file ( 'zes_api.yaml' )
1616$zel_api_yaml = YAML . load_file ( 'zel_api.yaml' )
3535typedefs = $ze_api[ 'typedefs' ] + $zet_api[ 'typedefs' ] + $zes_api[ 'typedefs' ] + $zel_api[ 'typedefs' ] + $zer_api[ 'typedefs' ] + $zex_api[ 'typedefs' ]
3636structs = $ze_api[ 'structs' ] + $zet_api[ 'structs' ] + $zes_api[ 'structs' ] + $zel_api[ 'structs' ] + $zer_api[ 'structs' ] + $zex_api[ 'structs' ]
3737
38- find_all_types ( typedefs )
38+ find_all_types ( typedefs ) #yaml_ast.rb
3939gen_struct_map ( typedefs , structs )
4040gen_ffi_type_map ( typedefs )
4141
4242# zesInit is included here so that a pure-Sysman program (one that only calls
4343# zesInit, never zeInit) still triggers the tracer initialization.
4444# Ideally we would split this into INIT_ZE_FUNCTIONS / INIT_ZES_FUNCTIONS
4545# so each namespace initializes its own symbols.
46- INIT_FUNCTIONS = /zeInit|zeLoaderInit|zeInitDrivers|zesInit/
46+ INIT_FUNCTIONS = /zeInit|zeLoaderInit|zeInitDrivers|zesInit/ # REGEX
4747
4848$struct_type_conversion_table = {
4949 'ZE_STRUCTURE_TYPE_IMAGE_MEMORY_PROPERTIES_EXP' => 'ZE_STRUCTURE_TYPE_IMAGE_MEMORY_EXP_PROPERTIES' ,
@@ -274,11 +274,23 @@ def upper_snake_case(str)
274274 _on_destroy_event(hEvent);
275275EOF
276276
277+ # Emit device_peer_access tracepoints after the loader hands back the driver
278+ # list. Guarded on phDrivers so the count-only invocation (phDrivers == NULL)
279+ # doesn't trigger a dump.
280+ p2p_epilogue = <<EOF
281+ if (_retval == ZE_RESULT_SUCCESS && phDrivers && pCount &&
282+ tracepoint_enabled(lttng_ust_ze_properties, zeMetadata_device_peer_access)) {
283+ _dump_p2p_all_drivers(*pCount, phDrivers);
284+ }
285+ EOF
286+ register_epilogue 'zeDriverGet' , p2p_epilogue
287+ register_epilogue 'zeInitDrivers' , p2p_epilogue
288+
277289# Dump memory info if required
278290memory_info_dump = lambda { |ptr_name |
279291 "_dump_memory_info(hCommandList, #{ ptr_name } )"
280292}
281-
293+ #memory info device,heap, etc. Only if paranoid memory tracking is enabled
282294memory_info_prologue = lambda { |ptr_names |
283295 <<EOF
284296 if (_do_paranoid_memory_location &&
@@ -346,6 +358,7 @@ def upper_snake_case(str)
346358EOF
347359}
348360
361+ # event name is known from API Spec
349362profiling_epilogue = lambda { |_event_name , waits_expr = 'phWaitEvents' , n_waits_expr = 'numWaitEvents' |
350363 <<EOF
351364 if (_do_profile && _einj) {
@@ -449,6 +462,8 @@ def upper_snake_case(str)
449462 }
450463EOF
451464
465+ # generates the dispatch table?
466+ # replaces the original function calls with the wrappers
452467( $ze_commands + $zet_commands + $zes_commands + $zel_commands + $zer_commands) . select do |c |
453468 c . name . match ( /(ze|zet|zes|zel|zer)Get.*ProcAddrTable/ )
454469end . each do |c |
@@ -576,4 +591,4 @@ def get_ffi_type(a)
576591
577592register_epilogue 'zeInit' , <<EOF
578593 _in_loader_init = 0;
579- EOF
594+ EOF
0 commit comments