@@ -22,6 +22,13 @@ namespace driver
2222 // ////////////////////////////////////////////////////////////////////////
2323 context_t::context_t ()
2424 {
25+ auto ddi_test_disable = getenv_string ( " ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT" );
26+ #ifndef ZEL_NULL_DRIVER_ID
27+ #define ZEL_NULL_DRIVER_ID 1
28+ #endif
29+ std::string null_driver_id_str = std::to_string (ZEL_NULL_DRIVER_ID);
30+ ddiExtensionSupported = (ddi_test_disable != null_driver_id_str && ddi_test_disable != " 3" );
31+
2532 zesDdiTable.Driver .pfnGet = [](
2633 uint32_t * pCount,
2734 ze_driver_handle_t * phDrivers )
@@ -69,15 +76,9 @@ namespace driver
6976 {
7077 auto pNext = reinterpret_cast <ze_base_properties_t *>(pDriverProperties->pNext );
7178 while (pNext) {
72- auto ddi_test_disable = getenv_string ( " ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT" );
73- #ifndef ZEL_NULL_DRIVER_ID
74- #define ZEL_NULL_DRIVER_ID 1
75- #endif
76- std::string null_driver_id_str = std::to_string (ZEL_NULL_DRIVER_ID);
77- if (pNext->stype == ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES && (ddi_test_disable != null_driver_id_str && ddi_test_disable != " 3" )) {
79+ if (pNext->stype == ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES && context.ddiExtensionSupported ) {
7880 ze_driver_ddi_handles_ext_properties_t *pDdiHandlesExtProperties = reinterpret_cast <ze_driver_ddi_handles_ext_properties_t *>(pNext);
7981 pDdiHandlesExtProperties->flags = ze_driver_ddi_handle_ext_flag_t ::ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED;
80- context.ddiExtensionRequested = true ;
8182 }
8283 pNext = reinterpret_cast <ze_base_properties_t *>(pNext->pNext );
8384 }
@@ -487,17 +488,32 @@ namespace driver
487488 {
488489 if ( nullptr != pExtensionProperties )
489490 {
490- ze_driver_extension_properties_t driverExtensionProperties = {};
491+ ze_driver_extension_properties_t tracingExtension = {};
492+ #if defined(_WIN32)
493+ strcpy_s ( tracingExtension.name , ZET_API_TRACING_EXP_NAME );
494+ #else
495+ strcpy ( tracingExtension.name , ZET_API_TRACING_EXP_NAME );
496+ #endif
497+ tracingExtension.version = ZET_API_TRACING_EXP_VERSION_1_0;
498+ pExtensionProperties[0 ] = tracingExtension;
499+
500+ ze_driver_extension_properties_t ddiHandlesExtension = {};
491501#if defined(_WIN32)
492- strcpy_s ( driverExtensionProperties .name , ZET_API_TRACING_EXP_NAME );
502+ strcpy_s ( ddiHandlesExtension .name , ZE_DRIVER_DDI_HANDLES_EXT_NAME );
493503#else
494- strcpy ( driverExtensionProperties .name , ZET_API_TRACING_EXP_NAME );
504+ strcpy ( ddiHandlesExtension .name , ZE_DRIVER_DDI_HANDLES_EXT_NAME );
495505#endif
496- driverExtensionProperties.version = ZET_API_TRACING_EXP_VERSION_1_0;
497506
498- *pExtensionProperties = driverExtensionProperties;
507+ auto ddi_version_env = getenv_string (" ZEL_TEST_DDI_HANDLES_EXT_VERSION" );
508+ if (!ddi_version_env.empty () && ddi_version_env == " 1_0" ) {
509+ ddiHandlesExtension.version = ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_0;
510+ } else {
511+ ddiHandlesExtension.version = ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_1;
512+ }
513+
514+ pExtensionProperties[1 ] = ddiHandlesExtension;
499515 }
500- *pCount = 1 ;
516+ *pCount = 2 ;
501517
502518 return ZE_RESULT_SUCCESS;
503519 };
@@ -629,6 +645,16 @@ namespace driver
629645 pSysman.Driver = &zesDdiTable.Driver ;
630646 pSysman.isValidFlag = 1 ;
631647 pSysman.version = ZE_API_VERSION_CURRENT;
648+
649+ static zer_global_dditable_t runtimeDdiTable;
650+ runtimeDdiTable.pfnGetLastErrorDescription = driver::zerGetLastErrorDescription;
651+ runtimeDdiTable.pfnTranslateDeviceHandleToIdentifier = driver::zerTranslateDeviceHandleToIdentifier;
652+ runtimeDdiTable.pfnTranslateIdentifierToDeviceHandle = driver::zerTranslateIdentifierToDeviceHandle;
653+ runtimeDdiTable.pfnGetDefaultContext = driver::zerGetDefaultContext;
654+
655+ pRuntime.Global = &runtimeDdiTable;
656+ pRuntime.isValidFlag = 1 ;
657+ pRuntime.version = ZE_API_VERSION_CURRENT;
632658 }
633659
634660 char *context_t ::setenv_var_with_driver_id(const std::string &key, uint32_t driverId)
0 commit comments