@@ -375,7 +375,7 @@ static struct _ze_event_h * _get_profiling_event(
375375 }
376376
377377 e_w -> command_list = command_list ;
378- ze_event_pool_desc_t desc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC , NULL , ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP | ZE_EVENT_POOL_FLAG_HOST_VISIBLE , 1 };
378+ ze_event_pool_desc_t desc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC , NULL , ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP | ZE_EVENT_POOL_FLAG_HOST_VISIBLE | ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP , 1 };
379379 ze_result_t res = ZE_EVENT_POOL_CREATE_PTR (context , & desc , 0 , NULL , & e_w -> event_pool );
380380 if (res != ZE_RESULT_SUCCESS ) {
381381 THAPI_DBGLOG ("zeEventPoolCreate failed with %d, for command list: %p, context: %p" , res , command_list , context );
@@ -399,6 +399,7 @@ static struct _ze_event_h * _get_profiling_event(
399399}
400400
401401static void _profile_event_results (ze_event_handle_t event );
402+ static void _profile_event_results_v2 (ze_event_handle_t event , ze_command_list_handle_t );
402403
403404static inline void _on_created_event (ze_event_handle_t event ) {
404405#ifdef THAPI_DEBUG
@@ -441,8 +442,10 @@ static inline void _on_destroy_event(ze_event_handle_t event) {
441442 return ;
442443 }
443444
444- if (!(ze_event -> flags & _ZE_PROFILED ))
445+ if (!(ze_event -> flags & _ZE_PROFILED )) {
445446 _profile_event_results (event );
447+ _profile_event_results_v2 (event , ze_event -> command_list );
448+ }
446449 PUT_ZE_EVENT_WRAPPER (ze_event );
447450}
448451
@@ -472,8 +475,10 @@ static inline void _on_reset_event(ze_event_handle_t event) {
472475 return ;
473476 }
474477
475- if (!(ze_event -> flags & _ZE_PROFILED ))
478+ if (!(ze_event -> flags & _ZE_PROFILED )) {
476479 _profile_event_results (event );
480+ _profile_event_results_v2 (event , ze_event -> command_list );
481+ }
477482
478483 if (!(ze_event -> flags & _ZE_IMMEDIATE_CMD ))
479484 ADD_ZE_EVENT (ze_event );
@@ -505,6 +510,9 @@ static void _profile_event_results(ze_event_handle_t event) {
505510 if (tracepoint_enabled (lttng_ust_ze_profiling , event_profiling_results )) {
506511 status = ZE_EVENT_QUERY_STATUS_PTR (event );
507512 timestamp_status = ZE_EVENT_QUERY_KERNEL_TIMESTAMP_PTR (event , & res );
513+ printf ("zeEventQueryKernelTimestamp | Start %ld | End %ld \n" ,
514+ res .global .kernelStart ,
515+ res .global .kernelEnd );
508516 do_tracepoint (lttng_ust_ze_profiling , event_profiling_results ,
509517 event , status , timestamp_status ,
510518 res .global .kernelStart ,
@@ -513,6 +521,42 @@ static void _profile_event_results(ze_event_handle_t event) {
513521 res .context .kernelEnd );
514522 }
515523}
524+ static void _profile_event_results_v2 (ze_event_handle_t event , ze_command_list_handle_t command_list ) {
525+
526+ ze_result_t status = ZE_EVENT_QUERY_STATUS_PTR (event );
527+
528+ /* Find Device */
529+ ze_device_handle_t device ;
530+ ZE_COMMAND_LIST_GET_DEVICE_HANDLE_PTR (command_list , & device );
531+
532+ // Qurery Timestamp. We should avoid malloc
533+ uint32_t pCount = 0 ;
534+ ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PTR (event , device , & pCount , NULL );
535+
536+ ze_kernel_timestamp_result_t * kernelTimestamps =
537+ malloc (pCount * sizeof (ze_kernel_timestamp_result_t ));
538+ ze_synchronized_timestamp_result_ext_t * synchronizedTimestamps =
539+ malloc (pCount * sizeof (ze_synchronized_timestamp_result_ext_t ));
540+ ze_event_query_kernel_timestamps_results_ext_properties_t resultsProps ;
541+
542+ resultsProps .stype = ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES ;
543+ resultsProps .pNext = NULL ;
544+ resultsProps .pKernelTimestampsBuffer = kernelTimestamps ;
545+ resultsProps .pSynchronizedTimestampsBuffer = synchronizedTimestamps ;
546+ // Query the event timestamps
547+ ze_result_t timestamps_status = ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PTR (event , device , & pCount , & resultsProps );
548+ // Will do lttng static array. of size pCount and type synchronizedTimestamps
549+ for (uint32_t i = 0 ; i < pCount ; i ++ ) {
550+ printf ("zeEventQueryKernelTimestampsExtSynchronizedTimestamps | Start %ld | End %ld \n" ,
551+ synchronizedTimestamps [i ].global .kernelStart ,
552+ synchronizedTimestamps [i ].global .kernelEnd );
553+ printf ("zeEventQueryKernelTimestampsExtGlobalKernelKernelTimestamps | Start %ld | End %ld \n" ,
554+ kernelTimestamps [i ].global .kernelStart ,
555+ kernelTimestamps [i ].global .kernelEnd );
556+ }
557+ do_tracepoint (lttng_ust_ze_profiling , event_profiling_results_v2 ,
558+ event , status , timestamps_status , pCount , synchronizedTimestamps );
559+ }
516560
517561static void _event_cleanup () {
518562 struct _ze_event_h * ze_event = NULL ;
0 commit comments