@@ -177,14 +177,21 @@ namespace ze_lib
177177 return ZE_RESULT_ERROR_UNINITIALIZED;
178178 }
179179 tracing_lib = getTracing ();
180- typedef ze_result_t (ZE_APICALL *zelLoaderTracingLayerInit_t )(std::atomic<ze_dditable_t *> &zeDdiTable);
181- auto loaderTracingLayerInit = reinterpret_cast <zelLoaderTracingLayerInit_t >(
180+ typedef ze_result_t (ZE_APICALL *zelLoaderZeTracingLayerInit_t )(std::atomic<ze_dditable_t *> &zeDdiTable);
181+ auto loaderZeTracingLayerInit = reinterpret_cast <zelLoaderZeTracingLayerInit_t >(
182182 GET_FUNCTION_PTR (loader, " zelLoaderTracingLayerInit" ) );
183- if (loaderTracingLayerInit == nullptr ) {
183+ if (loaderZeTracingLayerInit == nullptr ) {
184184 std::string message = " ze_lib Context Init() zelLoaderTracingLayerInit missing, disabling dynamic tracer support " ;
185185 debug_trace_message (message, " " );
186186 this ->dynamicTracingSupported = false ;
187187 }
188+ typedef ze_result_t (ZE_APICALL *zelLoaderZerTracingLayerInit_t)(std::atomic<zer_dditable_t *> &zerDdiTable);
189+ auto loaderZerTracingLayerInit = reinterpret_cast <zelLoaderZerTracingLayerInit_t>(
190+ GET_FUNCTION_PTR (loader, " zelLoaderZerTracingLayerInit" ) );
191+ if (loaderZerTracingLayerInit == nullptr ) {
192+ std::string message = " ze_lib Context Init() zelLoaderZerTracingLayerInit missing, dynamic tracing support for Zer API's will be unavailable " ;
193+ debug_trace_message (message, " " );
194+ }
188195 typedef loader::context_t * (ZE_APICALL *zelLoaderGetContext_t)();
189196 auto loaderGetContext = reinterpret_cast <zelLoaderGetContext_t>(
190197 GET_FUNCTION_PTR (loader, " zelLoaderGetContext" ) );
@@ -280,11 +287,17 @@ namespace ze_lib
280287 if ( ZE_RESULT_SUCCESS == result )
281288 {
282289 #ifdef L0_STATIC_LOADER_BUILD
283- if (loaderTracingLayerInit) {
284- result = loaderTracingLayerInit (this ->pTracingZeDdiTable );
290+ if (loaderZeTracingLayerInit) {
291+ result = loaderZeTracingLayerInit (this ->pTracingZeDdiTable );
292+ if (result == ZE_RESULT_SUCCESS && loaderZerTracingLayerInit) {
293+ result = loaderZerTracingLayerInit (this ->pTracingZerDdiTable );
294+ }
285295 }
286296 #else
287297 result = zelLoaderTracingLayerInit (this ->pTracingZeDdiTable );
298+ if (result == ZE_RESULT_SUCCESS) {
299+ result = zelLoaderZerTracingLayerInit (this ->pTracingZerDdiTable );
300+ }
288301 #endif
289302 }
290303 // End DDI Table Inits
@@ -638,6 +651,9 @@ zelEnableTracingLayer()
638651 }
639652 if (ze_lib::context->tracingLayerEnableCounter .fetch_add (1 ) == 0 ) {
640653 ze_lib::context->zeDdiTable .exchange (ze_lib::context->pTracingZeDdiTable );
654+ if (ze_lib::context->pTracingZerDdiTable != nullptr ) {
655+ ze_lib::context->zerDdiTable .exchange (ze_lib::context->pTracingZerDdiTable );
656+ }
641657 }
642658 #endif
643659 return ZE_RESULT_SUCCESS;
@@ -659,6 +675,9 @@ zelDisableTracingLayer()
659675 }
660676 if (ze_lib::context->tracingLayerEnableCounter .fetch_sub (1 ) <= 1 ) {
661677 ze_lib::context->zeDdiTable .exchange (&ze_lib::context->initialzeDdiTable );
678+ if (ze_lib::context->pTracingZerDdiTable != nullptr ) {
679+ ze_lib::context->zerDdiTable .exchange (&ze_lib::context->initialzerDdiTable );
680+ }
662681 }
663682 #endif
664683 return ZE_RESULT_SUCCESS;
0 commit comments