diff --git a/.github/workflows/build-quick-static.yml b/.github/workflows/build-quick-static.yml index 85f0302b..0634a74d 100644 --- a/.github/workflows/build-quick-static.yml +++ b/.github/workflows/build-quick-static.yml @@ -42,7 +42,7 @@ jobs: - env: ZEL_LIBRARY_PATH: '${{ github.workspace }}/dynamic_build/lib' working-directory: build - run: ls $ZEL_LIBRARY_PATH;ZE_ENABLE_LOADER_DEBUG_TRACE=1 ctest -V + run: ls $ZEL_LIBRARY_PATH;ctest -V build-windows: if: github.repository_owner == 'oneapi-src' @@ -56,7 +56,6 @@ jobs: cmake -D BUILD_L0_LOADER_TESTS=1 -D BUILD_STATIC=1 .. cmake --build . --config Release - env: - ZE_ENABLE_LOADER_DEBUG_TRACE: '1' ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin/Release' working-directory: build run: ctest -C Release -V diff --git a/.github/workflows/build-quick.yml b/.github/workflows/build-quick.yml index fbdb2c02..a0a57843 100644 --- a/.github/workflows/build-quick.yml +++ b/.github/workflows/build-quick.yml @@ -26,7 +26,6 @@ jobs: .. make -j$(nproc) - env: - ZE_ENABLE_LOADER_DEBUG_TRACE: '1' ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/lib' working-directory: build run: ctest -V @@ -43,7 +42,6 @@ jobs: cmake -D BUILD_L0_LOADER_TESTS=1 .. cmake --build . --config Release - env: - ZE_ENABLE_LOADER_DEBUG_TRACE: '1' ZEL_LIBRARY_PATH: '${{ github.workspace }}/build/bin/Release' working-directory: build run: ctest -C Release -V diff --git a/CMakeLists.txt b/CMakeLists.txt index b94a524c..2b397c98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2024 Intel Corporation +# Copyright (C) 2020-2025 Intel Corporation # SPDX-License-Identifier: MIT cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) @@ -13,7 +13,7 @@ if(MSVC AND (MSVC_VERSION LESS 1900)) endif() # This project follows semantic versioning (https://semver.org/) -project(level-zero VERSION 1.22.5) +project(level-zero VERSION 1.23.0) include(GNUInstallDirs) diff --git a/PRODUCT_GUID.txt b/PRODUCT_GUID.txt index 42093cdd..82243d87 100644 --- a/PRODUCT_GUID.txt +++ b/PRODUCT_GUID.txt @@ -1,2 +1,2 @@ -1.22.5 -4810dc63-268f-4abf-b3fe-a5f98334e3d9 \ No newline at end of file +1.23.0 +146652e2-0b5a-4461-b176-800135676a46 diff --git a/samples/zello_world/zello_world.cpp b/samples/zello_world/zello_world.cpp index 2facbd66..b45ce7b4 100644 --- a/samples/zello_world/zello_world.cpp +++ b/samples/zello_world/zello_world.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -82,6 +82,8 @@ int main( int argc, char *argv[] ) ze_device_handle_t pDevice = nullptr; uint32_t driverCount = 0; zel_tracer_handle_t tracer = nullptr; + std::vector drivers; + std::vector devices_per_driver; if( init_ze(legacy_init, driverCount, driverTypeDesc) ) { @@ -106,7 +108,6 @@ int main( int argc, char *argv[] ) } } - std::vector drivers; if (legacy_init) { status = zeDriverGet(&driverCount, nullptr); if(status != ZE_RESULT_SUCCESS) { @@ -129,96 +130,106 @@ int main( int argc, char *argv[] ) } } - for( uint32_t driver = 0; driver < driverCount; ++driver ) + for( size_t driver = 0; driver < drivers.size(); ++driver ) { + std::cout << "Driver # " << driver << "\n"; pDriver = drivers[driver]; pDevice = findDevice( pDriver, type ); - if( pDevice ) - { - break; + if (pDevice) { + devices_per_driver.push_back(pDevice); + } else { + devices_per_driver.push_back(nullptr); } } } - if( !pDevice ) + if( devices_per_driver.empty() || drivers.empty() ) { std::cout << "Did NOT find matching " << to_string(type) <<" device!" << "\n"; return -1; } + for (size_t driver_idx = 0; driver_idx < drivers.size(); ++driver_idx) { + if (driver_idx >= devices_per_driver.size() || devices_per_driver[driver_idx] == nullptr) { + std::cout << "No valid device found for Driver #" << driver_idx << std::endl; + continue; + } + pDriver = drivers[driver_idx]; + pDevice = devices_per_driver[driver_idx]; + std::cout << "Executing on Driver #" << driver_idx << ", Device #" << 0 << std::endl; + // Create the context + ze_context_handle_t context; + ze_context_desc_t context_desc = {}; + context_desc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC; + status = zeContextCreate(pDriver, &context_desc, &context); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zeContextCreate Failed with return code: " << to_string(status) << std::endl; + continue; + } - // Create the context - ze_context_handle_t context; - ze_context_desc_t context_desc = {}; - context_desc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC; - status = zeContextCreate(pDriver, &context_desc, &context); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zeContextCreate Failed with return code: " << to_string(status) << std::endl; - exit(1); - } + // Create an immediate command list for direct submission + ze_command_queue_desc_t altdesc = {}; + altdesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC; + ze_command_list_handle_t command_list = {}; + status = zeCommandListCreateImmediate(context, pDevice, &altdesc, &command_list); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zeCommandListCreateImmediate Failed with return code: " << to_string(status) << std::endl; + continue; + } - // Create an immediate command list for direct submission - ze_command_queue_desc_t altdesc = {}; - altdesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC; - ze_command_list_handle_t command_list = {}; - status = zeCommandListCreateImmediate(context, pDevice, &altdesc, &command_list); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zeCommandListCreateImmediate Failed with return code: " << to_string(status) << std::endl; - exit(1); - } + // Create an event to be signaled by the device + ze_event_pool_desc_t ep_desc = {}; + ep_desc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC; + ep_desc.count = 1; + ep_desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; + ze_event_desc_t ev_desc = {}; + ev_desc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC; + ev_desc.signal = ZE_EVENT_SCOPE_FLAG_HOST; + ev_desc.wait = ZE_EVENT_SCOPE_FLAG_HOST; + ze_event_handle_t event; + ze_event_pool_handle_t event_pool; + + status = zeEventPoolCreate(context, &ep_desc, 1, &pDevice, &event_pool); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zeEventPoolCreate Failed with return code: " << to_string(status) << std::endl; + continue; + } - // Create an event to be signaled by the device - ze_event_pool_desc_t ep_desc = {}; - ep_desc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC; - ep_desc.count = 1; - ep_desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; - ze_event_desc_t ev_desc = {}; - ev_desc.stype = ZE_STRUCTURE_TYPE_EVENT_DESC; - ev_desc.signal = ZE_EVENT_SCOPE_FLAG_HOST; - ev_desc.wait = ZE_EVENT_SCOPE_FLAG_HOST; - ze_event_handle_t event; - ze_event_pool_handle_t event_pool; - - status = zeEventPoolCreate(context, &ep_desc, 1, &pDevice, &event_pool); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zeEventPoolCreate Failed with return code: " << to_string(status) << std::endl; - exit(1); - } + status = zeEventCreate(event_pool, &ev_desc, &event); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zeEventCreate Failed with return code: " << to_string(status) << std::endl; + continue; + } - status = zeEventCreate(event_pool, &ev_desc, &event); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zeEventCreate Failed with return code: " << to_string(status) << std::endl; - exit(1); - } + // signal the event from the device and wait for completion + zeCommandListAppendSignalEvent(command_list, event); + zeEventHostSynchronize(event, UINT64_MAX ); + std::cout << "Congratulations, Executing on Driver #" << driver_idx << ", Device #" << 0 << " completed execution!" << std::endl; - // signal the event from the device and wait for completion - zeCommandListAppendSignalEvent(command_list, event); - zeEventHostSynchronize(event, UINT64_MAX ); - std::cout << "Congratulations, the device completed execution!\n"; - - if (!zelCheckIsLoaderInTearDown()) - zeContextDestroy(context); - if (!zelCheckIsLoaderInTearDown()) - zeCommandListDestroy(command_list); - if (!zelCheckIsLoaderInTearDown()) - zeEventDestroy(event); - if (!zelCheckIsLoaderInTearDown()) - zeEventPoolDestroy(event_pool); - - if (tracing_enabled) { - status = zelTracerDestroy(tracer); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zelTracerDestroy Failed with return code: " << to_string(status) << std::endl; - exit(1); + if (!zelCheckIsLoaderInTearDown()) + zeContextDestroy(context); + if (!zelCheckIsLoaderInTearDown()) + zeCommandListDestroy(command_list); + if (!zelCheckIsLoaderInTearDown()) + zeEventDestroy(event); + if (!zelCheckIsLoaderInTearDown()) + zeEventPoolDestroy(event_pool); + + if (tracing_enabled) { + status = zelTracerDestroy(tracer); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zelTracerDestroy Failed with return code: " << to_string(status) << std::endl; + exit(1); + } } - } - if (tracing_runtime_enabled) { - std::cout << "Disable Tracing Layer after init" << std::endl; - status = zelDisableTracingLayer(); - if(status != ZE_RESULT_SUCCESS) { - std::cout << "zelDisableTracingLayer Failed with return code: " << to_string(status) << std::endl; - exit(1); + if (tracing_runtime_enabled) { + std::cout << "Disable Tracing Layer after init" << std::endl; + status = zelDisableTracingLayer(); + if(status != ZE_RESULT_SUCCESS) { + std::cout << "zelDisableTracingLayer Failed with return code: " << to_string(status) << std::endl; + exit(1); + } } } diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 6ef50434..7646c59a 100644 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2019-2021 Intel Corporation + Copyright (C) 2019-2025 Intel Corporation SPDX-License-Identifier: MIT @@ -141,6 +141,23 @@ def _mako_loader_cpp(path, namespace, tags, version, specs, meta): filename = "%s.cpp"%(name) fout = os.path.join(path, filename) + print("Generating %s..."%fout) + loc += util.makoWrite( + fin, fout, + name=name, + ver=version, + namespace=namespace, + tags=tags, + specs=specs, + meta=meta) + + template = "ldrddi_driver_ddi.cpp.mako" + fin = os.path.join(templates_dir, template) + + name = "%s_ldrddi_driver_ddi"%(namespace) + filename = "%s.cpp"%(name) + fout = os.path.join(path, filename) + print("Generating %s..."%fout) loc += util.makoWrite( fin, fout, diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index 4cf99644..6acf027b 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -1,5 +1,5 @@ """ - Copyright (C) 2019-2021 Intel Corporation + Copyright (C) 2019-2025 Intel Corporation SPDX-License-Identifier: MIT @@ -1734,36 +1734,13 @@ def get_version(obj): if obj_traits.is_function(obj): ret_version = "ZE_API_VERSION_FORCE_UINT32" version = obj.get('version') - if version == "1.0": - ret_version = "ZE_API_VERSION_1_0" - if version == "1.1": - ret_version = "ZE_API_VERSION_1_1" - if version == "1.2": - ret_version = "ZE_API_VERSION_1_2" - if version == "1.3": - ret_version = "ZE_API_VERSION_1_3" - if version == "1.4": - ret_version = "ZE_API_VERSION_1_4" - if version == "1.5": - ret_version = "ZE_API_VERSION_1_5" - if version == "1.6": - ret_version = "ZE_API_VERSION_1_6" - if version == "1.7": - ret_version = "ZE_API_VERSION_1_7" - if version == "1.8": - ret_version = "ZE_API_VERSION_1_8" - if version == "1.9": - ret_version = "ZE_API_VERSION_1_9" - if version == "1.10": - ret_version = "ZE_API_VERSION_1_10" - if version == "1.11": - ret_version = "ZE_API_VERSION_1_11" - if version == "1.12": - ret_version = "ZE_API_VERSION_1_12" - if version == "1.13": - ret_version = "ZE_API_VERSION_1_13" - if (ret_version == "ZE_API_VERSION_FORCE_UINT32"): - ret_version = "ZE_API_VERSION_1_0" + if version is not None and version.startswith("1."): + try: + major, minor = version.split(".") + ret_version = f"ZE_API_VERSION_{major}_{minor}" + except Exception: + pass + assert(ret_version != "ZE_API_VERSION_FORCE_UINT32") return ret_version """ diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 24f6ec1c..12141e6f 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -9,7 +9,7 @@ from templates import helper as th X=x.upper() %>/* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,6 +18,8 @@ from templates import helper as th */ #include "${x}_loader_internal.h" +using namespace loader_driver_ddi; + namespace loader { %for obj in th.extract_objs(specs, r"function"): @@ -164,8 +166,28 @@ namespace loader { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { uint32_t driver_index = total_driver_handle_count + i; - ${obj['params'][1]['name']}[ driver_index ] = reinterpret_cast<${n}_driver_handle_t>( - context->${n}_driver_factory.getInstance( ${obj['params'][1]['name']}[ driver_index ], &drv.dditable ) ); + if (drv.driverDDIHandleSupportQueried == false) { + drv.properties = {}; + drv.properties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; + drv.properties.pNext = nullptr; + ze_driver_properties_t driverProperties = {}; + driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; + driverProperties.pNext = nullptr; + driverProperties.pNext = &drv.properties; + ze_result_t res = drv.dditable.ze.Driver.pfnGetProperties(${obj['params'][1]['name']}[ driver_index ], &driverProperties); + if (res != ZE_RESULT_SUCCESS) { + if (loader::context->debugTraceEnabled) { + std::string message = drv.name + " failed zeDriverGetProperties query, returned "; + loader::context->debug_trace_message(message, loader::to_string(res)); + } + return res; + } + drv.driverDDIHandleSupportQueried = true; + } + if (!(drv.properties.flags & ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED) || !loader::context->driverDDIPathDefault) { + ${obj['params'][1]['name']}[ driver_index ] = reinterpret_cast<${n}_driver_handle_t>( + context->${n}_driver_factory.getInstance( ${obj['params'][1]['name']}[ driver_index ], &drv.dditable ) ); + } } } catch( std::bad_alloc& ) @@ -354,6 +376,40 @@ namespace loader extern "C" { #endif +%for tbl in th.get_pfntables(specs, meta, n, tags): +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for ${tbl['name']} table +__${x}dlllocal void ${X}_APICALL +${tbl['export']['name']}Legacy() +{ + // return pointers to the Loader's Functions. + %for obj in tbl['functions']: + %if 'condition' in obj: +#if ${th.subt(n, tags, obj['condition'])} + %endif + %if namespace == "ze": + loader::loaderDispatch->pCore->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader::${th.make_func_name(n, tags, obj)}; + %elif namespace == "zet": + loader::loaderDispatch->pTools->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader::${th.make_func_name(n, tags, obj)}; + %elif namespace == "zes": + loader::loaderDispatch->pSysman->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader::${th.make_func_name(n, tags, obj)}; + %endif + %if 'condition' in obj: +#else + %if namespace == "ze": + loader::loaderDispatch->pCore->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = nullptr; + %elif namespace == "zet": + loader::loaderDispatch->pTools->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = nullptr; + %elif namespace == "zes": + loader::loaderDispatch->pSysman->${tbl['name']}->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = nullptr; + %endif +#endif + %endif + %endfor +} + +%endfor + %for tbl in th.get_pfntables(specs, meta, n, tags): /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's ${tbl['name']} table @@ -446,12 +502,27 @@ ${tbl['export']['name']}( %endif { // return pointers to loader's DDIs + %if namespace == "ze": + loader::loaderDispatch->pCore->${tbl['name']} = new ${tbl['type']}; + %elif namespace == "zet": + loader::loaderDispatch->pTools->${tbl['name']} = new ${tbl['type']}; + %elif namespace == "zes": + loader::loaderDispatch->pSysman->${tbl['name']} = new ${tbl['type']}; + %endif %for obj in tbl['functions']: if (version >= ${th.get_version(obj)}) { %if 'condition' in obj: #if ${th.subt(n, tags, obj['condition'])} %endif + %if not (re.match(r"Init", obj['name']) or re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)) or re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj))): + if (loader::context->driverDDIPathDefault) { + pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader_driver_ddi::${th.make_func_name(n, tags, obj)}; + } else { pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader::${th.make_func_name(n, tags, obj)}; + } + %else: + pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = loader::${th.make_func_name(n, tags, obj)}; + %endif %if 'condition' in obj: #else pDdiTable->${th.append_ws(th.make_pfn_name(n, tags, obj), 43)} = nullptr; @@ -459,6 +530,7 @@ ${tbl['export']['name']}( %endif } %endfor + ${tbl['export']['name']}Legacy(); } else { @@ -506,4 +578,4 @@ ${tbl['export']['name']}( #if defined(__cplusplus) }; -#endif +#endif \ No newline at end of file diff --git a/scripts/templates/ldrddi.h.mako b/scripts/templates/ldrddi.h.mako index d3fc5aac..fa18990f 100644 --- a/scripts/templates/ldrddi.h.mako +++ b/scripts/templates/ldrddi.h.mako @@ -9,7 +9,7 @@ from templates import helper as th X=x.upper() %>/* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,3 +33,32 @@ namespace loader %endif %endfor } + +namespace loader_driver_ddi +{ + __${x}dlllocal void ${X}_APICALL + ${n}DestroyDDiDriverTables(${n}_dditable_driver_t* pDdiTable); + %for obj in th.extract_objs(specs, r"function"): + %if not (re.match(r"Init", obj['name']) or re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)) or re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj))): + __${x}dlllocal ${x}_result_t ${X}_APICALL + ${th.make_func_name(n, tags, obj)}( + %for line in th.make_param_lines(n, tags, obj): + ${line} + %endfor + ); + %endif + %endfor +} + +#if defined(__cplusplus) +extern "C" { +#endif + +%for tbl in th.get_pfntables(specs, meta, n, tags): +__${x}dlllocal void ${X}_APICALL +${tbl['export']['name']}Legacy(); +%endfor + +#if defined(__cplusplus) +}; +#endif diff --git a/scripts/templates/ldrddi_driver_ddi.cpp.mako b/scripts/templates/ldrddi_driver_ddi.cpp.mako new file mode 100644 index 00000000..b279a635 --- /dev/null +++ b/scripts/templates/ldrddi_driver_ddi.cpp.mako @@ -0,0 +1,96 @@ +<%! +import re +from templates import helper as th +%><% + n=namespace + N=n.upper() + + x=tags['$x'] + X=x.upper() +%>/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ${name}.cpp + * + */ +#include "${x}_loader_internal.h" + +namespace loader_driver_ddi +{ + %for obj in th.extract_objs(specs, r"function"): + %if not (re.match(r"Init", obj['name']) or re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)) or re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj))): + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for ${th.make_func_name(n, tags, obj)} + %if 'condition' in obj: + #if ${th.subt(n, tags, obj['condition'])} + %endif + __${x}dlllocal ${x}_result_t ${X}_APICALL + ${th.make_func_name(n, tags, obj)}( + %for line in th.make_param_lines(n, tags, obj): + ${line} + %endfor + ) + { + ${x}_result_t result = ${X}_RESULT_SUCCESS;<% + add_local = False + arrays_to_delete = [] + %> + + %for i, item in enumerate(th.get_loader_prologue(n, tags, obj, meta)): + %if 0 == i: + // extract handle's function pointer table + %if 'range' in item: + %if namespace == "ze": + auto dditable = reinterpret_cast( ${item['name']}[ 0 ] )->pCore; + %elif namespace == "zet": + auto dditable = reinterpret_cast( ${item['name']}[ 0 ] )->pTools; + %elif namespace == "zes": + auto dditable = reinterpret_cast( ${item['name']}[ 0 ] )->pSysman; + %endif + %else: + %if namespace == "ze": + auto dditable = reinterpret_cast( ${item['name']} )->pCore; + %elif namespace == "zet": + auto dditable = reinterpret_cast( ${item['name']} )->pTools; + %elif namespace == "zes": + auto dditable = reinterpret_cast( ${item['name']} )->pSysman; + %endif + %endif + if (dditable->isValidFlag == 0) + return ${X}_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ${th.get_version(obj)}) { + return ${X}_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto ${th.make_pfn_name(n, tags, obj)} = dditable->${th.get_table_name(n, tags, obj)}->${th.make_pfn_name(n, tags, obj)}; + if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) + return ${X}_RESULT_ERROR_UNINITIALIZED; + %endif + %endfor + // forward to device-driver + result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); + return result; + } + %if 'condition' in obj: + #endif // ${th.subt(n, tags, obj['condition'])} + %endif + + %endif + %endfor + + /////////////////////////////////////////////////////////////////////////////// + /// @brief function for removing the ddi driver tables for ${n} + __${x}dlllocal void ${X}_APICALL + ${n}DestroyDDiDriverTables(${n}_dditable_driver_t* pDdiTable) + { + // Delete ddi tables +%for tbl in th.get_pfntables(specs, meta, n, tags): + delete pDdiTable->${tbl['name']}; +%endfor + delete pDdiTable; + } + +} // namespace loader_driver_ddi \ No newline at end of file diff --git a/scripts/templates/ze_loader_internal.h.mako b/scripts/templates/ze_loader_internal.h.mako index 220aea50..0f96fbee 100644 --- a/scripts/templates/ze_loader_internal.h.mako +++ b/scripts/templates/ze_loader_internal.h.mako @@ -21,9 +21,7 @@ from templates import helper as th #include #include -#include "ze_ddi.h" -#include "zet_ddi.h" -#include "zes_ddi.h" +#include "ze_ddi_common.h" #include "ze_util.h" #include "ze_object.h" @@ -63,9 +61,10 @@ namespace loader std::string name; bool driverInuse = false; zel_driver_type_t driverType = ZEL_DRIVER_TYPE_FORCE_UINT32; - ze_driver_properties_t properties; + ze_driver_ddi_handles_ext_properties_t properties; bool pciOrderingRequested = false; bool legacyInitAttempted = false; + bool driverDDIHandleSupportQueried = false; }; using driver_vector_t = std::vector< driver_t >; @@ -118,6 +117,7 @@ namespace loader ~context_t(); bool intercept_enabled = false; bool debugTraceEnabled = false; + bool driverDDIPathDefault = false; bool tracingLayerEnabled = false; std::once_flag coreDriverSortOnce; std::once_flag sysmanDriverSortOnce; @@ -128,5 +128,9 @@ namespace loader std::shared_ptr zel_logger; }; + extern ze_handle_t* loaderDispatch; + extern ze_dditable_t* loaderZeDdiTable; + extern zet_dditable_t* loaderZetDdiTable; + extern zes_dditable_t* loaderZesDdiTable; extern context_t *context; } diff --git a/source/drivers/null/ze_null.cpp b/source/drivers/null/ze_null.cpp index 64e8e196..c0ee9748 100644 --- a/source/drivers/null/ze_null.cpp +++ b/source/drivers/null/ze_null.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,6 +14,9 @@ namespace driver { ////////////////////////////////////////////////////////////////////////// context_t context; + ze_dditable_driver_t pCore; + zet_dditable_driver_t pTools; + zes_dditable_driver_t pSysman; ////////////////////////////////////////////////////////////////////////// context_t::context_t() @@ -63,16 +66,24 @@ namespace driver ze_driver_handle_t, ze_driver_properties_t* pDriverProperties ) { - ze_driver_properties_t driverProperties = {}; - driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; - //driverProperties.uuid - driverProperties.driverVersion = 0; + auto pNext = reinterpret_cast(pDriverProperties->pNext); + while (pNext) { + auto ddi_test_disable = getenv_string( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT" ); + #ifndef ZEL_NULL_DRIVER_ID + #define ZEL_NULL_DRIVER_ID 1 + #endif + std::string null_driver_id_str = std::to_string(ZEL_NULL_DRIVER_ID); + if (pNext->stype == ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES && (ddi_test_disable != null_driver_id_str && ddi_test_disable != "3")) { + ze_driver_ddi_handles_ext_properties_t *pDdiHandlesExtProperties = reinterpret_cast(pNext); + pDdiHandlesExtProperties->flags = ze_driver_ddi_handle_ext_flag_t::ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED; + context.ddiExtensionRequested = true; + } + pNext = reinterpret_cast(pNext->pNext); + } + pDriverProperties->driverVersion = 0; - *pDriverProperties = driverProperties; return ZE_RESULT_SUCCESS; }; - - //pfnGetIPCProperties ////////////////////////////////////////////////////////////////////////// zeDdiTable.Mem.pfnAllocShared = []( @@ -122,14 +133,227 @@ namespace driver return ZE_RESULT_SUCCESS; }; - //pfnGetMemProperties - //pfnGetMemAddressRange - //pfnGetMemIpcHandle - //pfnOpenMemIpcHandle - //pfnCloseMemIpcHandle + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.EventPool.pfnCreate = []( + ze_context_handle_t, + const ze_event_pool_desc_t* desc, + uint32_t, + ze_device_handle_t*, + ze_event_pool_handle_t* phEventPool ) + { + *phEventPool = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Event.pfnCreate = []( + ze_event_pool_handle_t, + const ze_event_desc_t* desc, + ze_event_handle_t* phEvent ) + { + *phEvent = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.CommandList.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + const ze_command_list_desc_t* desc, + ze_command_list_handle_t* phCommandList ) + { + *phCommandList = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.CommandQueue.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + const ze_command_queue_desc_t* desc, + ze_command_queue_handle_t* phCommandQueue ) + { + *phCommandQueue = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Context.pfnCreate = []( + ze_driver_handle_t, + const ze_context_desc_t*, + ze_context_handle_t* phContext ) + { + *phContext = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Context.pfnDestroy = []( + ze_context_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.CommandList.pfnDestroy = []( + ze_command_list_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.CommandQueue.pfnDestroy = []( + ze_command_queue_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.EventPool.pfnDestroy = []( + ze_event_pool_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Event.pfnDestroy = []( + ze_event_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Module.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + const ze_module_desc_t*, + ze_module_handle_t* phModule, + ze_module_build_log_handle_t* phModuleBuildLog ) + { + *phModule = reinterpret_cast(context.get()); + if (phModuleBuildLog) { + *phModuleBuildLog = reinterpret_cast(context.get()); + } + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Module.pfnDestroy = []( + ze_module_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.ModuleBuildLog.pfnDestroy = []( + ze_module_build_log_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.ModuleBuildLog.pfnGetString = []( + ze_module_build_log_handle_t, + size_t* pSize, + char* pBuildLog ) + { + const char* log = "Build log not available."; + *pSize = strlen(log) + 1; + if (pBuildLog) { + #if defined(_WIN32) + strncpy_s( pBuildLog, *pSize, log, *pSize ); + #else + strncpy( pBuildLog, log, *pSize ); + #endif + } + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.PhysicalMem.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + ze_physical_mem_desc_t*, + ze_physical_mem_handle_t* phPhysicalMemory ) + { + *phPhysicalMemory = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.PhysicalMem.pfnDestroy = []( ze_context_handle_t, + ze_physical_mem_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Fence.pfnCreate = []( + ze_command_queue_handle_t, + const ze_fence_desc_t*, + ze_fence_handle_t* phFence ) + { + *phFence = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; ////////////////////////////////////////////////////////////////////////// - //pfnGetSubDevices + zeDdiTable.Fence.pfnDestroy = []( + ze_fence_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Image.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + const ze_image_desc_t*, + ze_image_handle_t* phImage ) + { + *phImage = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Image.pfnDestroy = []( + ze_image_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Sampler.pfnCreate = []( + ze_context_handle_t, + ze_device_handle_t, + const ze_sampler_desc_t*, + ze_sampler_handle_t* phSampler ) + { + *phSampler = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Sampler.pfnDestroy = []( + ze_sampler_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Kernel.pfnCreate = []( + ze_module_handle_t, + const ze_kernel_desc_t*, + ze_kernel_handle_t* phKernel ) + { + *phKernel = reinterpret_cast(context.get()); + return ZE_RESULT_SUCCESS; + }; + + ////////////////////////////////////////////////////////////////////////// + zeDdiTable.Kernel.pfnDestroy = []( + ze_kernel_handle_t ) + { + return ZE_RESULT_SUCCESS; + }; ////////////////////////////////////////////////////////////////////////// zeDdiTable.Device.pfnGetProperties = []( @@ -367,6 +591,32 @@ namespace driver if( pRawData ) *pRawData = 0; return ZE_RESULT_SUCCESS; }; + pCore.Driver = &zeDdiTable.Driver; + pCore.Device = &zeDdiTable.Device; + pCore.Mem = &zeDdiTable.Mem; + pCore.CommandList = &zeDdiTable.CommandList; + pCore.CommandQueue = &zeDdiTable.CommandQueue; + pCore.Context = &zeDdiTable.Context; + pCore.Event = &zeDdiTable.Event; + pCore.EventPool = &zeDdiTable.EventPool; + pCore.Module = &zeDdiTable.Module; + pCore.ModuleBuildLog = &zeDdiTable.ModuleBuildLog; + pCore.PhysicalMem = &zeDdiTable.PhysicalMem; + pCore.Kernel = &zeDdiTable.Kernel; + pCore.Fence = &zeDdiTable.Fence; + pCore.Image = &zeDdiTable.Image; + pCore.Sampler = &zeDdiTable.Sampler; + pCore.isValidFlag = 1; + pCore.version = ZE_API_VERSION_CURRENT; + pTools.MetricGroup = &zetDdiTable.MetricGroup; + pTools.Metric = &zetDdiTable.Metric; + pTools.MetricQuery = &zetDdiTable.MetricQuery; + pTools.MetricStreamer = &zetDdiTable.MetricStreamer; + pTools.isValidFlag = 1; + pTools.version = ZE_API_VERSION_CURRENT; + pSysman.Driver = &zesDdiTable.Driver; + pSysman.isValidFlag = 1; + pSysman.version = ZE_API_VERSION_CURRENT; } } // namespace driver diff --git a/source/drivers/null/ze_null.h b/source/drivers/null/ze_null.h index bcdc9562..57c9c630 100644 --- a/source/drivers/null/ze_null.h +++ b/source/drivers/null/ze_null.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,6 +14,7 @@ #include "zet_ddi.h" #include "zes_ddi.h" #include "ze_util.h" +#include "ze_ddi_common.h" #ifndef ZEL_NULL_DRIVER_ID #define ZEL_NULL_DRIVER_ID 1 @@ -21,6 +22,16 @@ namespace driver { + extern ze_dditable_driver_t pCore; + extern zet_dditable_driver_t pTools; + extern zes_dditable_driver_t pSysman; + struct __zedlllocal BaseNullHandle : ze_handle_t { + BaseNullHandle() { + pCore = &driver::pCore; + pTools = &driver::pTools; + pSysman = &driver::pSysman; + } + }; /////////////////////////////////////////////////////////////////////////////// class __zedlllocal context_t { @@ -30,13 +41,24 @@ namespace driver ze_dditable_t zeDdiTable = {}; zet_dditable_t zetDdiTable = {}; zes_dditable_t zesDdiTable = {}; + std::vector globalBaseNullHandle; + bool ddiExtensionRequested = false; context_t(); - ~context_t() = default; + ~context_t() { + for (auto handle : globalBaseNullHandle) { + delete handle; + } + } void* get( void ) { static uint64_t count = 0x80800000; - return reinterpret_cast( ++count ); + if (ddiExtensionRequested) { + globalBaseNullHandle.push_back(new BaseNullHandle()); + return reinterpret_cast(globalBaseNullHandle.back()); + } else { + return reinterpret_cast( ++count ); + } } }; diff --git a/source/inc/ze_singleton.h b/source/inc/ze_singleton.h index 3be4a9b9..7f7d09a0 100644 --- a/source/inc/ze_singleton.h +++ b/source/inc/ze_singleton.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////// /// a abstract factory for creation of singleton objects @@ -63,6 +64,12 @@ class singleton_factory_t return iter->second.get(); } + bool hasInstance( _key_t _key ) + { + std::lock_guard lk( mut ); + return map.find( getKey( _key ) ) != map.end(); + } + ////////////////////////////////////////////////////////////////////////// /// once the key is no longer valid, release the singleton void release( _key_t _key ) diff --git a/source/loader/CMakeLists.txt b/source/loader/CMakeLists.txt index e3f8d139..b2a5ad64 100644 --- a/source/loader/CMakeLists.txt +++ b/source/loader/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2020 Intel Corporation +# Copyright (C) 2020-2025 Intel Corporation # SPDX-License-Identifier: MIT @@ -9,10 +9,13 @@ target_sources(${TARGET_LOADER_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/ze_loader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ze_loader_api.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ze_ldrddi.h + ${CMAKE_CURRENT_SOURCE_DIR}/ze_ldrddi_driver_ddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ze_ldrddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zet_ldrddi.h + ${CMAKE_CURRENT_SOURCE_DIR}/zet_ldrddi_driver_ddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zet_ldrddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zes_ldrddi.h + ${CMAKE_CURRENT_SOURCE_DIR}/zes_ldrddi_driver_ddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zes_ldrddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zel_tracing_ldrddi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/driver_discovery.h diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 88f30e4d..882628fe 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,8 @@ */ #include "ze_loader_internal.h" +using namespace loader_driver_ddi; + namespace loader { /////////////////////////////////////////////////////////////////////////////// @@ -99,8 +101,28 @@ namespace loader { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { uint32_t driver_index = total_driver_handle_count + i; - phDrivers[ driver_index ] = reinterpret_cast( - context->ze_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + if (drv.driverDDIHandleSupportQueried == false) { + drv.properties = {}; + drv.properties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; + drv.properties.pNext = nullptr; + ze_driver_properties_t driverProperties = {}; + driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; + driverProperties.pNext = nullptr; + driverProperties.pNext = &drv.properties; + ze_result_t res = drv.dditable.ze.Driver.pfnGetProperties(phDrivers[ driver_index ], &driverProperties); + if (res != ZE_RESULT_SUCCESS) { + if (loader::context->debugTraceEnabled) { + std::string message = drv.name + " failed zeDriverGetProperties query, returned "; + loader::context->debug_trace_message(message, loader::to_string(res)); + } + return res; + } + drv.driverDDIHandleSupportQueried = true; + } + if (!(drv.properties.flags & ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED) || !loader::context->driverDDIPathDefault) { + phDrivers[ driver_index ] = reinterpret_cast( + context->ze_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + } } } catch( std::bad_alloc& ) @@ -187,8 +209,28 @@ namespace loader { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { uint32_t driver_index = total_driver_handle_count + i; - phDrivers[ driver_index ] = reinterpret_cast( - context->ze_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + if (drv.driverDDIHandleSupportQueried == false) { + drv.properties = {}; + drv.properties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; + drv.properties.pNext = nullptr; + ze_driver_properties_t driverProperties = {}; + driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; + driverProperties.pNext = nullptr; + driverProperties.pNext = &drv.properties; + ze_result_t res = drv.dditable.ze.Driver.pfnGetProperties(phDrivers[ driver_index ], &driverProperties); + if (res != ZE_RESULT_SUCCESS) { + if (loader::context->debugTraceEnabled) { + std::string message = drv.name + " failed zeDriverGetProperties query, returned "; + loader::context->debug_trace_message(message, loader::to_string(res)); + } + return res; + } + drv.driverDDIHandleSupportQueried = true; + } + if (!(drv.properties.flags & ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED) || !loader::context->driverDDIPathDefault) { + phDrivers[ driver_index ] = reinterpret_cast( + context->ze_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + } } } catch( std::bad_alloc& ) @@ -6877,6 +6919,450 @@ namespace loader extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Global table +__zedlllocal void ZE_APICALL +zeGetGlobalProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Global->pfnInit = loader::zeInit; + loader::loaderDispatch->pCore->Global->pfnInitDrivers = loader::zeInitDrivers; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for RTASBuilder table +__zedlllocal void ZE_APICALL +zeGetRTASBuilderProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->RTASBuilder->pfnCreateExt = loader::zeRTASBuilderCreateExt; + loader::loaderDispatch->pCore->RTASBuilder->pfnGetBuildPropertiesExt = loader::zeRTASBuilderGetBuildPropertiesExt; + loader::loaderDispatch->pCore->RTASBuilder->pfnBuildExt = loader::zeRTASBuilderBuildExt; + loader::loaderDispatch->pCore->RTASBuilder->pfnCommandListAppendCopyExt = loader::zeRTASBuilderCommandListAppendCopyExt; + loader::loaderDispatch->pCore->RTASBuilder->pfnDestroyExt = loader::zeRTASBuilderDestroyExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for RTASBuilderExp table +__zedlllocal void ZE_APICALL +zeGetRTASBuilderExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->RTASBuilderExp->pfnCreateExp = loader::zeRTASBuilderCreateExp; + loader::loaderDispatch->pCore->RTASBuilderExp->pfnGetBuildPropertiesExp = loader::zeRTASBuilderGetBuildPropertiesExp; + loader::loaderDispatch->pCore->RTASBuilderExp->pfnBuildExp = loader::zeRTASBuilderBuildExp; + loader::loaderDispatch->pCore->RTASBuilderExp->pfnDestroyExp = loader::zeRTASBuilderDestroyExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for RTASParallelOperation table +__zedlllocal void ZE_APICALL +zeGetRTASParallelOperationProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->RTASParallelOperation->pfnCreateExt = loader::zeRTASParallelOperationCreateExt; + loader::loaderDispatch->pCore->RTASParallelOperation->pfnGetPropertiesExt = loader::zeRTASParallelOperationGetPropertiesExt; + loader::loaderDispatch->pCore->RTASParallelOperation->pfnJoinExt = loader::zeRTASParallelOperationJoinExt; + loader::loaderDispatch->pCore->RTASParallelOperation->pfnDestroyExt = loader::zeRTASParallelOperationDestroyExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for RTASParallelOperationExp table +__zedlllocal void ZE_APICALL +zeGetRTASParallelOperationExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->RTASParallelOperationExp->pfnCreateExp = loader::zeRTASParallelOperationCreateExp; + loader::loaderDispatch->pCore->RTASParallelOperationExp->pfnGetPropertiesExp = loader::zeRTASParallelOperationGetPropertiesExp; + loader::loaderDispatch->pCore->RTASParallelOperationExp->pfnJoinExp = loader::zeRTASParallelOperationJoinExp; + loader::loaderDispatch->pCore->RTASParallelOperationExp->pfnDestroyExp = loader::zeRTASParallelOperationDestroyExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Driver table +__zedlllocal void ZE_APICALL +zeGetDriverProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Driver->pfnGet = loader::zeDriverGet; + loader::loaderDispatch->pCore->Driver->pfnGetApiVersion = loader::zeDriverGetApiVersion; + loader::loaderDispatch->pCore->Driver->pfnGetProperties = loader::zeDriverGetProperties; + loader::loaderDispatch->pCore->Driver->pfnGetIpcProperties = loader::zeDriverGetIpcProperties; + loader::loaderDispatch->pCore->Driver->pfnGetExtensionProperties = loader::zeDriverGetExtensionProperties; + loader::loaderDispatch->pCore->Driver->pfnGetExtensionFunctionAddress = loader::zeDriverGetExtensionFunctionAddress; + loader::loaderDispatch->pCore->Driver->pfnRTASFormatCompatibilityCheckExt = loader::zeDriverRTASFormatCompatibilityCheckExt; + loader::loaderDispatch->pCore->Driver->pfnGetLastErrorDescription = loader::zeDriverGetLastErrorDescription; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for DriverExp table +__zedlllocal void ZE_APICALL +zeGetDriverExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->DriverExp->pfnRTASFormatCompatibilityCheckExp = loader::zeDriverRTASFormatCompatibilityCheckExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Device table +__zedlllocal void ZE_APICALL +zeGetDeviceProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Device->pfnGet = loader::zeDeviceGet; + loader::loaderDispatch->pCore->Device->pfnGetSubDevices = loader::zeDeviceGetSubDevices; + loader::loaderDispatch->pCore->Device->pfnGetProperties = loader::zeDeviceGetProperties; + loader::loaderDispatch->pCore->Device->pfnGetComputeProperties = loader::zeDeviceGetComputeProperties; + loader::loaderDispatch->pCore->Device->pfnGetModuleProperties = loader::zeDeviceGetModuleProperties; + loader::loaderDispatch->pCore->Device->pfnGetCommandQueueGroupProperties = loader::zeDeviceGetCommandQueueGroupProperties; + loader::loaderDispatch->pCore->Device->pfnGetMemoryProperties = loader::zeDeviceGetMemoryProperties; + loader::loaderDispatch->pCore->Device->pfnGetMemoryAccessProperties = loader::zeDeviceGetMemoryAccessProperties; + loader::loaderDispatch->pCore->Device->pfnGetCacheProperties = loader::zeDeviceGetCacheProperties; + loader::loaderDispatch->pCore->Device->pfnGetImageProperties = loader::zeDeviceGetImageProperties; + loader::loaderDispatch->pCore->Device->pfnGetExternalMemoryProperties = loader::zeDeviceGetExternalMemoryProperties; + loader::loaderDispatch->pCore->Device->pfnGetP2PProperties = loader::zeDeviceGetP2PProperties; + loader::loaderDispatch->pCore->Device->pfnCanAccessPeer = loader::zeDeviceCanAccessPeer; + loader::loaderDispatch->pCore->Device->pfnGetStatus = loader::zeDeviceGetStatus; + loader::loaderDispatch->pCore->Device->pfnGetGlobalTimestamps = loader::zeDeviceGetGlobalTimestamps; + loader::loaderDispatch->pCore->Device->pfnImportExternalSemaphoreExt = loader::zeDeviceImportExternalSemaphoreExt; + loader::loaderDispatch->pCore->Device->pfnReleaseExternalSemaphoreExt = loader::zeDeviceReleaseExternalSemaphoreExt; + loader::loaderDispatch->pCore->Device->pfnGetVectorWidthPropertiesExt = loader::zeDeviceGetVectorWidthPropertiesExt; + loader::loaderDispatch->pCore->Device->pfnReserveCacheExt = loader::zeDeviceReserveCacheExt; + loader::loaderDispatch->pCore->Device->pfnSetCacheAdviceExt = loader::zeDeviceSetCacheAdviceExt; + loader::loaderDispatch->pCore->Device->pfnPciGetPropertiesExt = loader::zeDevicePciGetPropertiesExt; + loader::loaderDispatch->pCore->Device->pfnGetRootDevice = loader::zeDeviceGetRootDevice; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for DeviceExp table +__zedlllocal void ZE_APICALL +zeGetDeviceExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->DeviceExp->pfnGetFabricVertexExp = loader::zeDeviceGetFabricVertexExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Context table +__zedlllocal void ZE_APICALL +zeGetContextProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Context->pfnCreate = loader::zeContextCreate; + loader::loaderDispatch->pCore->Context->pfnDestroy = loader::zeContextDestroy; + loader::loaderDispatch->pCore->Context->pfnGetStatus = loader::zeContextGetStatus; + loader::loaderDispatch->pCore->Context->pfnSystemBarrier = loader::zeContextSystemBarrier; + loader::loaderDispatch->pCore->Context->pfnMakeMemoryResident = loader::zeContextMakeMemoryResident; + loader::loaderDispatch->pCore->Context->pfnEvictMemory = loader::zeContextEvictMemory; + loader::loaderDispatch->pCore->Context->pfnMakeImageResident = loader::zeContextMakeImageResident; + loader::loaderDispatch->pCore->Context->pfnEvictImage = loader::zeContextEvictImage; + loader::loaderDispatch->pCore->Context->pfnCreateEx = loader::zeContextCreateEx; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for CommandQueue table +__zedlllocal void ZE_APICALL +zeGetCommandQueueProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->CommandQueue->pfnCreate = loader::zeCommandQueueCreate; + loader::loaderDispatch->pCore->CommandQueue->pfnDestroy = loader::zeCommandQueueDestroy; + loader::loaderDispatch->pCore->CommandQueue->pfnExecuteCommandLists = loader::zeCommandQueueExecuteCommandLists; + loader::loaderDispatch->pCore->CommandQueue->pfnSynchronize = loader::zeCommandQueueSynchronize; + loader::loaderDispatch->pCore->CommandQueue->pfnGetOrdinal = loader::zeCommandQueueGetOrdinal; + loader::loaderDispatch->pCore->CommandQueue->pfnGetIndex = loader::zeCommandQueueGetIndex; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for CommandList table +__zedlllocal void ZE_APICALL +zeGetCommandListProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->CommandList->pfnCreate = loader::zeCommandListCreate; + loader::loaderDispatch->pCore->CommandList->pfnCreateImmediate = loader::zeCommandListCreateImmediate; + loader::loaderDispatch->pCore->CommandList->pfnDestroy = loader::zeCommandListDestroy; + loader::loaderDispatch->pCore->CommandList->pfnClose = loader::zeCommandListClose; + loader::loaderDispatch->pCore->CommandList->pfnReset = loader::zeCommandListReset; + loader::loaderDispatch->pCore->CommandList->pfnAppendWriteGlobalTimestamp = loader::zeCommandListAppendWriteGlobalTimestamp; + loader::loaderDispatch->pCore->CommandList->pfnAppendBarrier = loader::zeCommandListAppendBarrier; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryRangesBarrier = loader::zeCommandListAppendMemoryRangesBarrier; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryCopy = loader::zeCommandListAppendMemoryCopy; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryFill = loader::zeCommandListAppendMemoryFill; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryCopyRegion = loader::zeCommandListAppendMemoryCopyRegion; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryCopyFromContext = loader::zeCommandListAppendMemoryCopyFromContext; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopy = loader::zeCommandListAppendImageCopy; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopyRegion = loader::zeCommandListAppendImageCopyRegion; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopyToMemory = loader::zeCommandListAppendImageCopyToMemory; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopyFromMemory = loader::zeCommandListAppendImageCopyFromMemory; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemoryPrefetch = loader::zeCommandListAppendMemoryPrefetch; + loader::loaderDispatch->pCore->CommandList->pfnAppendMemAdvise = loader::zeCommandListAppendMemAdvise; + loader::loaderDispatch->pCore->CommandList->pfnAppendSignalEvent = loader::zeCommandListAppendSignalEvent; + loader::loaderDispatch->pCore->CommandList->pfnAppendWaitOnEvents = loader::zeCommandListAppendWaitOnEvents; + loader::loaderDispatch->pCore->CommandList->pfnAppendEventReset = loader::zeCommandListAppendEventReset; + loader::loaderDispatch->pCore->CommandList->pfnAppendQueryKernelTimestamps = loader::zeCommandListAppendQueryKernelTimestamps; + loader::loaderDispatch->pCore->CommandList->pfnAppendLaunchKernel = loader::zeCommandListAppendLaunchKernel; + loader::loaderDispatch->pCore->CommandList->pfnAppendLaunchCooperativeKernel = loader::zeCommandListAppendLaunchCooperativeKernel; + loader::loaderDispatch->pCore->CommandList->pfnAppendLaunchKernelIndirect = loader::zeCommandListAppendLaunchKernelIndirect; + loader::loaderDispatch->pCore->CommandList->pfnAppendLaunchMultipleKernelsIndirect = loader::zeCommandListAppendLaunchMultipleKernelsIndirect; + loader::loaderDispatch->pCore->CommandList->pfnAppendSignalExternalSemaphoreExt = loader::zeCommandListAppendSignalExternalSemaphoreExt; + loader::loaderDispatch->pCore->CommandList->pfnAppendWaitExternalSemaphoreExt = loader::zeCommandListAppendWaitExternalSemaphoreExt; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopyToMemoryExt = loader::zeCommandListAppendImageCopyToMemoryExt; + loader::loaderDispatch->pCore->CommandList->pfnAppendImageCopyFromMemoryExt = loader::zeCommandListAppendImageCopyFromMemoryExt; + loader::loaderDispatch->pCore->CommandList->pfnHostSynchronize = loader::zeCommandListHostSynchronize; + loader::loaderDispatch->pCore->CommandList->pfnGetDeviceHandle = loader::zeCommandListGetDeviceHandle; + loader::loaderDispatch->pCore->CommandList->pfnGetContextHandle = loader::zeCommandListGetContextHandle; + loader::loaderDispatch->pCore->CommandList->pfnGetOrdinal = loader::zeCommandListGetOrdinal; + loader::loaderDispatch->pCore->CommandList->pfnImmediateGetIndex = loader::zeCommandListImmediateGetIndex; + loader::loaderDispatch->pCore->CommandList->pfnIsImmediate = loader::zeCommandListIsImmediate; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for CommandListExp table +__zedlllocal void ZE_APICALL +zeGetCommandListExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->CommandListExp->pfnGetNextCommandIdWithKernelsExp = loader::zeCommandListGetNextCommandIdWithKernelsExp; + loader::loaderDispatch->pCore->CommandListExp->pfnUpdateMutableCommandKernelsExp = loader::zeCommandListUpdateMutableCommandKernelsExp; + loader::loaderDispatch->pCore->CommandListExp->pfnCreateCloneExp = loader::zeCommandListCreateCloneExp; + loader::loaderDispatch->pCore->CommandListExp->pfnImmediateAppendCommandListsExp = loader::zeCommandListImmediateAppendCommandListsExp; + loader::loaderDispatch->pCore->CommandListExp->pfnGetNextCommandIdExp = loader::zeCommandListGetNextCommandIdExp; + loader::loaderDispatch->pCore->CommandListExp->pfnUpdateMutableCommandsExp = loader::zeCommandListUpdateMutableCommandsExp; + loader::loaderDispatch->pCore->CommandListExp->pfnUpdateMutableCommandSignalEventExp = loader::zeCommandListUpdateMutableCommandSignalEventExp; + loader::loaderDispatch->pCore->CommandListExp->pfnUpdateMutableCommandWaitEventsExp = loader::zeCommandListUpdateMutableCommandWaitEventsExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Event table +__zedlllocal void ZE_APICALL +zeGetEventProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Event->pfnCreate = loader::zeEventCreate; + loader::loaderDispatch->pCore->Event->pfnDestroy = loader::zeEventDestroy; + loader::loaderDispatch->pCore->Event->pfnHostSignal = loader::zeEventHostSignal; + loader::loaderDispatch->pCore->Event->pfnHostSynchronize = loader::zeEventHostSynchronize; + loader::loaderDispatch->pCore->Event->pfnQueryStatus = loader::zeEventQueryStatus; + loader::loaderDispatch->pCore->Event->pfnHostReset = loader::zeEventHostReset; + loader::loaderDispatch->pCore->Event->pfnQueryKernelTimestamp = loader::zeEventQueryKernelTimestamp; + loader::loaderDispatch->pCore->Event->pfnQueryKernelTimestampsExt = loader::zeEventQueryKernelTimestampsExt; + loader::loaderDispatch->pCore->Event->pfnGetEventPool = loader::zeEventGetEventPool; + loader::loaderDispatch->pCore->Event->pfnGetSignalScope = loader::zeEventGetSignalScope; + loader::loaderDispatch->pCore->Event->pfnGetWaitScope = loader::zeEventGetWaitScope; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for EventExp table +__zedlllocal void ZE_APICALL +zeGetEventExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->EventExp->pfnQueryTimestampsExp = loader::zeEventQueryTimestampsExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for EventPool table +__zedlllocal void ZE_APICALL +zeGetEventPoolProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->EventPool->pfnCreate = loader::zeEventPoolCreate; + loader::loaderDispatch->pCore->EventPool->pfnDestroy = loader::zeEventPoolDestroy; + loader::loaderDispatch->pCore->EventPool->pfnGetIpcHandle = loader::zeEventPoolGetIpcHandle; + loader::loaderDispatch->pCore->EventPool->pfnOpenIpcHandle = loader::zeEventPoolOpenIpcHandle; + loader::loaderDispatch->pCore->EventPool->pfnCloseIpcHandle = loader::zeEventPoolCloseIpcHandle; + loader::loaderDispatch->pCore->EventPool->pfnPutIpcHandle = loader::zeEventPoolPutIpcHandle; + loader::loaderDispatch->pCore->EventPool->pfnGetContextHandle = loader::zeEventPoolGetContextHandle; + loader::loaderDispatch->pCore->EventPool->pfnGetFlags = loader::zeEventPoolGetFlags; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Fence table +__zedlllocal void ZE_APICALL +zeGetFenceProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Fence->pfnCreate = loader::zeFenceCreate; + loader::loaderDispatch->pCore->Fence->pfnDestroy = loader::zeFenceDestroy; + loader::loaderDispatch->pCore->Fence->pfnHostSynchronize = loader::zeFenceHostSynchronize; + loader::loaderDispatch->pCore->Fence->pfnQueryStatus = loader::zeFenceQueryStatus; + loader::loaderDispatch->pCore->Fence->pfnReset = loader::zeFenceReset; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Image table +__zedlllocal void ZE_APICALL +zeGetImageProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Image->pfnGetProperties = loader::zeImageGetProperties; + loader::loaderDispatch->pCore->Image->pfnCreate = loader::zeImageCreate; + loader::loaderDispatch->pCore->Image->pfnDestroy = loader::zeImageDestroy; + loader::loaderDispatch->pCore->Image->pfnGetAllocPropertiesExt = loader::zeImageGetAllocPropertiesExt; + loader::loaderDispatch->pCore->Image->pfnViewCreateExt = loader::zeImageViewCreateExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for ImageExp table +__zedlllocal void ZE_APICALL +zeGetImageExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->ImageExp->pfnGetMemoryPropertiesExp = loader::zeImageGetMemoryPropertiesExp; + loader::loaderDispatch->pCore->ImageExp->pfnViewCreateExp = loader::zeImageViewCreateExp; + loader::loaderDispatch->pCore->ImageExp->pfnGetDeviceOffsetExp = loader::zeImageGetDeviceOffsetExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Kernel table +__zedlllocal void ZE_APICALL +zeGetKernelProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Kernel->pfnCreate = loader::zeKernelCreate; + loader::loaderDispatch->pCore->Kernel->pfnDestroy = loader::zeKernelDestroy; + loader::loaderDispatch->pCore->Kernel->pfnSetCacheConfig = loader::zeKernelSetCacheConfig; + loader::loaderDispatch->pCore->Kernel->pfnSetGroupSize = loader::zeKernelSetGroupSize; + loader::loaderDispatch->pCore->Kernel->pfnSuggestGroupSize = loader::zeKernelSuggestGroupSize; + loader::loaderDispatch->pCore->Kernel->pfnSuggestMaxCooperativeGroupCount = loader::zeKernelSuggestMaxCooperativeGroupCount; + loader::loaderDispatch->pCore->Kernel->pfnSetArgumentValue = loader::zeKernelSetArgumentValue; + loader::loaderDispatch->pCore->Kernel->pfnSetIndirectAccess = loader::zeKernelSetIndirectAccess; + loader::loaderDispatch->pCore->Kernel->pfnGetIndirectAccess = loader::zeKernelGetIndirectAccess; + loader::loaderDispatch->pCore->Kernel->pfnGetSourceAttributes = loader::zeKernelGetSourceAttributes; + loader::loaderDispatch->pCore->Kernel->pfnGetProperties = loader::zeKernelGetProperties; + loader::loaderDispatch->pCore->Kernel->pfnGetName = loader::zeKernelGetName; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for KernelExp table +__zedlllocal void ZE_APICALL +zeGetKernelExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->KernelExp->pfnSetGlobalOffsetExp = loader::zeKernelSetGlobalOffsetExp; + loader::loaderDispatch->pCore->KernelExp->pfnGetBinaryExp = loader::zeKernelGetBinaryExp; + loader::loaderDispatch->pCore->KernelExp->pfnSchedulingHintExp = loader::zeKernelSchedulingHintExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Mem table +__zedlllocal void ZE_APICALL +zeGetMemProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Mem->pfnAllocShared = loader::zeMemAllocShared; + loader::loaderDispatch->pCore->Mem->pfnAllocDevice = loader::zeMemAllocDevice; + loader::loaderDispatch->pCore->Mem->pfnAllocHost = loader::zeMemAllocHost; + loader::loaderDispatch->pCore->Mem->pfnFree = loader::zeMemFree; + loader::loaderDispatch->pCore->Mem->pfnGetAllocProperties = loader::zeMemGetAllocProperties; + loader::loaderDispatch->pCore->Mem->pfnGetAddressRange = loader::zeMemGetAddressRange; + loader::loaderDispatch->pCore->Mem->pfnGetIpcHandle = loader::zeMemGetIpcHandle; + loader::loaderDispatch->pCore->Mem->pfnOpenIpcHandle = loader::zeMemOpenIpcHandle; + loader::loaderDispatch->pCore->Mem->pfnCloseIpcHandle = loader::zeMemCloseIpcHandle; + loader::loaderDispatch->pCore->Mem->pfnFreeExt = loader::zeMemFreeExt; + loader::loaderDispatch->pCore->Mem->pfnPutIpcHandle = loader::zeMemPutIpcHandle; + loader::loaderDispatch->pCore->Mem->pfnGetPitchFor2dImage = loader::zeMemGetPitchFor2dImage; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MemExp table +__zedlllocal void ZE_APICALL +zeGetMemExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->MemExp->pfnGetIpcHandleFromFileDescriptorExp = loader::zeMemGetIpcHandleFromFileDescriptorExp; + loader::loaderDispatch->pCore->MemExp->pfnGetFileDescriptorFromIpcHandleExp = loader::zeMemGetFileDescriptorFromIpcHandleExp; + loader::loaderDispatch->pCore->MemExp->pfnSetAtomicAccessAttributeExp = loader::zeMemSetAtomicAccessAttributeExp; + loader::loaderDispatch->pCore->MemExp->pfnGetAtomicAccessAttributeExp = loader::zeMemGetAtomicAccessAttributeExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Module table +__zedlllocal void ZE_APICALL +zeGetModuleProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Module->pfnCreate = loader::zeModuleCreate; + loader::loaderDispatch->pCore->Module->pfnDestroy = loader::zeModuleDestroy; + loader::loaderDispatch->pCore->Module->pfnDynamicLink = loader::zeModuleDynamicLink; + loader::loaderDispatch->pCore->Module->pfnGetNativeBinary = loader::zeModuleGetNativeBinary; + loader::loaderDispatch->pCore->Module->pfnGetGlobalPointer = loader::zeModuleGetGlobalPointer; + loader::loaderDispatch->pCore->Module->pfnGetKernelNames = loader::zeModuleGetKernelNames; + loader::loaderDispatch->pCore->Module->pfnGetProperties = loader::zeModuleGetProperties; + loader::loaderDispatch->pCore->Module->pfnGetFunctionPointer = loader::zeModuleGetFunctionPointer; + loader::loaderDispatch->pCore->Module->pfnInspectLinkageExt = loader::zeModuleInspectLinkageExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for ModuleBuildLog table +__zedlllocal void ZE_APICALL +zeGetModuleBuildLogProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->ModuleBuildLog->pfnDestroy = loader::zeModuleBuildLogDestroy; + loader::loaderDispatch->pCore->ModuleBuildLog->pfnGetString = loader::zeModuleBuildLogGetString; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for PhysicalMem table +__zedlllocal void ZE_APICALL +zeGetPhysicalMemProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->PhysicalMem->pfnCreate = loader::zePhysicalMemCreate; + loader::loaderDispatch->pCore->PhysicalMem->pfnDestroy = loader::zePhysicalMemDestroy; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Sampler table +__zedlllocal void ZE_APICALL +zeGetSamplerProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->Sampler->pfnCreate = loader::zeSamplerCreate; + loader::loaderDispatch->pCore->Sampler->pfnDestroy = loader::zeSamplerDestroy; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for VirtualMem table +__zedlllocal void ZE_APICALL +zeGetVirtualMemProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->VirtualMem->pfnReserve = loader::zeVirtualMemReserve; + loader::loaderDispatch->pCore->VirtualMem->pfnFree = loader::zeVirtualMemFree; + loader::loaderDispatch->pCore->VirtualMem->pfnQueryPageSize = loader::zeVirtualMemQueryPageSize; + loader::loaderDispatch->pCore->VirtualMem->pfnMap = loader::zeVirtualMemMap; + loader::loaderDispatch->pCore->VirtualMem->pfnUnmap = loader::zeVirtualMemUnmap; + loader::loaderDispatch->pCore->VirtualMem->pfnSetAccessAttribute = loader::zeVirtualMemSetAccessAttribute; + loader::loaderDispatch->pCore->VirtualMem->pfnGetAccessAttribute = loader::zeVirtualMemGetAccessAttribute; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for FabricEdgeExp table +__zedlllocal void ZE_APICALL +zeGetFabricEdgeExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->FabricEdgeExp->pfnGetExp = loader::zeFabricEdgeGetExp; + loader::loaderDispatch->pCore->FabricEdgeExp->pfnGetVerticesExp = loader::zeFabricEdgeGetVerticesExp; + loader::loaderDispatch->pCore->FabricEdgeExp->pfnGetPropertiesExp = loader::zeFabricEdgeGetPropertiesExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for FabricVertexExp table +__zedlllocal void ZE_APICALL +zeGetFabricVertexExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pCore->FabricVertexExp->pfnGetExp = loader::zeFabricVertexGetExp; + loader::loaderDispatch->pCore->FabricVertexExp->pfnGetSubVerticesExp = loader::zeFabricVertexGetSubVerticesExp; + loader::loaderDispatch->pCore->FabricVertexExp->pfnGetPropertiesExp = loader::zeFabricVertexGetPropertiesExp; + loader::loaderDispatch->pCore->FabricVertexExp->pfnGetDeviceExp = loader::zeFabricVertexGetDeviceExp; +} + + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Global table /// with current process' addresses @@ -6935,12 +7421,14 @@ zeGetGlobalProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Global = new ze_global_dditable_t; if (version >= ZE_API_VERSION_1_0) { - pDdiTable->pfnInit = loader::zeInit; + pDdiTable->pfnInit = loader::zeInit; } if (version >= ZE_API_VERSION_1_10) { - pDdiTable->pfnInitDrivers = loader::zeInitDrivers; + pDdiTable->pfnInitDrivers = loader::zeInitDrivers; } + zeGetGlobalProcAddrTableLegacy(); } else { @@ -7033,21 +7521,43 @@ zeGetRTASBuilderProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->RTASBuilder = new ze_rtas_builder_dditable_t; if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExt = loader_driver_ddi::zeRTASBuilderCreateExt; + } else { pDdiTable->pfnCreateExt = loader::zeRTASBuilderCreateExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetBuildPropertiesExt = loader_driver_ddi::zeRTASBuilderGetBuildPropertiesExt; + } else { pDdiTable->pfnGetBuildPropertiesExt = loader::zeRTASBuilderGetBuildPropertiesExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnBuildExt = loader_driver_ddi::zeRTASBuilderBuildExt; + } else { pDdiTable->pfnBuildExt = loader::zeRTASBuilderBuildExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCommandListAppendCopyExt = loader_driver_ddi::zeRTASBuilderCommandListAppendCopyExt; + } else { pDdiTable->pfnCommandListAppendCopyExt = loader::zeRTASBuilderCommandListAppendCopyExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExt = loader_driver_ddi::zeRTASBuilderDestroyExt; + } else { pDdiTable->pfnDestroyExt = loader::zeRTASBuilderDestroyExt; } + } + zeGetRTASBuilderProcAddrTableLegacy(); } else { @@ -7130,18 +7640,36 @@ zeGetRTASBuilderExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->RTASBuilderExp = new ze_rtas_builder_exp_dditable_t; if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExp = loader_driver_ddi::zeRTASBuilderCreateExp; + } else { pDdiTable->pfnCreateExp = loader::zeRTASBuilderCreateExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetBuildPropertiesExp = loader_driver_ddi::zeRTASBuilderGetBuildPropertiesExp; + } else { pDdiTable->pfnGetBuildPropertiesExp = loader::zeRTASBuilderGetBuildPropertiesExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnBuildExp = loader_driver_ddi::zeRTASBuilderBuildExp; + } else { pDdiTable->pfnBuildExp = loader::zeRTASBuilderBuildExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zeRTASBuilderDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zeRTASBuilderDestroyExp; } + } + zeGetRTASBuilderExpProcAddrTableLegacy(); } else { @@ -7234,18 +7762,36 @@ zeGetRTASParallelOperationProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->RTASParallelOperation = new ze_rtas_parallel_operation_dditable_t; if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExt = loader_driver_ddi::zeRTASParallelOperationCreateExt; + } else { pDdiTable->pfnCreateExt = loader::zeRTASParallelOperationCreateExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPropertiesExt = loader_driver_ddi::zeRTASParallelOperationGetPropertiesExt; + } else { pDdiTable->pfnGetPropertiesExt = loader::zeRTASParallelOperationGetPropertiesExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnJoinExt = loader_driver_ddi::zeRTASParallelOperationJoinExt; + } else { pDdiTable->pfnJoinExt = loader::zeRTASParallelOperationJoinExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExt = loader_driver_ddi::zeRTASParallelOperationDestroyExt; + } else { pDdiTable->pfnDestroyExt = loader::zeRTASParallelOperationDestroyExt; } + } + zeGetRTASParallelOperationProcAddrTableLegacy(); } else { @@ -7328,18 +7874,36 @@ zeGetRTASParallelOperationExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->RTASParallelOperationExp = new ze_rtas_parallel_operation_exp_dditable_t; if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExp = loader_driver_ddi::zeRTASParallelOperationCreateExp; + } else { pDdiTable->pfnCreateExp = loader::zeRTASParallelOperationCreateExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPropertiesExp = loader_driver_ddi::zeRTASParallelOperationGetPropertiesExp; + } else { pDdiTable->pfnGetPropertiesExp = loader::zeRTASParallelOperationGetPropertiesExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnJoinExp = loader_driver_ddi::zeRTASParallelOperationJoinExp; + } else { pDdiTable->pfnJoinExp = loader::zeRTASParallelOperationJoinExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zeRTASParallelOperationDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zeRTASParallelOperationDestroyExp; } + } + zeGetRTASParallelOperationExpProcAddrTableLegacy(); } else { @@ -7432,30 +7996,60 @@ zeGetDriverProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Driver = new ze_driver_dditable_t; if (version >= ZE_API_VERSION_1_0) { - pDdiTable->pfnGet = loader::zeDriverGet; + pDdiTable->pfnGet = loader::zeDriverGet; } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetApiVersion = loader_driver_ddi::zeDriverGetApiVersion; + } else { pDdiTable->pfnGetApiVersion = loader::zeDriverGetApiVersion; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zeDriverGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zeDriverGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIpcProperties = loader_driver_ddi::zeDriverGetIpcProperties; + } else { pDdiTable->pfnGetIpcProperties = loader::zeDriverGetIpcProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExtensionProperties = loader_driver_ddi::zeDriverGetExtensionProperties; + } else { pDdiTable->pfnGetExtensionProperties = loader::zeDriverGetExtensionProperties; } + } if (version >= ZE_API_VERSION_1_1) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExtensionFunctionAddress = loader_driver_ddi::zeDriverGetExtensionFunctionAddress; + } else { pDdiTable->pfnGetExtensionFunctionAddress = loader::zeDriverGetExtensionFunctionAddress; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnRTASFormatCompatibilityCheckExt = loader_driver_ddi::zeDriverRTASFormatCompatibilityCheckExt; + } else { pDdiTable->pfnRTASFormatCompatibilityCheckExt = loader::zeDriverRTASFormatCompatibilityCheckExt; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetLastErrorDescription = loader_driver_ddi::zeDriverGetLastErrorDescription; + } else { pDdiTable->pfnGetLastErrorDescription = loader::zeDriverGetLastErrorDescription; } + } + zeGetDriverProcAddrTableLegacy(); } else { @@ -7538,9 +8132,15 @@ zeGetDriverExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->DriverExp = new ze_driver_exp_dditable_t; if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnRTASFormatCompatibilityCheckExp = loader_driver_ddi::zeDriverRTASFormatCompatibilityCheckExp; + } else { pDdiTable->pfnRTASFormatCompatibilityCheckExp = loader::zeDriverRTASFormatCompatibilityCheckExp; } + } + zeGetDriverExpProcAddrTableLegacy(); } else { @@ -7633,72 +8233,162 @@ zeGetDeviceProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Device = new ze_device_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGet = loader_driver_ddi::zeDeviceGet; + } else { pDdiTable->pfnGet = loader::zeDeviceGet; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSubDevices = loader_driver_ddi::zeDeviceGetSubDevices; + } else { pDdiTable->pfnGetSubDevices = loader::zeDeviceGetSubDevices; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zeDeviceGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zeDeviceGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetComputeProperties = loader_driver_ddi::zeDeviceGetComputeProperties; + } else { pDdiTable->pfnGetComputeProperties = loader::zeDeviceGetComputeProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetModuleProperties = loader_driver_ddi::zeDeviceGetModuleProperties; + } else { pDdiTable->pfnGetModuleProperties = loader::zeDeviceGetModuleProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetCommandQueueGroupProperties = loader_driver_ddi::zeDeviceGetCommandQueueGroupProperties; + } else { pDdiTable->pfnGetCommandQueueGroupProperties = loader::zeDeviceGetCommandQueueGroupProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetMemoryProperties = loader_driver_ddi::zeDeviceGetMemoryProperties; + } else { pDdiTable->pfnGetMemoryProperties = loader::zeDeviceGetMemoryProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetMemoryAccessProperties = loader_driver_ddi::zeDeviceGetMemoryAccessProperties; + } else { pDdiTable->pfnGetMemoryAccessProperties = loader::zeDeviceGetMemoryAccessProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetCacheProperties = loader_driver_ddi::zeDeviceGetCacheProperties; + } else { pDdiTable->pfnGetCacheProperties = loader::zeDeviceGetCacheProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetImageProperties = loader_driver_ddi::zeDeviceGetImageProperties; + } else { pDdiTable->pfnGetImageProperties = loader::zeDeviceGetImageProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExternalMemoryProperties = loader_driver_ddi::zeDeviceGetExternalMemoryProperties; + } else { pDdiTable->pfnGetExternalMemoryProperties = loader::zeDeviceGetExternalMemoryProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetP2PProperties = loader_driver_ddi::zeDeviceGetP2PProperties; + } else { pDdiTable->pfnGetP2PProperties = loader::zeDeviceGetP2PProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCanAccessPeer = loader_driver_ddi::zeDeviceCanAccessPeer; + } else { pDdiTable->pfnCanAccessPeer = loader::zeDeviceCanAccessPeer; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetStatus = loader_driver_ddi::zeDeviceGetStatus; + } else { pDdiTable->pfnGetStatus = loader::zeDeviceGetStatus; } + } if (version >= ZE_API_VERSION_1_1) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetGlobalTimestamps = loader_driver_ddi::zeDeviceGetGlobalTimestamps; + } else { pDdiTable->pfnGetGlobalTimestamps = loader::zeDeviceGetGlobalTimestamps; } + } if (version >= ZE_API_VERSION_1_12) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnImportExternalSemaphoreExt = loader_driver_ddi::zeDeviceImportExternalSemaphoreExt; + } else { pDdiTable->pfnImportExternalSemaphoreExt = loader::zeDeviceImportExternalSemaphoreExt; } + } if (version >= ZE_API_VERSION_1_12) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReleaseExternalSemaphoreExt = loader_driver_ddi::zeDeviceReleaseExternalSemaphoreExt; + } else { pDdiTable->pfnReleaseExternalSemaphoreExt = loader::zeDeviceReleaseExternalSemaphoreExt; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVectorWidthPropertiesExt = loader_driver_ddi::zeDeviceGetVectorWidthPropertiesExt; + } else { pDdiTable->pfnGetVectorWidthPropertiesExt = loader::zeDeviceGetVectorWidthPropertiesExt; } + } if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReserveCacheExt = loader_driver_ddi::zeDeviceReserveCacheExt; + } else { pDdiTable->pfnReserveCacheExt = loader::zeDeviceReserveCacheExt; } + } if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetCacheAdviceExt = loader_driver_ddi::zeDeviceSetCacheAdviceExt; + } else { pDdiTable->pfnSetCacheAdviceExt = loader::zeDeviceSetCacheAdviceExt; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPciGetPropertiesExt = loader_driver_ddi::zeDevicePciGetPropertiesExt; + } else { pDdiTable->pfnPciGetPropertiesExt = loader::zeDevicePciGetPropertiesExt; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetRootDevice = loader_driver_ddi::zeDeviceGetRootDevice; + } else { pDdiTable->pfnGetRootDevice = loader::zeDeviceGetRootDevice; } + } + zeGetDeviceProcAddrTableLegacy(); } else { @@ -7781,9 +8471,15 @@ zeGetDeviceExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->DeviceExp = new ze_device_exp_dditable_t; if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFabricVertexExp = loader_driver_ddi::zeDeviceGetFabricVertexExp; + } else { pDdiTable->pfnGetFabricVertexExp = loader::zeDeviceGetFabricVertexExp; } + } + zeGetDeviceExpProcAddrTableLegacy(); } else { @@ -7876,33 +8572,71 @@ zeGetContextProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Context = new ze_context_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeContextCreate; + } else { pDdiTable->pfnCreate = loader::zeContextCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeContextDestroy; + } else { pDdiTable->pfnDestroy = loader::zeContextDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetStatus = loader_driver_ddi::zeContextGetStatus; + } else { pDdiTable->pfnGetStatus = loader::zeContextGetStatus; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSystemBarrier = loader_driver_ddi::zeContextSystemBarrier; + } else { pDdiTable->pfnSystemBarrier = loader::zeContextSystemBarrier; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnMakeMemoryResident = loader_driver_ddi::zeContextMakeMemoryResident; + } else { pDdiTable->pfnMakeMemoryResident = loader::zeContextMakeMemoryResident; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEvictMemory = loader_driver_ddi::zeContextEvictMemory; + } else { pDdiTable->pfnEvictMemory = loader::zeContextEvictMemory; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnMakeImageResident = loader_driver_ddi::zeContextMakeImageResident; + } else { pDdiTable->pfnMakeImageResident = loader::zeContextMakeImageResident; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEvictImage = loader_driver_ddi::zeContextEvictImage; + } else { pDdiTable->pfnEvictImage = loader::zeContextEvictImage; } + } if (version >= ZE_API_VERSION_1_1) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateEx = loader_driver_ddi::zeContextCreateEx; + } else { pDdiTable->pfnCreateEx = loader::zeContextCreateEx; } + } + zeGetContextProcAddrTableLegacy(); } else { @@ -7995,24 +8729,50 @@ zeGetCommandQueueProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->CommandQueue = new ze_command_queue_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeCommandQueueCreate; + } else { pDdiTable->pfnCreate = loader::zeCommandQueueCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeCommandQueueDestroy; + } else { pDdiTable->pfnDestroy = loader::zeCommandQueueDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnExecuteCommandLists = loader_driver_ddi::zeCommandQueueExecuteCommandLists; + } else { pDdiTable->pfnExecuteCommandLists = loader::zeCommandQueueExecuteCommandLists; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSynchronize = loader_driver_ddi::zeCommandQueueSynchronize; + } else { pDdiTable->pfnSynchronize = loader::zeCommandQueueSynchronize; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetOrdinal = loader_driver_ddi::zeCommandQueueGetOrdinal; + } else { pDdiTable->pfnGetOrdinal = loader::zeCommandQueueGetOrdinal; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIndex = loader_driver_ddi::zeCommandQueueGetIndex; + } else { pDdiTable->pfnGetIndex = loader::zeCommandQueueGetIndex; } + } + zeGetCommandQueueProcAddrTableLegacy(); } else { @@ -8105,114 +8865,260 @@ zeGetCommandListProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->CommandList = new ze_command_list_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeCommandListCreate; + } else { pDdiTable->pfnCreate = loader::zeCommandListCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateImmediate = loader_driver_ddi::zeCommandListCreateImmediate; + } else { pDdiTable->pfnCreateImmediate = loader::zeCommandListCreateImmediate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeCommandListDestroy; + } else { pDdiTable->pfnDestroy = loader::zeCommandListDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnClose = loader_driver_ddi::zeCommandListClose; + } else { pDdiTable->pfnClose = loader::zeCommandListClose; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReset = loader_driver_ddi::zeCommandListReset; + } else { pDdiTable->pfnReset = loader::zeCommandListReset; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendWriteGlobalTimestamp = loader_driver_ddi::zeCommandListAppendWriteGlobalTimestamp; + } else { pDdiTable->pfnAppendWriteGlobalTimestamp = loader::zeCommandListAppendWriteGlobalTimestamp; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendBarrier = loader_driver_ddi::zeCommandListAppendBarrier; + } else { pDdiTable->pfnAppendBarrier = loader::zeCommandListAppendBarrier; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryRangesBarrier = loader_driver_ddi::zeCommandListAppendMemoryRangesBarrier; + } else { pDdiTable->pfnAppendMemoryRangesBarrier = loader::zeCommandListAppendMemoryRangesBarrier; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryCopy = loader_driver_ddi::zeCommandListAppendMemoryCopy; + } else { pDdiTable->pfnAppendMemoryCopy = loader::zeCommandListAppendMemoryCopy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryFill = loader_driver_ddi::zeCommandListAppendMemoryFill; + } else { pDdiTable->pfnAppendMemoryFill = loader::zeCommandListAppendMemoryFill; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryCopyRegion = loader_driver_ddi::zeCommandListAppendMemoryCopyRegion; + } else { pDdiTable->pfnAppendMemoryCopyRegion = loader::zeCommandListAppendMemoryCopyRegion; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryCopyFromContext = loader_driver_ddi::zeCommandListAppendMemoryCopyFromContext; + } else { pDdiTable->pfnAppendMemoryCopyFromContext = loader::zeCommandListAppendMemoryCopyFromContext; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopy = loader_driver_ddi::zeCommandListAppendImageCopy; + } else { pDdiTable->pfnAppendImageCopy = loader::zeCommandListAppendImageCopy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopyRegion = loader_driver_ddi::zeCommandListAppendImageCopyRegion; + } else { pDdiTable->pfnAppendImageCopyRegion = loader::zeCommandListAppendImageCopyRegion; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopyToMemory = loader_driver_ddi::zeCommandListAppendImageCopyToMemory; + } else { pDdiTable->pfnAppendImageCopyToMemory = loader::zeCommandListAppendImageCopyToMemory; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopyFromMemory = loader_driver_ddi::zeCommandListAppendImageCopyFromMemory; + } else { pDdiTable->pfnAppendImageCopyFromMemory = loader::zeCommandListAppendImageCopyFromMemory; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemoryPrefetch = loader_driver_ddi::zeCommandListAppendMemoryPrefetch; + } else { pDdiTable->pfnAppendMemoryPrefetch = loader::zeCommandListAppendMemoryPrefetch; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMemAdvise = loader_driver_ddi::zeCommandListAppendMemAdvise; + } else { pDdiTable->pfnAppendMemAdvise = loader::zeCommandListAppendMemAdvise; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendSignalEvent = loader_driver_ddi::zeCommandListAppendSignalEvent; + } else { pDdiTable->pfnAppendSignalEvent = loader::zeCommandListAppendSignalEvent; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendWaitOnEvents = loader_driver_ddi::zeCommandListAppendWaitOnEvents; + } else { pDdiTable->pfnAppendWaitOnEvents = loader::zeCommandListAppendWaitOnEvents; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendEventReset = loader_driver_ddi::zeCommandListAppendEventReset; + } else { pDdiTable->pfnAppendEventReset = loader::zeCommandListAppendEventReset; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendQueryKernelTimestamps = loader_driver_ddi::zeCommandListAppendQueryKernelTimestamps; + } else { pDdiTable->pfnAppendQueryKernelTimestamps = loader::zeCommandListAppendQueryKernelTimestamps; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendLaunchKernel = loader_driver_ddi::zeCommandListAppendLaunchKernel; + } else { pDdiTable->pfnAppendLaunchKernel = loader::zeCommandListAppendLaunchKernel; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendLaunchCooperativeKernel = loader_driver_ddi::zeCommandListAppendLaunchCooperativeKernel; + } else { pDdiTable->pfnAppendLaunchCooperativeKernel = loader::zeCommandListAppendLaunchCooperativeKernel; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendLaunchKernelIndirect = loader_driver_ddi::zeCommandListAppendLaunchKernelIndirect; + } else { pDdiTable->pfnAppendLaunchKernelIndirect = loader::zeCommandListAppendLaunchKernelIndirect; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = loader_driver_ddi::zeCommandListAppendLaunchMultipleKernelsIndirect; + } else { pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = loader::zeCommandListAppendLaunchMultipleKernelsIndirect; } + } if (version >= ZE_API_VERSION_1_12) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendSignalExternalSemaphoreExt = loader_driver_ddi::zeCommandListAppendSignalExternalSemaphoreExt; + } else { pDdiTable->pfnAppendSignalExternalSemaphoreExt = loader::zeCommandListAppendSignalExternalSemaphoreExt; } + } if (version >= ZE_API_VERSION_1_12) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendWaitExternalSemaphoreExt = loader_driver_ddi::zeCommandListAppendWaitExternalSemaphoreExt; + } else { pDdiTable->pfnAppendWaitExternalSemaphoreExt = loader::zeCommandListAppendWaitExternalSemaphoreExt; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopyToMemoryExt = loader_driver_ddi::zeCommandListAppendImageCopyToMemoryExt; + } else { pDdiTable->pfnAppendImageCopyToMemoryExt = loader::zeCommandListAppendImageCopyToMemoryExt; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendImageCopyFromMemoryExt = loader_driver_ddi::zeCommandListAppendImageCopyFromMemoryExt; + } else { pDdiTable->pfnAppendImageCopyFromMemoryExt = loader::zeCommandListAppendImageCopyFromMemoryExt; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnHostSynchronize = loader_driver_ddi::zeCommandListHostSynchronize; + } else { pDdiTable->pfnHostSynchronize = loader::zeCommandListHostSynchronize; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDeviceHandle = loader_driver_ddi::zeCommandListGetDeviceHandle; + } else { pDdiTable->pfnGetDeviceHandle = loader::zeCommandListGetDeviceHandle; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetContextHandle = loader_driver_ddi::zeCommandListGetContextHandle; + } else { pDdiTable->pfnGetContextHandle = loader::zeCommandListGetContextHandle; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetOrdinal = loader_driver_ddi::zeCommandListGetOrdinal; + } else { pDdiTable->pfnGetOrdinal = loader::zeCommandListGetOrdinal; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnImmediateGetIndex = loader_driver_ddi::zeCommandListImmediateGetIndex; + } else { pDdiTable->pfnImmediateGetIndex = loader::zeCommandListImmediateGetIndex; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnIsImmediate = loader_driver_ddi::zeCommandListIsImmediate; + } else { pDdiTable->pfnIsImmediate = loader::zeCommandListIsImmediate; } + } + zeGetCommandListProcAddrTableLegacy(); } else { @@ -8295,30 +9201,64 @@ zeGetCommandListExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->CommandListExp = new ze_command_list_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetNextCommandIdWithKernelsExp = loader_driver_ddi::zeCommandListGetNextCommandIdWithKernelsExp; + } else { pDdiTable->pfnGetNextCommandIdWithKernelsExp = loader::zeCommandListGetNextCommandIdWithKernelsExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnUpdateMutableCommandKernelsExp = loader_driver_ddi::zeCommandListUpdateMutableCommandKernelsExp; + } else { pDdiTable->pfnUpdateMutableCommandKernelsExp = loader::zeCommandListUpdateMutableCommandKernelsExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateCloneExp = loader_driver_ddi::zeCommandListCreateCloneExp; + } else { pDdiTable->pfnCreateCloneExp = loader::zeCommandListCreateCloneExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnImmediateAppendCommandListsExp = loader_driver_ddi::zeCommandListImmediateAppendCommandListsExp; + } else { pDdiTable->pfnImmediateAppendCommandListsExp = loader::zeCommandListImmediateAppendCommandListsExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetNextCommandIdExp = loader_driver_ddi::zeCommandListGetNextCommandIdExp; + } else { pDdiTable->pfnGetNextCommandIdExp = loader::zeCommandListGetNextCommandIdExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnUpdateMutableCommandsExp = loader_driver_ddi::zeCommandListUpdateMutableCommandsExp; + } else { pDdiTable->pfnUpdateMutableCommandsExp = loader::zeCommandListUpdateMutableCommandsExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnUpdateMutableCommandSignalEventExp = loader_driver_ddi::zeCommandListUpdateMutableCommandSignalEventExp; + } else { pDdiTable->pfnUpdateMutableCommandSignalEventExp = loader::zeCommandListUpdateMutableCommandSignalEventExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnUpdateMutableCommandWaitEventsExp = loader_driver_ddi::zeCommandListUpdateMutableCommandWaitEventsExp; + } else { pDdiTable->pfnUpdateMutableCommandWaitEventsExp = loader::zeCommandListUpdateMutableCommandWaitEventsExp; } + } + zeGetCommandListExpProcAddrTableLegacy(); } else { @@ -8411,39 +9351,85 @@ zeGetEventProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Event = new ze_event_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeEventCreate; + } else { pDdiTable->pfnCreate = loader::zeEventCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeEventDestroy; + } else { pDdiTable->pfnDestroy = loader::zeEventDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnHostSignal = loader_driver_ddi::zeEventHostSignal; + } else { pDdiTable->pfnHostSignal = loader::zeEventHostSignal; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnHostSynchronize = loader_driver_ddi::zeEventHostSynchronize; + } else { pDdiTable->pfnHostSynchronize = loader::zeEventHostSynchronize; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryStatus = loader_driver_ddi::zeEventQueryStatus; + } else { pDdiTable->pfnQueryStatus = loader::zeEventQueryStatus; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnHostReset = loader_driver_ddi::zeEventHostReset; + } else { pDdiTable->pfnHostReset = loader::zeEventHostReset; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryKernelTimestamp = loader_driver_ddi::zeEventQueryKernelTimestamp; + } else { pDdiTable->pfnQueryKernelTimestamp = loader::zeEventQueryKernelTimestamp; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryKernelTimestampsExt = loader_driver_ddi::zeEventQueryKernelTimestampsExt; + } else { pDdiTable->pfnQueryKernelTimestampsExt = loader::zeEventQueryKernelTimestampsExt; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetEventPool = loader_driver_ddi::zeEventGetEventPool; + } else { pDdiTable->pfnGetEventPool = loader::zeEventGetEventPool; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSignalScope = loader_driver_ddi::zeEventGetSignalScope; + } else { pDdiTable->pfnGetSignalScope = loader::zeEventGetSignalScope; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetWaitScope = loader_driver_ddi::zeEventGetWaitScope; + } else { pDdiTable->pfnGetWaitScope = loader::zeEventGetWaitScope; } + } + zeGetEventProcAddrTableLegacy(); } else { @@ -8526,9 +9512,15 @@ zeGetEventExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->EventExp = new ze_event_exp_dditable_t; if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryTimestampsExp = loader_driver_ddi::zeEventQueryTimestampsExp; + } else { pDdiTable->pfnQueryTimestampsExp = loader::zeEventQueryTimestampsExp; } + } + zeGetEventExpProcAddrTableLegacy(); } else { @@ -8621,30 +9613,64 @@ zeGetEventPoolProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->EventPool = new ze_event_pool_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeEventPoolCreate; + } else { pDdiTable->pfnCreate = loader::zeEventPoolCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeEventPoolDestroy; + } else { pDdiTable->pfnDestroy = loader::zeEventPoolDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIpcHandle = loader_driver_ddi::zeEventPoolGetIpcHandle; + } else { pDdiTable->pfnGetIpcHandle = loader::zeEventPoolGetIpcHandle; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOpenIpcHandle = loader_driver_ddi::zeEventPoolOpenIpcHandle; + } else { pDdiTable->pfnOpenIpcHandle = loader::zeEventPoolOpenIpcHandle; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCloseIpcHandle = loader_driver_ddi::zeEventPoolCloseIpcHandle; + } else { pDdiTable->pfnCloseIpcHandle = loader::zeEventPoolCloseIpcHandle; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPutIpcHandle = loader_driver_ddi::zeEventPoolPutIpcHandle; + } else { pDdiTable->pfnPutIpcHandle = loader::zeEventPoolPutIpcHandle; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetContextHandle = loader_driver_ddi::zeEventPoolGetContextHandle; + } else { pDdiTable->pfnGetContextHandle = loader::zeEventPoolGetContextHandle; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFlags = loader_driver_ddi::zeEventPoolGetFlags; + } else { pDdiTable->pfnGetFlags = loader::zeEventPoolGetFlags; } + } + zeGetEventPoolProcAddrTableLegacy(); } else { @@ -8737,21 +9763,43 @@ zeGetFenceProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Fence = new ze_fence_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeFenceCreate; + } else { pDdiTable->pfnCreate = loader::zeFenceCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeFenceDestroy; + } else { pDdiTable->pfnDestroy = loader::zeFenceDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnHostSynchronize = loader_driver_ddi::zeFenceHostSynchronize; + } else { pDdiTable->pfnHostSynchronize = loader::zeFenceHostSynchronize; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryStatus = loader_driver_ddi::zeFenceQueryStatus; + } else { pDdiTable->pfnQueryStatus = loader::zeFenceQueryStatus; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReset = loader_driver_ddi::zeFenceReset; + } else { pDdiTable->pfnReset = loader::zeFenceReset; } + } + zeGetFenceProcAddrTableLegacy(); } else { @@ -8844,21 +9892,43 @@ zeGetImageProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Image = new ze_image_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zeImageGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zeImageGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeImageCreate; + } else { pDdiTable->pfnCreate = loader::zeImageCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeImageDestroy; + } else { pDdiTable->pfnDestroy = loader::zeImageDestroy; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAllocPropertiesExt = loader_driver_ddi::zeImageGetAllocPropertiesExt; + } else { pDdiTable->pfnGetAllocPropertiesExt = loader::zeImageGetAllocPropertiesExt; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnViewCreateExt = loader_driver_ddi::zeImageViewCreateExt; + } else { pDdiTable->pfnViewCreateExt = loader::zeImageViewCreateExt; } + } + zeGetImageProcAddrTableLegacy(); } else { @@ -8941,15 +10011,29 @@ zeGetImageExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->ImageExp = new ze_image_exp_dditable_t; if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetMemoryPropertiesExp = loader_driver_ddi::zeImageGetMemoryPropertiesExp; + } else { pDdiTable->pfnGetMemoryPropertiesExp = loader::zeImageGetMemoryPropertiesExp; } + } if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnViewCreateExp = loader_driver_ddi::zeImageViewCreateExp; + } else { pDdiTable->pfnViewCreateExp = loader::zeImageViewCreateExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDeviceOffsetExp = loader_driver_ddi::zeImageGetDeviceOffsetExp; + } else { pDdiTable->pfnGetDeviceOffsetExp = loader::zeImageGetDeviceOffsetExp; } + } + zeGetImageExpProcAddrTableLegacy(); } else { @@ -9042,42 +10126,92 @@ zeGetKernelProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Kernel = new ze_kernel_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeKernelCreate; + } else { pDdiTable->pfnCreate = loader::zeKernelCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeKernelDestroy; + } else { pDdiTable->pfnDestroy = loader::zeKernelDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetCacheConfig = loader_driver_ddi::zeKernelSetCacheConfig; + } else { pDdiTable->pfnSetCacheConfig = loader::zeKernelSetCacheConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetGroupSize = loader_driver_ddi::zeKernelSetGroupSize; + } else { pDdiTable->pfnSetGroupSize = loader::zeKernelSetGroupSize; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSuggestGroupSize = loader_driver_ddi::zeKernelSuggestGroupSize; + } else { pDdiTable->pfnSuggestGroupSize = loader::zeKernelSuggestGroupSize; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSuggestMaxCooperativeGroupCount = loader_driver_ddi::zeKernelSuggestMaxCooperativeGroupCount; + } else { pDdiTable->pfnSuggestMaxCooperativeGroupCount = loader::zeKernelSuggestMaxCooperativeGroupCount; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetArgumentValue = loader_driver_ddi::zeKernelSetArgumentValue; + } else { pDdiTable->pfnSetArgumentValue = loader::zeKernelSetArgumentValue; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetIndirectAccess = loader_driver_ddi::zeKernelSetIndirectAccess; + } else { pDdiTable->pfnSetIndirectAccess = loader::zeKernelSetIndirectAccess; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIndirectAccess = loader_driver_ddi::zeKernelGetIndirectAccess; + } else { pDdiTable->pfnGetIndirectAccess = loader::zeKernelGetIndirectAccess; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSourceAttributes = loader_driver_ddi::zeKernelGetSourceAttributes; + } else { pDdiTable->pfnGetSourceAttributes = loader::zeKernelGetSourceAttributes; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zeKernelGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zeKernelGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetName = loader_driver_ddi::zeKernelGetName; + } else { pDdiTable->pfnGetName = loader::zeKernelGetName; } + } + zeGetKernelProcAddrTableLegacy(); } else { @@ -9160,15 +10294,29 @@ zeGetKernelExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->KernelExp = new ze_kernel_exp_dditable_t; if (version >= ZE_API_VERSION_1_1) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetGlobalOffsetExp = loader_driver_ddi::zeKernelSetGlobalOffsetExp; + } else { pDdiTable->pfnSetGlobalOffsetExp = loader::zeKernelSetGlobalOffsetExp; } + } if (version >= ZE_API_VERSION_1_11) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetBinaryExp = loader_driver_ddi::zeKernelGetBinaryExp; + } else { pDdiTable->pfnGetBinaryExp = loader::zeKernelGetBinaryExp; } + } if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSchedulingHintExp = loader_driver_ddi::zeKernelSchedulingHintExp; + } else { pDdiTable->pfnSchedulingHintExp = loader::zeKernelSchedulingHintExp; } + } + zeGetKernelExpProcAddrTableLegacy(); } else { @@ -9261,42 +10409,92 @@ zeGetMemProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Mem = new ze_mem_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAllocShared = loader_driver_ddi::zeMemAllocShared; + } else { pDdiTable->pfnAllocShared = loader::zeMemAllocShared; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAllocDevice = loader_driver_ddi::zeMemAllocDevice; + } else { pDdiTable->pfnAllocDevice = loader::zeMemAllocDevice; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAllocHost = loader_driver_ddi::zeMemAllocHost; + } else { pDdiTable->pfnAllocHost = loader::zeMemAllocHost; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnFree = loader_driver_ddi::zeMemFree; + } else { pDdiTable->pfnFree = loader::zeMemFree; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAllocProperties = loader_driver_ddi::zeMemGetAllocProperties; + } else { pDdiTable->pfnGetAllocProperties = loader::zeMemGetAllocProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAddressRange = loader_driver_ddi::zeMemGetAddressRange; + } else { pDdiTable->pfnGetAddressRange = loader::zeMemGetAddressRange; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIpcHandle = loader_driver_ddi::zeMemGetIpcHandle; + } else { pDdiTable->pfnGetIpcHandle = loader::zeMemGetIpcHandle; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOpenIpcHandle = loader_driver_ddi::zeMemOpenIpcHandle; + } else { pDdiTable->pfnOpenIpcHandle = loader::zeMemOpenIpcHandle; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCloseIpcHandle = loader_driver_ddi::zeMemCloseIpcHandle; + } else { pDdiTable->pfnCloseIpcHandle = loader::zeMemCloseIpcHandle; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnFreeExt = loader_driver_ddi::zeMemFreeExt; + } else { pDdiTable->pfnFreeExt = loader::zeMemFreeExt; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPutIpcHandle = loader_driver_ddi::zeMemPutIpcHandle; + } else { pDdiTable->pfnPutIpcHandle = loader::zeMemPutIpcHandle; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPitchFor2dImage = loader_driver_ddi::zeMemGetPitchFor2dImage; + } else { pDdiTable->pfnGetPitchFor2dImage = loader::zeMemGetPitchFor2dImage; } + } + zeGetMemProcAddrTableLegacy(); } else { @@ -9379,18 +10577,36 @@ zeGetMemExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->MemExp = new ze_mem_exp_dditable_t; if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = loader_driver_ddi::zeMemGetIpcHandleFromFileDescriptorExp; + } else { pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = loader::zeMemGetIpcHandleFromFileDescriptorExp; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = loader_driver_ddi::zeMemGetFileDescriptorFromIpcHandleExp; + } else { pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = loader::zeMemGetFileDescriptorFromIpcHandleExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetAtomicAccessAttributeExp = loader_driver_ddi::zeMemSetAtomicAccessAttributeExp; + } else { pDdiTable->pfnSetAtomicAccessAttributeExp = loader::zeMemSetAtomicAccessAttributeExp; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAtomicAccessAttributeExp = loader_driver_ddi::zeMemGetAtomicAccessAttributeExp; + } else { pDdiTable->pfnGetAtomicAccessAttributeExp = loader::zeMemGetAtomicAccessAttributeExp; } + } + zeGetMemExpProcAddrTableLegacy(); } else { @@ -9483,33 +10699,71 @@ zeGetModuleProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Module = new ze_module_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeModuleCreate; + } else { pDdiTable->pfnCreate = loader::zeModuleCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeModuleDestroy; + } else { pDdiTable->pfnDestroy = loader::zeModuleDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDynamicLink = loader_driver_ddi::zeModuleDynamicLink; + } else { pDdiTable->pfnDynamicLink = loader::zeModuleDynamicLink; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetNativeBinary = loader_driver_ddi::zeModuleGetNativeBinary; + } else { pDdiTable->pfnGetNativeBinary = loader::zeModuleGetNativeBinary; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetGlobalPointer = loader_driver_ddi::zeModuleGetGlobalPointer; + } else { pDdiTable->pfnGetGlobalPointer = loader::zeModuleGetGlobalPointer; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetKernelNames = loader_driver_ddi::zeModuleGetKernelNames; + } else { pDdiTable->pfnGetKernelNames = loader::zeModuleGetKernelNames; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zeModuleGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zeModuleGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFunctionPointer = loader_driver_ddi::zeModuleGetFunctionPointer; + } else { pDdiTable->pfnGetFunctionPointer = loader::zeModuleGetFunctionPointer; } + } if (version >= ZE_API_VERSION_1_3) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnInspectLinkageExt = loader_driver_ddi::zeModuleInspectLinkageExt; + } else { pDdiTable->pfnInspectLinkageExt = loader::zeModuleInspectLinkageExt; } + } + zeGetModuleProcAddrTableLegacy(); } else { @@ -9602,12 +10856,22 @@ zeGetModuleBuildLogProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->ModuleBuildLog = new ze_module_build_log_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeModuleBuildLogDestroy; + } else { pDdiTable->pfnDestroy = loader::zeModuleBuildLogDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetString = loader_driver_ddi::zeModuleBuildLogGetString; + } else { pDdiTable->pfnGetString = loader::zeModuleBuildLogGetString; } + } + zeGetModuleBuildLogProcAddrTableLegacy(); } else { @@ -9700,12 +10964,22 @@ zeGetPhysicalMemProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->PhysicalMem = new ze_physical_mem_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zePhysicalMemCreate; + } else { pDdiTable->pfnCreate = loader::zePhysicalMemCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zePhysicalMemDestroy; + } else { pDdiTable->pfnDestroy = loader::zePhysicalMemDestroy; } + } + zeGetPhysicalMemProcAddrTableLegacy(); } else { @@ -9798,12 +11072,22 @@ zeGetSamplerProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->Sampler = new ze_sampler_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zeSamplerCreate; + } else { pDdiTable->pfnCreate = loader::zeSamplerCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zeSamplerDestroy; + } else { pDdiTable->pfnDestroy = loader::zeSamplerDestroy; } + } + zeGetSamplerProcAddrTableLegacy(); } else { @@ -9896,27 +11180,57 @@ zeGetVirtualMemProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->VirtualMem = new ze_virtual_mem_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReserve = loader_driver_ddi::zeVirtualMemReserve; + } else { pDdiTable->pfnReserve = loader::zeVirtualMemReserve; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnFree = loader_driver_ddi::zeVirtualMemFree; + } else { pDdiTable->pfnFree = loader::zeVirtualMemFree; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnQueryPageSize = loader_driver_ddi::zeVirtualMemQueryPageSize; + } else { pDdiTable->pfnQueryPageSize = loader::zeVirtualMemQueryPageSize; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnMap = loader_driver_ddi::zeVirtualMemMap; + } else { pDdiTable->pfnMap = loader::zeVirtualMemMap; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnUnmap = loader_driver_ddi::zeVirtualMemUnmap; + } else { pDdiTable->pfnUnmap = loader::zeVirtualMemUnmap; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetAccessAttribute = loader_driver_ddi::zeVirtualMemSetAccessAttribute; + } else { pDdiTable->pfnSetAccessAttribute = loader::zeVirtualMemSetAccessAttribute; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAccessAttribute = loader_driver_ddi::zeVirtualMemGetAccessAttribute; + } else { pDdiTable->pfnGetAccessAttribute = loader::zeVirtualMemGetAccessAttribute; } + } + zeGetVirtualMemProcAddrTableLegacy(); } else { @@ -9999,15 +11313,29 @@ zeGetFabricEdgeExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->FabricEdgeExp = new ze_fabric_edge_exp_dditable_t; if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExp = loader_driver_ddi::zeFabricEdgeGetExp; + } else { pDdiTable->pfnGetExp = loader::zeFabricEdgeGetExp; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVerticesExp = loader_driver_ddi::zeFabricEdgeGetVerticesExp; + } else { pDdiTable->pfnGetVerticesExp = loader::zeFabricEdgeGetVerticesExp; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPropertiesExp = loader_driver_ddi::zeFabricEdgeGetPropertiesExp; + } else { pDdiTable->pfnGetPropertiesExp = loader::zeFabricEdgeGetPropertiesExp; } + } + zeGetFabricEdgeExpProcAddrTableLegacy(); } else { @@ -10090,18 +11418,36 @@ zeGetFabricVertexExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pCore->FabricVertexExp = new ze_fabric_vertex_exp_dditable_t; if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExp = loader_driver_ddi::zeFabricVertexGetExp; + } else { pDdiTable->pfnGetExp = loader::zeFabricVertexGetExp; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSubVerticesExp = loader_driver_ddi::zeFabricVertexGetSubVerticesExp; + } else { pDdiTable->pfnGetSubVerticesExp = loader::zeFabricVertexGetSubVerticesExp; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPropertiesExp = loader_driver_ddi::zeFabricVertexGetPropertiesExp; + } else { pDdiTable->pfnGetPropertiesExp = loader::zeFabricVertexGetPropertiesExp; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDeviceExp = loader_driver_ddi::zeFabricVertexGetDeviceExp; + } else { pDdiTable->pfnGetDeviceExp = loader::zeFabricVertexGetDeviceExp; } + } + zeGetFabricVertexExpProcAddrTableLegacy(); } else { @@ -10142,4 +11488,4 @@ zeGetFabricVertexExpProcAddrTable( #if defined(__cplusplus) }; -#endif +#endif \ No newline at end of file diff --git a/source/loader/ze_ldrddi.h b/source/loader/ze_ldrddi.h index 609bb853..5f6d89e3 100644 --- a/source/loader/ze_ldrddi.h +++ b/source/loader/ze_ldrddi.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -76,3 +76,1599 @@ namespace loader using ze_rtas_parallel_operation_exp_factory_t = singleton_factory_t < ze_rtas_parallel_operation_exp_object_t, ze_rtas_parallel_operation_exp_handle_t >; } + +namespace loader_driver_ddi +{ + __zedlllocal void ZE_APICALL + zeDestroyDDiDriverTables(ze_dditable_driver_t* pDdiTable); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetApiVersion( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_api_version_t* version ///< [out] api version + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_driver_properties_t* pDriverProperties ///< [in,out] query result for driver properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetIpcProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_driver_ipc_properties_t* pIpcProperties ///< [in,out] query result for IPC properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetExtensionProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of extension properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of extension properties available. + ///< if count is greater than the number of extension properties available, + ///< then the driver shall update the value with the correct number of + ///< extension properties available. + ze_driver_extension_properties_t* pExtensionProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< extension properties. + ///< if count is less than the number of extension properties available, + ///< then driver shall only retrieve that number of extension properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetExtensionFunctionAddress( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char* name, ///< [in] extension function name + void** ppFunctionAddress ///< [out] pointer to function pointer + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGet( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of devices available. + ///< if count is greater than the number of devices available, then the + ///< driver shall update the value with the correct number of devices available. + ze_device_handle_t* phDevices ///< [in,out][optional][range(0, *pCount)] array of handle of devices. + ///< if count is less than the number of devices available, then driver + ///< shall only retrieve that number of devices. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetRootDevice( + ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t* phRootDevice ///< [in,out] parent root device. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetSubDevices( + ze_device_handle_t hDevice, ///< [in] handle of the device object + uint32_t* pCount, ///< [in,out] pointer to the number of sub-devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub-devices available. + ///< if count is greater than the number of sub-devices available, then the + ///< driver shall update the value with the correct number of sub-devices available. + ze_device_handle_t* phSubdevices ///< [in,out][optional][range(0, *pCount)] array of handle of sub-devices. + ///< if count is less than the number of sub-devices available, then driver + ///< shall only retrieve that number of sub-devices. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_properties_t* pDeviceProperties ///< [in,out] query result for device properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetComputeProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_compute_properties_t* pComputeProperties ///< [in,out] query result for compute properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetModuleProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_module_properties_t* pModuleProperties///< [in,out] query result for module properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetCommandQueueGroupProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of command queue group properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of command queue group properties available. + ///< if count is greater than the number of command queue group properties + ///< available, then the driver shall update the value with the correct + ///< number of command queue group properties available. + ze_command_queue_group_properties_t* pCommandQueueGroupProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< command queue group properties. + ///< if count is less than the number of command queue group properties + ///< available, then driver shall only retrieve that number of command + ///< queue group properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetMemoryProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of memory properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of memory properties available. + ///< if count is greater than the number of memory properties available, + ///< then the driver shall update the value with the correct number of + ///< memory properties available. + ze_device_memory_properties_t* pMemProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< memory properties. + ///< if count is less than the number of memory properties available, then + ///< driver shall only retrieve that number of memory properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetMemoryAccessProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_memory_access_properties_t* pMemAccessProperties ///< [in,out] query result for memory access properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetCacheProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of cache properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of cache properties available. + ///< if count is greater than the number of cache properties available, + ///< then the driver shall update the value with the correct number of + ///< cache properties available. + ze_device_cache_properties_t* pCacheProperties ///< [in,out][optional][range(0, *pCount)] array of query results for cache properties. + ///< if count is less than the number of cache properties available, then + ///< driver shall only retrieve that number of cache properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetImageProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_image_properties_t* pImageProperties ///< [in,out] query result for image properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetExternalMemoryProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_external_memory_properties_t* pExternalMemoryProperties ///< [in,out] query result for external memory properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetP2PProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device performing the access + ze_device_handle_t hPeerDevice, ///< [in] handle of the peer device with the allocation + ze_device_p2p_properties_t* pP2PProperties ///< [in,out] Peer-to-Peer properties between source and peer device + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceCanAccessPeer( + ze_device_handle_t hDevice, ///< [in] handle of the device performing the access + ze_device_handle_t hPeerDevice, ///< [in] handle of the peer device with the allocation + ze_bool_t* value ///< [out] returned access capability + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetStatus( + ze_device_handle_t hDevice ///< [in] handle of the device + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetGlobalTimestamps( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the + ///< Device's global timestamp value. + uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the + ///< Host's global timestamp value. + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextCreate( + ze_driver_handle_t hDriver, ///< [in] handle of the driver object + const ze_context_desc_t* desc, ///< [in] pointer to context descriptor + ze_context_handle_t* phContext ///< [out] pointer to handle of context object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextCreateEx( + ze_driver_handle_t hDriver, ///< [in] handle of the driver object + const ze_context_desc_t* desc, ///< [in] pointer to context descriptor + uint32_t numDevices, ///< [in][optional] number of device handles; must be 0 if `nullptr == + ///< phDevices` + ze_device_handle_t* phDevices, ///< [in][optional][range(0, numDevices)] array of device handles which + ///< context has visibility. + ///< if nullptr, then all devices and any sub-devices supported by the + ///< driver instance are + ///< visible to the context. + ///< otherwise, the context only has visibility to the devices and any + ///< sub-devices of the + ///< devices in this array. + ze_context_handle_t* phContext ///< [out] pointer to handle of context object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextDestroy( + ze_context_handle_t hContext ///< [in][release] handle of context object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextGetStatus( + ze_context_handle_t hContext ///< [in] handle of context object + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_queue_desc_t* desc, ///< [in] pointer to command queue descriptor + ze_command_queue_handle_t* phCommandQueue ///< [out] pointer to handle of command queue object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueDestroy( + ze_command_queue_handle_t hCommandQueue ///< [in][release] handle of command queue object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueExecuteCommandLists( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t numCommandLists, ///< [in] number of command lists to execute + ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] list of handles of the command lists + ///< to execute + ze_fence_handle_t hFence ///< [in][optional] handle of the fence to signal on completion + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueSynchronize( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the command queue; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueGetOrdinal( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t* pOrdinal ///< [out] command queue group ordinal + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueGetIndex( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t* pIndex ///< [out] command queue index within the group + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_list_desc_t* desc, ///< [in] pointer to command list descriptor + ze_command_list_handle_t* phCommandList ///< [out] pointer to handle of command list object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreateImmediate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_queue_desc_t* altdesc, ///< [in] pointer to command queue descriptor + ze_command_list_handle_t* phCommandList ///< [out] pointer to handle of command list object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListDestroy( + ze_command_list_handle_t hCommandList ///< [in][release] handle of command list object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListClose( + ze_command_list_handle_t hCommandList ///< [in] handle of command list object to close + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListReset( + ze_command_list_handle_t hCommandList ///< [in] handle of command list object to reset + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWriteGlobalTimestamp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t* dstptr, ///< [in,out] pointer to memory where timestamp value will be written; must + ///< be 8byte-aligned. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing query; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing query + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetDeviceHandle( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_device_handle_t* phDevice ///< [out] handle of the device on which the command list was created + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetContextHandle( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_context_handle_t* phContext ///< [out] handle of the context on which the command list was created + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetOrdinal( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t* pOrdinal ///< [out] command queue group ordinal to which command list is submitted + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListImmediateGetIndex( + ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list + uint32_t* pIndex ///< [out] command queue index within the group to which the immediate + ///< command list is submitted + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListIsImmediate( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_bool_t* pIsImmediate ///< [out] Boolean indicating whether the command list is an immediate + ///< command list (true) or not (false) + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendBarrier( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing barrier; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing barrier + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryRangesBarrier( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numRanges, ///< [in] number of memory ranges + const size_t* pRangeSizes, ///< [in][range(0, numRanges)] array of sizes of memory range + const void** pRanges, ///< [in][range(0, numRanges)] array of memory ranges + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing barrier; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing barrier + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextSystemBarrier( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice ///< [in] handle of the device + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopy( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryFill( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* ptr, ///< [in] pointer to memory to initialize + const void* pattern, ///< [in] pointer to value to initialize memory to + size_t pattern_size, ///< [in] size in bytes of the value to initialize memory to + size_t size, ///< [in] size in bytes to initialize + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopyRegion( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + const ze_copy_region_t* dstRegion, ///< [in] pointer to destination region to copy to + uint32_t dstPitch, ///< [in] destination pitch in bytes + uint32_t dstSlicePitch, ///< [in] destination slice pitch in bytes. This is required for 3D region + ///< copies where the `depth` member of ::ze_copy_region_t is not 0, + ///< otherwise it's ignored. + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_copy_region_t* srcRegion, ///< [in] pointer to source region to copy from + uint32_t srcPitch, ///< [in] source pitch in bytes + uint32_t srcSlicePitch, ///< [in] source slice pitch in bytes. This is required for 3D region + ///< copies where the `depth` member of ::ze_copy_region_t is not 0, + ///< otherwise it's ignored. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopyFromContext( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_context_handle_t hContextSrc, ///< [in] handle of source context object + const void* srcptr, ///< [in] pointer to source memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopy( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyRegion( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyToMemory( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyFromMemory( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryPrefetch( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + const void* ptr, ///< [in] pointer to start of the memory range to prefetch + size_t size ///< [in] size in bytes of the memory range to prefetch + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemAdvise( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_advice_t advice ///< [in] Memory advice for the memory range + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_event_pool_desc_t* desc, ///< [in] pointer to event pool descriptor + uint32_t numDevices, ///< [in][optional] number of device handles; must be 0 if `nullptr == + ///< phDevices` + ze_device_handle_t* phDevices, ///< [in][optional][range(0, numDevices)] array of device handles which + ///< have visibility to the event pool. + ///< if nullptr, then event pool is visible to all devices supported by the + ///< driver instance. + ze_event_pool_handle_t* phEventPool ///< [out] pointer handle of event pool object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolDestroy( + ze_event_pool_handle_t hEventPool ///< [in][release] handle of event pool object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventCreate( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + const ze_event_desc_t* desc, ///< [in] pointer to event descriptor + ze_event_handle_t* phEvent ///< [out] pointer to handle of event object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventDestroy( + ze_event_handle_t hEvent ///< [in][release] handle of event object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetIpcHandle( + ze_event_pool_handle_t hEventPool, ///< [in] handle of event pool object + ze_ipc_event_pool_handle_t* phIpc ///< [out] Returned IPC event handle + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolOpenIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object to associate with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc, ///< [in] IPC event pool handle + ze_event_pool_handle_t* phEventPool ///< [out] pointer handle of event pool object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolCloseIpcHandle( + ze_event_pool_handle_t hEventPool ///< [in][release] handle of event pool object + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalEvent( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hEvent ///< [in] handle of the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitOnEvents( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numEvents, ///< [in] number of events to wait on before continuing + ze_event_handle_t* phEvents ///< [in][range(0, numEvents)] handles of the events to wait on before + ///< continuing + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventHostSignal( + ze_event_handle_t hEvent ///< [in] handle of the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventHostSynchronize( + ze_event_handle_t hEvent, ///< [in] handle of the event + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then operates exactly like ::zeEventQueryStatus; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryStatus( + ze_event_handle_t hEvent ///< [in] handle of the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendEventReset( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hEvent ///< [in] handle of the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventHostReset( + ze_event_handle_t hEvent ///< [in] handle of the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestamp( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_kernel_timestamp_result_t* dstptr ///< [in,out] pointer to memory for where timestamp result will be written. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendQueryKernelTimestamps( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numEvents, ///< [in] the number of timestamp events to query + ze_event_handle_t* phEvents, ///< [in][range(0, numEvents)] handles of timestamp events to query + void* dstptr, ///< [in,out] pointer to memory where ::ze_kernel_timestamp_result_t will + ///< be written; must be size-aligned. + const size_t* pOffsets, ///< [in][optional][range(0, numEvents)] offset, in bytes, to write + ///< results; address must be 4byte-aligned and offsets must be + ///< size-aligned. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing query; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing query + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventGetEventPool( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_pool_handle_t* phEventPool ///< [out] handle of the event pool for the event + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventGetSignalScope( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_scope_flags_t* pSignalScope ///< [out] signal event scope. This is the scope of relevant cache + ///< hierarchies that are flushed on a signal action before the event is + ///< triggered. May be 0 or a valid combination of ::ze_event_scope_flag_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventGetWaitScope( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_scope_flags_t* pWaitScope ///< [out] wait event scope. This is the scope of relevant cache + ///< hierarchies invalidated on a wait action after the event is complete. + ///< May be 0 or a valid combination of ::ze_event_scope_flag_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetContextHandle( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + ze_context_handle_t* phContext ///< [out] handle of the context on which the event pool was created + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetFlags( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + ze_event_pool_flags_t* pFlags ///< [out] creation flags used to create the event pool; may be 0 or a + ///< valid combination of ::ze_event_pool_flag_t + ); + __zedlllocal ze_result_t ZE_APICALL + zeFenceCreate( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of command queue + const ze_fence_desc_t* desc, ///< [in] pointer to fence descriptor + ze_fence_handle_t* phFence ///< [out] pointer to handle of fence object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeFenceDestroy( + ze_fence_handle_t hFence ///< [in][release] handle of fence object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeFenceHostSynchronize( + ze_fence_handle_t hFence, ///< [in] handle of the fence + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then operates exactly like ::zeFenceQueryStatus; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ); + __zedlllocal ze_result_t ZE_APICALL + zeFenceQueryStatus( + ze_fence_handle_t hFence ///< [in] handle of the fence + ); + __zedlllocal ze_result_t ZE_APICALL + zeFenceReset( + ze_fence_handle_t hFence ///< [in] handle of the fence + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageGetProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_properties_t* pImageProperties ///< [out] pointer to image properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t* phImage ///< [out] pointer to handle of image object created + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageDestroy( + ze_image_handle_t hImage ///< [in][release] handle of image object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocShared( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_device_mem_alloc_desc_t* device_desc, ///< [in] pointer to device memory allocation descriptor + const ze_host_mem_alloc_desc_t* host_desc, ///< [in] pointer to host memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + ze_device_handle_t hDevice, ///< [in][optional] device handle to associate with + void** pptr ///< [out] pointer to shared allocation + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocDevice( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_device_mem_alloc_desc_t* device_desc, ///< [in] pointer to device memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + ze_device_handle_t hDevice, ///< [in] handle of the device + void** pptr ///< [out] pointer to device allocation + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocHost( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_host_mem_alloc_desc_t* host_desc, ///< [in] pointer to host memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + void** pptr ///< [out] pointer to host allocation + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemFree( + ze_context_handle_t hContext, ///< [in] handle of the context object + void* ptr ///< [in][release] pointer to memory to free + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAllocProperties( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] memory pointer to query + ze_memory_allocation_properties_t* pMemAllocProperties, ///< [in,out] query result for memory allocation properties + ze_device_handle_t* phDevice ///< [out][optional] device associated with this allocation + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAddressRange( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] memory pointer to query + void** pBase, ///< [in,out][optional] base address of the allocation + size_t* pSize ///< [in,out][optional] size of the allocation + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to the device memory allocation + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemOpenIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device to associate with the IPC memory handle + ze_ipc_mem_handle_t handle, ///< [in] IPC memory handle + ze_ipc_memory_flags_t flags, ///< [in] flags controlling the operation. + ///< must be 0 (default) or a valid combination of ::ze_ipc_memory_flag_t. + void** pptr ///< [out] pointer to device allocation in this process + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemCloseIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr ///< [in][release] pointer to device allocation in this process + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemSetAtomicAccessAttributeExp( + ze_context_handle_t hContext, ///< [in] handle of context + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_atomic_attr_exp_flags_t attr ///< [in] Atomic access attributes to set for the specified range. + ///< Must be 0 (default) or a valid combination of ::ze_memory_atomic_attr_exp_flag_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAtomicAccessAttributeExp( + ze_context_handle_t hContext, ///< [in] handle of context + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_atomic_attr_exp_flags_t* pAttr ///< [out] Atomic access attributes for the specified range + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_module_desc_t* desc, ///< [in] pointer to module descriptor + ze_module_handle_t* phModule, ///< [out] pointer to handle of module object created + ze_module_build_log_handle_t* phBuildLog ///< [out][optional] pointer to handle of module's build log. + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleDestroy( + ze_module_handle_t hModule ///< [in][release] handle of the module + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleDynamicLink( + uint32_t numModules, ///< [in] number of modules to be linked pointed to by phModules. + ze_module_handle_t* phModules, ///< [in][range(0, numModules)] pointer to an array of modules to + ///< dynamically link together. + ze_module_build_log_handle_t* phLinkLog ///< [out][optional] pointer to handle of dynamic link log. + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleBuildLogDestroy( + ze_module_build_log_handle_t hModuleBuildLog ///< [in][release] handle of the module build log object. + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleBuildLogGetString( + ze_module_build_log_handle_t hModuleBuildLog, ///< [in] handle of the module build log object. + size_t* pSize, ///< [in,out] size of build log string. + char* pBuildLog ///< [in,out][optional] pointer to null-terminated string of the log. + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetNativeBinary( + ze_module_handle_t hModule, ///< [in] handle of the module + size_t* pSize, ///< [in,out] size of native binary in bytes. + uint8_t* pModuleNativeBinary ///< [in,out][optional] byte pointer to native binary + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetGlobalPointer( + ze_module_handle_t hModule, ///< [in] handle of the module + const char* pGlobalName, ///< [in] name of global variable in module + size_t* pSize, ///< [in,out][optional] size of global variable + void** pptr ///< [in,out][optional] device visible pointer + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetKernelNames( + ze_module_handle_t hModule, ///< [in] handle of the module + uint32_t* pCount, ///< [in,out] pointer to the number of names. + ///< if count is zero, then the driver shall update the value with the + ///< total number of names available. + ///< if count is greater than the number of names available, then the + ///< driver shall update the value with the correct number of names available. + const char** pNames ///< [in,out][optional][range(0, *pCount)] array of names of functions. + ///< if count is less than the number of names available, then driver shall + ///< only retrieve that number of names. + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetProperties( + ze_module_handle_t hModule, ///< [in] handle of the module + ze_module_properties_t* pModuleProperties ///< [in,out] query result for module properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelCreate( + ze_module_handle_t hModule, ///< [in] handle of the module + const ze_kernel_desc_t* desc, ///< [in] pointer to kernel descriptor + ze_kernel_handle_t* phKernel ///< [out] handle of the Function object + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelDestroy( + ze_kernel_handle_t hKernel ///< [in][release] handle of the kernel object + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetFunctionPointer( + ze_module_handle_t hModule, ///< [in] handle of the module + const char* pFunctionName, ///< [in] Name of function to retrieve function pointer for. + void** pfnFunction ///< [out] pointer to function. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetGroupSize( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t groupSizeX, ///< [in] group size for X dimension to use for this kernel + uint32_t groupSizeY, ///< [in] group size for Y dimension to use for this kernel + uint32_t groupSizeZ ///< [in] group size for Z dimension to use for this kernel + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSuggestGroupSize( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t globalSizeX, ///< [in] global width for X dimension + uint32_t globalSizeY, ///< [in] global width for Y dimension + uint32_t globalSizeZ, ///< [in] global width for Z dimension + uint32_t* groupSizeX, ///< [out] recommended size of group for X dimension + uint32_t* groupSizeY, ///< [out] recommended size of group for Y dimension + uint32_t* groupSizeZ ///< [out] recommended size of group for Z dimension + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSuggestMaxCooperativeGroupCount( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t* totalGroupCount ///< [out] recommended total group count. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetArgumentValue( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t argIndex, ///< [in] argument index in range [0, num args - 1] + size_t argSize, ///< [in] size of argument type + const void* pArgValue ///< [in][optional] argument value represented as matching arg type. If + ///< null then argument value is considered null. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetIndirectAccess( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_indirect_access_flags_t flags ///< [in] kernel indirect access flags + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetIndirectAccess( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_indirect_access_flags_t* pFlags ///< [out] query result for kernel indirect access flags. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetSourceAttributes( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. Otherwise, pString + ///< must point to valid application memory that is greater than or equal + ///< to *pSize bytes in length, and on return the pointed-to string will + ///< contain a space-separated list of kernel source attributes. Note: This + ///< API was originally intended to ship with a char *pString, however this + ///< typo was introduced. Thus the API has to stay this way for backwards + ///< compatible reasons. It can be corrected in v2.0. Suggestion is to + ///< create your own char *pString and then pass to this API with &pString. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetCacheConfig( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_cache_config_flags_t flags ///< [in] cache configuration. + ///< must be 0 (default configuration) or a valid combination of ::ze_cache_config_flag_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetProperties( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_properties_t* pKernelProperties ///< [in,out] query result for kernel properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetName( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + size_t* pSize, ///< [in,out] size of kernel name string, including null terminator, in + ///< bytes. + char* pName ///< [in,out][optional] char pointer to kernel name. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchKernel( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchFuncArgs, ///< [in] thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchCooperativeKernel( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchFuncArgs, ///< [in] thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchKernelIndirect( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchArgumentsBuffer, ///< [in] pointer to device buffer that will contain thread group launch + ///< arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchMultipleKernelsIndirect( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] maximum number of kernels to launch + ze_kernel_handle_t* phKernels, ///< [in][range(0, numKernels)] handles of the kernel objects + const uint32_t* pCountBuffer, ///< [in] pointer to device memory location that will contain the actual + ///< number of kernels to launch; value must be less than or equal to + ///< numKernels + const ze_group_count_t* pLaunchArgumentsBuffer, ///< [in][range(0, numKernels)] pointer to device buffer that will contain + ///< a contiguous array of thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextMakeMemoryResident( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + void* ptr, ///< [in] pointer to memory to make resident + size_t size ///< [in] size in bytes to make resident + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextEvictMemory( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + void* ptr, ///< [in] pointer to memory to evict + size_t size ///< [in] size in bytes to evict + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextMakeImageResident( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_image_handle_t hImage ///< [in] handle of image to make resident + ); + __zedlllocal ze_result_t ZE_APICALL + zeContextEvictImage( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_image_handle_t hImage ///< [in] handle of image to make evict + ); + __zedlllocal ze_result_t ZE_APICALL + zeSamplerCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_sampler_desc_t* desc, ///< [in] pointer to sampler descriptor + ze_sampler_handle_t* phSampler ///< [out] handle of the sampler + ); + __zedlllocal ze_result_t ZE_APICALL + zeSamplerDestroy( + ze_sampler_handle_t hSampler ///< [in][release] handle of the sampler + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemReserve( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* pStart, ///< [in][optional] pointer to start of region to reserve. If nullptr then + ///< implementation will choose a start address. + size_t size, ///< [in] size in bytes to reserve; must be page aligned. + void** pptr ///< [out] pointer to virtual reservation. + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemFree( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of region to free. + size_t size ///< [in] size in bytes to free; must be page aligned. + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemQueryPageSize( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + size_t size, ///< [in] unaligned allocation size in bytes + size_t* pagesize ///< [out] pointer to page size to use for start address and size + ///< alignments. + ); + __zedlllocal ze_result_t ZE_APICALL + zePhysicalMemCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. + ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. + ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created + ); + __zedlllocal ze_result_t ZE_APICALL + zePhysicalMemDestroy( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_physical_mem_handle_t hPhysicalMemory ///< [in][release] handle of physical memory object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemMap( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of virtual address range to map. + size_t size, ///< [in] size in bytes of virtual address range to map; must be page + ///< aligned. + ze_physical_mem_handle_t hPhysicalMemory, ///< [in] handle to physical memory object. + size_t offset, ///< [in] offset into physical memory allocation object; must be page + ///< aligned. + ze_memory_access_attribute_t access ///< [in] specifies page access attributes to apply to the virtual address + ///< range. + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemUnmap( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of region to unmap. + size_t size ///< [in] size in bytes to unmap; must be page aligned. + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemSetAccessAttribute( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of reserved virtual address region. + size_t size, ///< [in] size in bytes; must be page aligned. + ze_memory_access_attribute_t access ///< [in] specifies page access attributes to apply to the virtual address + ///< range. + ); + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemGetAccessAttribute( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of virtual address region for query. + size_t size, ///< [in] size in bytes; must be page aligned. + ze_memory_access_attribute_t* access, ///< [out] query result for page access attribute. + size_t* outSize ///< [out] query result for size of virtual address range, starting at ptr, + ///< that shares same access attribute. + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetGlobalOffsetExp( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t offsetX, ///< [in] global offset for X dimension to use for this kernel + uint32_t offsetY, ///< [in] global offset for Y dimension to use for this kernel + uint32_t offsetZ ///< [in] global offset for Z dimension to use for this kernel + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetBinaryExp( + ze_kernel_handle_t hKernel, ///< [in] Kernel handle. + size_t* pSize, ///< [in,out] pointer to variable with size of GEN ISA binary. + uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCreateExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + const ze_rtas_builder_ext_desc_t* pDescriptor, ///< [in] pointer to builder descriptor + ze_rtas_builder_ext_handle_t* phBuilder ///< [out] handle of builder object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderGetBuildPropertiesExt( + ze_rtas_builder_ext_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_ext_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + ze_rtas_builder_ext_properties_t* pProperties ///< [in,out] query result for builder properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverRTASFormatCompatibilityCheckExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_format_ext_t rtasFormatA, ///< [in] operand A + ze_rtas_format_ext_t rtasFormatB ///< [in] operand B + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderBuildExt( + ze_rtas_builder_ext_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_ext_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + void* pScratchBuffer, ///< [in][range(0, `scratchBufferSizeBytes`)] scratch buffer to be used + ///< during acceleration structure construction + size_t scratchBufferSizeBytes, ///< [in] size of scratch buffer, in bytes + void* pRtasBuffer, ///< [in] pointer to destination buffer + size_t rtasBufferSizeBytes, ///< [in] destination buffer size, in bytes + ze_rtas_parallel_operation_ext_handle_t hParallelOperation, ///< [in][optional] handle to parallel operation object + void* pBuildUserPtr, ///< [in][optional] pointer passed to callbacks + ze_rtas_aabb_ext_t* pBounds, ///< [in,out][optional] pointer to destination address for acceleration + ///< structure bounds + size_t* pRtasBufferSizeBytes ///< [out][optional] updated acceleration structure size requirement, in + ///< bytes + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCommandListAppendCopyExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination in device memory to copy the ray tracing + ///< acceleration structure to + const void* srcptr, ///< [in] pointer to a valid source ray tracing acceleration structure in + ///< host memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderDestroyExt( + ze_rtas_builder_ext_handle_t hBuilder ///< [in][release] handle of builder object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationCreateExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_parallel_operation_ext_handle_t* phParallelOperation///< [out] handle of parallel operation object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationGetPropertiesExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation, ///< [in] handle of parallel operation object + ze_rtas_parallel_operation_ext_properties_t* pProperties///< [in,out] query result for parallel operation properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationJoinExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation ///< [in] handle of parallel operation object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationDestroyExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetVectorWidthPropertiesExt( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of vector width properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of vector width properties available. + ///< if count is greater than the number of vector width properties + ///< available, then the driver shall update the value with the correct + ///< number of vector width properties available. + ze_device_vector_width_properties_ext_t* pVectorWidthProperties ///< [in,out][optional][range(0, *pCount)] array of vector width properties. + ///< if count is less than the number of properties available, then the + ///< driver will return only the number requested. + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReserveCacheExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + size_t cacheLevel, ///< [in] cache level where application want to reserve. If zero, then the + ///< driver shall default to last level of cache and attempt to reserve in + ///< that cache. + size_t cacheReservationSize ///< [in] value for reserving size, in bytes. If zero, then the driver + ///< shall remove prior reservation + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceSetCacheAdviceExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + void* ptr, ///< [in] memory pointer to query + size_t regionSize, ///< [in] region size, in pages + ze_cache_ext_region_t cacheRegion ///< [in] reservation region + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryTimestampsExp( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of timestamp results. + ///< if count is zero, then the driver shall update the value with the + ///< total number of timestamps available. + ///< if count is greater than the number of timestamps available, then the + ///< driver shall update the value with the correct number of timestamps available. + ze_kernel_timestamp_result_t* pTimestamps ///< [in,out][optional][range(0, *pCount)] array of timestamp results. + ///< if count is less than the number of timestamps available, then driver + ///< shall only retrieve that number of timestamps. + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageGetMemoryPropertiesExp( + ze_image_handle_t hImage, ///< [in] handle of image object + ze_image_memory_properties_exp_t* pMemoryProperties ///< [in,out] query result for image memory properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageViewCreateExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t hImage, ///< [in] handle of image object to create view from + ze_image_handle_t* phImageView ///< [out] pointer to handle of image object created for view + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageViewCreateExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t hImage, ///< [in] handle of image object to create view from + ze_image_handle_t* phImageView ///< [out] pointer to handle of image object created for view + ); + __zedlllocal ze_result_t ZE_APICALL + zeKernelSchedulingHintExp( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_scheduling_hint_exp_desc_t* pHint ///< [in] pointer to kernel scheduling hint descriptor + ); + __zedlllocal ze_result_t ZE_APICALL + zeDevicePciGetPropertiesExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object. + ze_pci_ext_properties_t* pPciProperties ///< [in,out] returns the PCI properties of the device. + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyToMemoryExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + uint32_t destRowPitch, ///< [in] size in bytes of the 1D slice of the 2D region of a 2D or 3D + ///< image or each image of a 1D or 2D image array being written + uint32_t destSlicePitch, ///< [in] size in bytes of the 2D slice of the 3D region of a 3D image or + ///< each image of a 1D or 2D image array being written + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyFromMemoryExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + uint32_t srcRowPitch, ///< [in] size in bytes of the 1D slice of the 2D region of a 2D or 3D + ///< image or each image of a 1D or 2D image array being read + uint32_t srcSlicePitch, ///< [in] size in bytes of the 2D slice of the 3D region of a 3D image or + ///< each image of a 1D or 2D image array being read + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageGetAllocPropertiesExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_image_handle_t hImage, ///< [in] handle of image object to query + ze_image_allocation_ext_properties_t* pImageAllocProperties ///< [in,out] query result for image allocation properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeModuleInspectLinkageExt( + ze_linkage_inspection_ext_desc_t* pInspectDesc, ///< [in] pointer to linkage inspection descriptor structure. + uint32_t numModules, ///< [in] number of modules to be inspected pointed to by phModules. + ze_module_handle_t* phModules, ///< [in][range(0, numModules)] pointer to an array of modules to be + ///< inspected for import dependencies. + ze_module_build_log_handle_t* phLog ///< [out] pointer to handle of linkage inspection log. Log object will + ///< contain separate lists of imports, un-resolvable imports, and exports. + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemFreeExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_memory_free_ext_desc_t* pMemFreeDesc, ///< [in] pointer to memory free descriptor + void* ptr ///< [in][release] pointer to memory to free + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetExp( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of fabric vertices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of fabric vertices available. + ///< if count is greater than the number of fabric vertices available, then + ///< the driver shall update the value with the correct number of fabric + ///< vertices available. + ze_fabric_vertex_handle_t* phVertices ///< [in,out][optional][range(0, *pCount)] array of handle of fabric vertices. + ///< if count is less than the number of fabric vertices available, then + ///< driver shall only retrieve that number of fabric vertices. + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetSubVerticesExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex object + uint32_t* pCount, ///< [in,out] pointer to the number of sub-vertices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub-vertices available. + ///< if count is greater than the number of sub-vertices available, then + ///< the driver shall update the value with the correct number of + ///< sub-vertices available. + ze_fabric_vertex_handle_t* phSubvertices ///< [in,out][optional][range(0, *pCount)] array of handle of sub-vertices. + ///< if count is less than the number of sub-vertices available, then + ///< driver shall only retrieve that number of sub-vertices. + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetPropertiesExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex + ze_fabric_vertex_exp_properties_t* pVertexProperties///< [in,out] query result for fabric vertex properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetDeviceExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex + ze_device_handle_t* phDevice ///< [out] device handle corresponding to fabric vertex + ); + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetFabricVertexExp( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_fabric_vertex_handle_t* phVertex ///< [out] fabric vertex handle corresponding to device + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetExp( + ze_fabric_vertex_handle_t hVertexA, ///< [in] handle of first fabric vertex instance + ze_fabric_vertex_handle_t hVertexB, ///< [in] handle of second fabric vertex instance + uint32_t* pCount, ///< [in,out] pointer to the number of fabric edges. + ///< if count is zero, then the driver shall update the value with the + ///< total number of fabric edges available. + ///< if count is greater than the number of fabric edges available, then + ///< the driver shall update the value with the correct number of fabric + ///< edges available. + ze_fabric_edge_handle_t* phEdges ///< [in,out][optional][range(0, *pCount)] array of handle of fabric edges. + ///< if count is less than the number of fabric edges available, then + ///< driver shall only retrieve that number of fabric edges. + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetVerticesExp( + ze_fabric_edge_handle_t hEdge, ///< [in] handle of the fabric edge instance + ze_fabric_vertex_handle_t* phVertexA, ///< [out] fabric vertex connected to one end of the given fabric edge. + ze_fabric_vertex_handle_t* phVertexB ///< [out] fabric vertex connected to other end of the given fabric edge. + ); + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetPropertiesExp( + ze_fabric_edge_handle_t hEdge, ///< [in] handle of the fabric edge + ze_fabric_edge_exp_properties_t* pEdgeProperties///< [in,out] query result for fabric edge properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in,out][optional][range(0, *pCount)] pointer to event query + ///< properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCreateExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + const ze_rtas_builder_exp_desc_t* pDescriptor, ///< [in] pointer to builder descriptor + ze_rtas_builder_exp_handle_t* phBuilder ///< [out] handle of builder object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderGetBuildPropertiesExp( + ze_rtas_builder_exp_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_exp_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + ze_rtas_builder_exp_properties_t* pProperties ///< [in,out] query result for builder properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeDriverRTASFormatCompatibilityCheckExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_format_exp_t rtasFormatA, ///< [in] operand A + ze_rtas_format_exp_t rtasFormatB ///< [in] operand B + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderBuildExp( + ze_rtas_builder_exp_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_exp_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + void* pScratchBuffer, ///< [in][range(0, `scratchBufferSizeBytes`)] scratch buffer to be used + ///< during acceleration structure construction + size_t scratchBufferSizeBytes, ///< [in] size of scratch buffer, in bytes + void* pRtasBuffer, ///< [in] pointer to destination buffer + size_t rtasBufferSizeBytes, ///< [in] destination buffer size, in bytes + ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in][optional] handle to parallel operation object + void* pBuildUserPtr, ///< [in][optional] pointer passed to callbacks + ze_rtas_aabb_exp_t* pBounds, ///< [in,out][optional] pointer to destination address for acceleration + ///< structure bounds + size_t* pRtasBufferSizeBytes ///< [out][optional] updated acceleration structure size requirement, in + ///< bytes + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderDestroyExp( + ze_rtas_builder_exp_handle_t hBuilder ///< [in][release] handle of builder object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationCreateExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_parallel_operation_exp_handle_t* phParallelOperation///< [out] handle of parallel operation object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationGetPropertiesExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in] handle of parallel operation object + ze_rtas_parallel_operation_exp_properties_t* pProperties///< [in,out] query result for parallel operation properties + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationJoinExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in] handle of parallel operation object + ); + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationDestroyExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zeMemGetPitchFor2dImage( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + size_t imageWidth, ///< [in] imageWidth + size_t imageHeight, ///< [in] imageHeight + unsigned int elementSizeInBytes, ///< [in] Element size in bytes + size_t * rowPitch ///< [out] rowPitch + ); + __zedlllocal ze_result_t ZE_APICALL + zeImageGetDeviceOffsetExp( + ze_image_handle_t hImage, ///< [in] handle of the image + uint64_t* pDeviceOffset ///< [out] bindless device offset for image + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreateCloneExp( + ze_command_list_handle_t hCommandList, ///< [in] handle to source command list (the command list to clone) + ze_command_list_handle_t* phClonedCommandList ///< [out] pointer to handle of the cloned command list + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListImmediateAppendCommandListsExp( + ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list + uint32_t numCommandLists, ///< [in] number of command lists + ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] handles of command lists + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + ///< - if not null, this event is signaled after the completion of all + ///< appended command lists + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing appended + ///< command lists; must be 0 if nullptr == phWaitEvents + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing appended command lists. + ///< - if not null, all wait events must be satisfied prior to the start + ///< of any appended command list(s) + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +__zedlllocal void ZE_APICALL +zeGetGlobalProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetRTASBuilderProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetRTASBuilderExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetRTASParallelOperationProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetRTASParallelOperationExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetDriverProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetDriverExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetDeviceProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetDeviceExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetContextProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetCommandQueueProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetCommandListProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetCommandListExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetEventProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetEventExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetEventPoolProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetFenceProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetImageProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetImageExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetKernelProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetKernelExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetMemProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetMemExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetModuleProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetModuleBuildLogProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetPhysicalMemProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetSamplerProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetVirtualMemProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetFabricEdgeExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zeGetFabricVertexExpProcAddrTableLegacy(); + +#if defined(__cplusplus) +}; +#endif diff --git a/source/loader/ze_ldrddi_driver_ddi.cpp b/source/loader/ze_ldrddi_driver_ddi.cpp new file mode 100644 index 00000000..452ab5b6 --- /dev/null +++ b/source/loader/ze_ldrddi_driver_ddi.cpp @@ -0,0 +1,5775 @@ +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_ldrddi_driver_ddi.cpp + * + */ +#include "ze_loader_internal.h" + +namespace loader_driver_ddi +{ + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetApiVersion + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetApiVersion( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_api_version_t* version ///< [out] api version + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetApiVersion = dditable->Driver->pfnGetApiVersion; + if( nullptr == pfnGetApiVersion ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetApiVersion( hDriver, version ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetProperties + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_driver_properties_t* pDriverProperties ///< [in,out] query result for driver properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Driver->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hDriver, pDriverProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetIpcProperties + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetIpcProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + ze_driver_ipc_properties_t* pIpcProperties ///< [in,out] query result for IPC properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIpcProperties = dditable->Driver->pfnGetIpcProperties; + if( nullptr == pfnGetIpcProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIpcProperties( hDriver, pIpcProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetExtensionProperties + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetExtensionProperties( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of extension properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of extension properties available. + ///< if count is greater than the number of extension properties available, + ///< then the driver shall update the value with the correct number of + ///< extension properties available. + ze_driver_extension_properties_t* pExtensionProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< extension properties. + ///< if count is less than the number of extension properties available, + ///< then driver shall only retrieve that number of extension properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExtensionProperties = dditable->Driver->pfnGetExtensionProperties; + if( nullptr == pfnGetExtensionProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExtensionProperties( hDriver, pCount, pExtensionProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetExtensionFunctionAddress + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetExtensionFunctionAddress( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char* name, ///< [in] extension function name + void** ppFunctionAddress ///< [out] pointer to function pointer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_1) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExtensionFunctionAddress = dditable->Driver->pfnGetExtensionFunctionAddress; + if( nullptr == pfnGetExtensionFunctionAddress ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExtensionFunctionAddress( hDriver, name, ppFunctionAddress ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetLastErrorDescription + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetLastErrorDescription = dditable->Driver->pfnGetLastErrorDescription; + if( nullptr == pfnGetLastErrorDescription ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetLastErrorDescription( hDriver, ppString ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGet + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGet( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of devices available. + ///< if count is greater than the number of devices available, then the + ///< driver shall update the value with the correct number of devices available. + ze_device_handle_t* phDevices ///< [in,out][optional][range(0, *pCount)] array of handle of devices. + ///< if count is less than the number of devices available, then driver + ///< shall only retrieve that number of devices. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGet = dditable->Device->pfnGet; + if( nullptr == pfnGet ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGet( hDriver, pCount, phDevices ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetRootDevice + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetRootDevice( + ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t* phRootDevice ///< [in,out] parent root device. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetRootDevice = dditable->Device->pfnGetRootDevice; + if( nullptr == pfnGetRootDevice ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetRootDevice( hDevice, phRootDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetSubDevices + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetSubDevices( + ze_device_handle_t hDevice, ///< [in] handle of the device object + uint32_t* pCount, ///< [in,out] pointer to the number of sub-devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub-devices available. + ///< if count is greater than the number of sub-devices available, then the + ///< driver shall update the value with the correct number of sub-devices available. + ze_device_handle_t* phSubdevices ///< [in,out][optional][range(0, *pCount)] array of handle of sub-devices. + ///< if count is less than the number of sub-devices available, then driver + ///< shall only retrieve that number of sub-devices. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSubDevices = dditable->Device->pfnGetSubDevices; + if( nullptr == pfnGetSubDevices ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSubDevices( hDevice, pCount, phSubdevices ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_properties_t* pDeviceProperties ///< [in,out] query result for device properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Device->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hDevice, pDeviceProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetComputeProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetComputeProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_compute_properties_t* pComputeProperties ///< [in,out] query result for compute properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetComputeProperties = dditable->Device->pfnGetComputeProperties; + if( nullptr == pfnGetComputeProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetComputeProperties( hDevice, pComputeProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetModuleProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetModuleProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_module_properties_t* pModuleProperties///< [in,out] query result for module properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetModuleProperties = dditable->Device->pfnGetModuleProperties; + if( nullptr == pfnGetModuleProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetModuleProperties( hDevice, pModuleProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetCommandQueueGroupProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetCommandQueueGroupProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of command queue group properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of command queue group properties available. + ///< if count is greater than the number of command queue group properties + ///< available, then the driver shall update the value with the correct + ///< number of command queue group properties available. + ze_command_queue_group_properties_t* pCommandQueueGroupProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< command queue group properties. + ///< if count is less than the number of command queue group properties + ///< available, then driver shall only retrieve that number of command + ///< queue group properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetCommandQueueGroupProperties = dditable->Device->pfnGetCommandQueueGroupProperties; + if( nullptr == pfnGetCommandQueueGroupProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetCommandQueueGroupProperties( hDevice, pCount, pCommandQueueGroupProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetMemoryProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetMemoryProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of memory properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of memory properties available. + ///< if count is greater than the number of memory properties available, + ///< then the driver shall update the value with the correct number of + ///< memory properties available. + ze_device_memory_properties_t* pMemProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< memory properties. + ///< if count is less than the number of memory properties available, then + ///< driver shall only retrieve that number of memory properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetMemoryProperties = dditable->Device->pfnGetMemoryProperties; + if( nullptr == pfnGetMemoryProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetMemoryProperties( hDevice, pCount, pMemProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetMemoryAccessProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetMemoryAccessProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_memory_access_properties_t* pMemAccessProperties ///< [in,out] query result for memory access properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetMemoryAccessProperties = dditable->Device->pfnGetMemoryAccessProperties; + if( nullptr == pfnGetMemoryAccessProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetMemoryAccessProperties( hDevice, pMemAccessProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetCacheProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetCacheProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of cache properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of cache properties available. + ///< if count is greater than the number of cache properties available, + ///< then the driver shall update the value with the correct number of + ///< cache properties available. + ze_device_cache_properties_t* pCacheProperties ///< [in,out][optional][range(0, *pCount)] array of query results for cache properties. + ///< if count is less than the number of cache properties available, then + ///< driver shall only retrieve that number of cache properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetCacheProperties = dditable->Device->pfnGetCacheProperties; + if( nullptr == pfnGetCacheProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetCacheProperties( hDevice, pCount, pCacheProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetImageProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetImageProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_image_properties_t* pImageProperties ///< [in,out] query result for image properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetImageProperties = dditable->Device->pfnGetImageProperties; + if( nullptr == pfnGetImageProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetImageProperties( hDevice, pImageProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetExternalMemoryProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetExternalMemoryProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_device_external_memory_properties_t* pExternalMemoryProperties ///< [in,out] query result for external memory properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExternalMemoryProperties = dditable->Device->pfnGetExternalMemoryProperties; + if( nullptr == pfnGetExternalMemoryProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExternalMemoryProperties( hDevice, pExternalMemoryProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetP2PProperties + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetP2PProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device performing the access + ze_device_handle_t hPeerDevice, ///< [in] handle of the peer device with the allocation + ze_device_p2p_properties_t* pP2PProperties ///< [in,out] Peer-to-Peer properties between source and peer device + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetP2PProperties = dditable->Device->pfnGetP2PProperties; + if( nullptr == pfnGetP2PProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetP2PProperties( hDevice, hPeerDevice, pP2PProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceCanAccessPeer + __zedlllocal ze_result_t ZE_APICALL + zeDeviceCanAccessPeer( + ze_device_handle_t hDevice, ///< [in] handle of the device performing the access + ze_device_handle_t hPeerDevice, ///< [in] handle of the peer device with the allocation + ze_bool_t* value ///< [out] returned access capability + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCanAccessPeer = dditable->Device->pfnCanAccessPeer; + if( nullptr == pfnCanAccessPeer ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCanAccessPeer( hDevice, hPeerDevice, value ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetStatus + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetStatus( + ze_device_handle_t hDevice ///< [in] handle of the device + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetStatus = dditable->Device->pfnGetStatus; + if( nullptr == pfnGetStatus ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetStatus( hDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetGlobalTimestamps + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetGlobalTimestamps( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the + ///< Device's global timestamp value. + uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the + ///< Host's global timestamp value. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_1) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetGlobalTimestamps = dditable->Device->pfnGetGlobalTimestamps; + if( nullptr == pfnGetGlobalTimestamps ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetGlobalTimestamps( hDevice, hostTimestamp, deviceTimestamp ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextCreate + __zedlllocal ze_result_t ZE_APICALL + zeContextCreate( + ze_driver_handle_t hDriver, ///< [in] handle of the driver object + const ze_context_desc_t* desc, ///< [in] pointer to context descriptor + ze_context_handle_t* phContext ///< [out] pointer to handle of context object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Context->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hDriver, desc, phContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextCreateEx + __zedlllocal ze_result_t ZE_APICALL + zeContextCreateEx( + ze_driver_handle_t hDriver, ///< [in] handle of the driver object + const ze_context_desc_t* desc, ///< [in] pointer to context descriptor + uint32_t numDevices, ///< [in][optional] number of device handles; must be 0 if `nullptr == + ///< phDevices` + ze_device_handle_t* phDevices, ///< [in][optional][range(0, numDevices)] array of device handles which + ///< context has visibility. + ///< if nullptr, then all devices and any sub-devices supported by the + ///< driver instance are + ///< visible to the context. + ///< otherwise, the context only has visibility to the devices and any + ///< sub-devices of the + ///< devices in this array. + ze_context_handle_t* phContext ///< [out] pointer to handle of context object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_1) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateEx = dditable->Context->pfnCreateEx; + if( nullptr == pfnCreateEx ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateEx( hDriver, desc, numDevices, phDevices, phContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextDestroy + __zedlllocal ze_result_t ZE_APICALL + zeContextDestroy( + ze_context_handle_t hContext ///< [in][release] handle of context object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Context->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextGetStatus + __zedlllocal ze_result_t ZE_APICALL + zeContextGetStatus( + ze_context_handle_t hContext ///< [in] handle of context object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetStatus = dditable->Context->pfnGetStatus; + if( nullptr == pfnGetStatus ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetStatus( hContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueCreate + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_queue_desc_t* desc, ///< [in] pointer to command queue descriptor + ze_command_queue_handle_t* phCommandQueue ///< [out] pointer to handle of command queue object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->CommandQueue->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phCommandQueue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueDestroy + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueDestroy( + ze_command_queue_handle_t hCommandQueue ///< [in][release] handle of command queue object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->CommandQueue->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hCommandQueue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueExecuteCommandLists + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueExecuteCommandLists( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t numCommandLists, ///< [in] number of command lists to execute + ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] list of handles of the command lists + ///< to execute + ze_fence_handle_t hFence ///< [in][optional] handle of the fence to signal on completion + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnExecuteCommandLists = dditable->CommandQueue->pfnExecuteCommandLists; + if( nullptr == pfnExecuteCommandLists ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnExecuteCommandLists( hCommandQueue, numCommandLists, phCommandLists, hFence ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueSynchronize( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the command queue; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSynchronize = dditable->CommandQueue->pfnSynchronize; + if( nullptr == pfnSynchronize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSynchronize( hCommandQueue, timeout ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueGetOrdinal + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueGetOrdinal( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t* pOrdinal ///< [out] command queue group ordinal + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetOrdinal = dditable->CommandQueue->pfnGetOrdinal; + if( nullptr == pfnGetOrdinal ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetOrdinal( hCommandQueue, pOrdinal ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandQueueGetIndex + __zedlllocal ze_result_t ZE_APICALL + zeCommandQueueGetIndex( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of the command queue + uint32_t* pIndex ///< [out] command queue index within the group + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIndex = dditable->CommandQueue->pfnGetIndex; + if( nullptr == pfnGetIndex ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIndex( hCommandQueue, pIndex ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListCreate + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_list_desc_t* desc, ///< [in] pointer to command list descriptor + ze_command_list_handle_t* phCommandList ///< [out] pointer to handle of command list object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->CommandList->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListCreateImmediate + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreateImmediate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + const ze_command_queue_desc_t* altdesc, ///< [in] pointer to command queue descriptor + ze_command_list_handle_t* phCommandList ///< [out] pointer to handle of command list object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateImmediate = dditable->CommandList->pfnCreateImmediate; + if( nullptr == pfnCreateImmediate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateImmediate( hContext, hDevice, altdesc, phCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListDestroy + __zedlllocal ze_result_t ZE_APICALL + zeCommandListDestroy( + ze_command_list_handle_t hCommandList ///< [in][release] handle of command list object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->CommandList->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListClose + __zedlllocal ze_result_t ZE_APICALL + zeCommandListClose( + ze_command_list_handle_t hCommandList ///< [in] handle of command list object to close + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnClose = dditable->CommandList->pfnClose; + if( nullptr == pfnClose ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnClose( hCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListReset + __zedlllocal ze_result_t ZE_APICALL + zeCommandListReset( + ze_command_list_handle_t hCommandList ///< [in] handle of command list object to reset + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReset = dditable->CommandList->pfnReset; + if( nullptr == pfnReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReset( hCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWriteGlobalTimestamp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWriteGlobalTimestamp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t* dstptr, ///< [in,out] pointer to memory where timestamp value will be written; must + ///< be 8byte-aligned. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing query; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendWriteGlobalTimestamp = dditable->CommandList->pfnAppendWriteGlobalTimestamp; + if( nullptr == pfnAppendWriteGlobalTimestamp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendWriteGlobalTimestamp( hCommandList, dstptr, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnHostSynchronize = dditable->CommandList->pfnHostSynchronize; + if( nullptr == pfnHostSynchronize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnHostSynchronize( hCommandList, timeout ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetDeviceHandle + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetDeviceHandle( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_device_handle_t* phDevice ///< [out] handle of the device on which the command list was created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDeviceHandle = dditable->CommandList->pfnGetDeviceHandle; + if( nullptr == pfnGetDeviceHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDeviceHandle( hCommandList, phDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetContextHandle + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetContextHandle( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_context_handle_t* phContext ///< [out] handle of the context on which the command list was created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetContextHandle = dditable->CommandList->pfnGetContextHandle; + if( nullptr == pfnGetContextHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetContextHandle( hCommandList, phContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetOrdinal + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetOrdinal( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t* pOrdinal ///< [out] command queue group ordinal to which command list is submitted + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetOrdinal = dditable->CommandList->pfnGetOrdinal; + if( nullptr == pfnGetOrdinal ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetOrdinal( hCommandList, pOrdinal ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListImmediateGetIndex + __zedlllocal ze_result_t ZE_APICALL + zeCommandListImmediateGetIndex( + ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list + uint32_t* pIndex ///< [out] command queue index within the group to which the immediate + ///< command list is submitted + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandListImmediate )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnImmediateGetIndex = dditable->CommandList->pfnImmediateGetIndex; + if( nullptr == pfnImmediateGetIndex ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnImmediateGetIndex( hCommandListImmediate, pIndex ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListIsImmediate + __zedlllocal ze_result_t ZE_APICALL + zeCommandListIsImmediate( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_bool_t* pIsImmediate ///< [out] Boolean indicating whether the command list is an immediate + ///< command list (true) or not (false) + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnIsImmediate = dditable->CommandList->pfnIsImmediate; + if( nullptr == pfnIsImmediate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnIsImmediate( hCommandList, pIsImmediate ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendBarrier + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendBarrier( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing barrier; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing barrier + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendBarrier = dditable->CommandList->pfnAppendBarrier; + if( nullptr == pfnAppendBarrier ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendBarrier( hCommandList, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryRangesBarrier + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryRangesBarrier( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numRanges, ///< [in] number of memory ranges + const size_t* pRangeSizes, ///< [in][range(0, numRanges)] array of sizes of memory range + const void** pRanges, ///< [in][range(0, numRanges)] array of memory ranges + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing barrier; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing barrier + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryRangesBarrier = dditable->CommandList->pfnAppendMemoryRangesBarrier; + if( nullptr == pfnAppendMemoryRangesBarrier ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryRangesBarrier( hCommandList, numRanges, pRangeSizes, pRanges, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextSystemBarrier + __zedlllocal ze_result_t ZE_APICALL + zeContextSystemBarrier( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice ///< [in] handle of the device + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSystemBarrier = dditable->Context->pfnSystemBarrier; + if( nullptr == pfnSystemBarrier ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSystemBarrier( hContext, hDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryCopy + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopy( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryCopy = dditable->CommandList->pfnAppendMemoryCopy; + if( nullptr == pfnAppendMemoryCopy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryCopy( hCommandList, dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryFill + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryFill( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* ptr, ///< [in] pointer to memory to initialize + const void* pattern, ///< [in] pointer to value to initialize memory to + size_t pattern_size, ///< [in] size in bytes of the value to initialize memory to + size_t size, ///< [in] size in bytes to initialize + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryFill = dditable->CommandList->pfnAppendMemoryFill; + if( nullptr == pfnAppendMemoryFill ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryFill( hCommandList, ptr, pattern, pattern_size, size, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryCopyRegion + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopyRegion( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + const ze_copy_region_t* dstRegion, ///< [in] pointer to destination region to copy to + uint32_t dstPitch, ///< [in] destination pitch in bytes + uint32_t dstSlicePitch, ///< [in] destination slice pitch in bytes. This is required for 3D region + ///< copies where the `depth` member of ::ze_copy_region_t is not 0, + ///< otherwise it's ignored. + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_copy_region_t* srcRegion, ///< [in] pointer to source region to copy from + uint32_t srcPitch, ///< [in] source pitch in bytes + uint32_t srcSlicePitch, ///< [in] source slice pitch in bytes. This is required for 3D region + ///< copies where the `depth` member of ::ze_copy_region_t is not 0, + ///< otherwise it's ignored. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryCopyRegion = dditable->CommandList->pfnAppendMemoryCopyRegion; + if( nullptr == pfnAppendMemoryCopyRegion ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryCopyRegion( hCommandList, dstptr, dstRegion, dstPitch, dstSlicePitch, srcptr, srcRegion, srcPitch, srcSlicePitch, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryCopyFromContext + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryCopyFromContext( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_context_handle_t hContextSrc, ///< [in] handle of source context object + const void* srcptr, ///< [in] pointer to source memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryCopyFromContext = dditable->CommandList->pfnAppendMemoryCopyFromContext; + if( nullptr == pfnAppendMemoryCopyFromContext ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryCopyFromContext( hCommandList, dstptr, hContextSrc, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopy + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopy( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopy = dditable->CommandList->pfnAppendImageCopy; + if( nullptr == pfnAppendImageCopy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopy( hCommandList, hDstImage, hSrcImage, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopyRegion + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyRegion( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopyRegion = dditable->CommandList->pfnAppendImageCopyRegion; + if( nullptr == pfnAppendImageCopyRegion ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopyRegion( hCommandList, hDstImage, hSrcImage, pDstRegion, pSrcRegion, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopyToMemory + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyToMemory( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopyToMemory = dditable->CommandList->pfnAppendImageCopyToMemory; + if( nullptr == pfnAppendImageCopyToMemory ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopyToMemory( hCommandList, dstptr, hSrcImage, pSrcRegion, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopyFromMemory + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyFromMemory( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopyFromMemory = dditable->CommandList->pfnAppendImageCopyFromMemory; + if( nullptr == pfnAppendImageCopyFromMemory ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopyFromMemory( hCommandList, hDstImage, srcptr, pDstRegion, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemoryPrefetch + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemoryPrefetch( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + const void* ptr, ///< [in] pointer to start of the memory range to prefetch + size_t size ///< [in] size in bytes of the memory range to prefetch + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemoryPrefetch = dditable->CommandList->pfnAppendMemoryPrefetch; + if( nullptr == pfnAppendMemoryPrefetch ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemoryPrefetch( hCommandList, ptr, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendMemAdvise + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendMemAdvise( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_advice_t advice ///< [in] Memory advice for the memory range + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMemAdvise = dditable->CommandList->pfnAppendMemAdvise; + if( nullptr == pfnAppendMemAdvise ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMemAdvise( hCommandList, hDevice, ptr, size, advice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolCreate + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_event_pool_desc_t* desc, ///< [in] pointer to event pool descriptor + uint32_t numDevices, ///< [in][optional] number of device handles; must be 0 if `nullptr == + ///< phDevices` + ze_device_handle_t* phDevices, ///< [in][optional][range(0, numDevices)] array of device handles which + ///< have visibility to the event pool. + ///< if nullptr, then event pool is visible to all devices supported by the + ///< driver instance. + ze_event_pool_handle_t* phEventPool ///< [out] pointer handle of event pool object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->EventPool->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, desc, numDevices, phDevices, phEventPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolDestroy + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolDestroy( + ze_event_pool_handle_t hEventPool ///< [in][release] handle of event pool object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->EventPool->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hEventPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventCreate + __zedlllocal ze_result_t ZE_APICALL + zeEventCreate( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + const ze_event_desc_t* desc, ///< [in] pointer to event descriptor + ze_event_handle_t* phEvent ///< [out] pointer to handle of event object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Event->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hEventPool, desc, phEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventDestroy + __zedlllocal ze_result_t ZE_APICALL + zeEventDestroy( + ze_event_handle_t hEvent ///< [in][release] handle of event object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Event->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolGetIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetIpcHandle( + ze_event_pool_handle_t hEventPool, ///< [in] handle of event pool object + ze_ipc_event_pool_handle_t* phIpc ///< [out] Returned IPC event handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIpcHandle = dditable->EventPool->pfnGetIpcHandle; + if( nullptr == pfnGetIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIpcHandle( hEventPool, phIpc ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPutIpcHandle = dditable->EventPool->pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPutIpcHandle( hContext, hIpc ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolOpenIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolOpenIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object to associate with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc, ///< [in] IPC event pool handle + ze_event_pool_handle_t* phEventPool ///< [out] pointer handle of event pool object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOpenIpcHandle = dditable->EventPool->pfnOpenIpcHandle; + if( nullptr == pfnOpenIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOpenIpcHandle( hContext, hIpc, phEventPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolCloseIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolCloseIpcHandle( + ze_event_pool_handle_t hEventPool ///< [in][release] handle of event pool object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCloseIpcHandle = dditable->EventPool->pfnCloseIpcHandle; + if( nullptr == pfnCloseIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCloseIpcHandle( hEventPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalEvent + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalEvent( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hEvent ///< [in] handle of the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendSignalEvent = dditable->CommandList->pfnAppendSignalEvent; + if( nullptr == pfnAppendSignalEvent ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendSignalEvent( hCommandList, hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitOnEvents + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitOnEvents( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numEvents, ///< [in] number of events to wait on before continuing + ze_event_handle_t* phEvents ///< [in][range(0, numEvents)] handles of the events to wait on before + ///< continuing + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendWaitOnEvents = dditable->CommandList->pfnAppendWaitOnEvents; + if( nullptr == pfnAppendWaitOnEvents ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendWaitOnEvents( hCommandList, numEvents, phEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventHostSignal + __zedlllocal ze_result_t ZE_APICALL + zeEventHostSignal( + ze_event_handle_t hEvent ///< [in] handle of the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnHostSignal = dditable->Event->pfnHostSignal; + if( nullptr == pfnHostSignal ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnHostSignal( hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeEventHostSynchronize( + ze_event_handle_t hEvent, ///< [in] handle of the event + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then operates exactly like ::zeEventQueryStatus; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnHostSynchronize = dditable->Event->pfnHostSynchronize; + if( nullptr == pfnHostSynchronize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnHostSynchronize( hEvent, timeout ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryStatus + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryStatus( + ze_event_handle_t hEvent ///< [in] handle of the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryStatus = dditable->Event->pfnQueryStatus; + if( nullptr == pfnQueryStatus ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryStatus( hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendEventReset + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendEventReset( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_event_handle_t hEvent ///< [in] handle of the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendEventReset = dditable->CommandList->pfnAppendEventReset; + if( nullptr == pfnAppendEventReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendEventReset( hCommandList, hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventHostReset + __zedlllocal ze_result_t ZE_APICALL + zeEventHostReset( + ze_event_handle_t hEvent ///< [in] handle of the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnHostReset = dditable->Event->pfnHostReset; + if( nullptr == pfnHostReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnHostReset( hEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestamp + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestamp( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_kernel_timestamp_result_t* dstptr ///< [in,out] pointer to memory for where timestamp result will be written. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryKernelTimestamp = dditable->Event->pfnQueryKernelTimestamp; + if( nullptr == pfnQueryKernelTimestamp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryKernelTimestamp( hEvent, dstptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendQueryKernelTimestamps + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendQueryKernelTimestamps( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numEvents, ///< [in] the number of timestamp events to query + ze_event_handle_t* phEvents, ///< [in][range(0, numEvents)] handles of timestamp events to query + void* dstptr, ///< [in,out] pointer to memory where ::ze_kernel_timestamp_result_t will + ///< be written; must be size-aligned. + const size_t* pOffsets, ///< [in][optional][range(0, numEvents)] offset, in bytes, to write + ///< results; address must be 4byte-aligned and offsets must be + ///< size-aligned. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing query; + ///< must be 0 if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendQueryKernelTimestamps = dditable->CommandList->pfnAppendQueryKernelTimestamps; + if( nullptr == pfnAppendQueryKernelTimestamps ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendQueryKernelTimestamps( hCommandList, numEvents, phEvents, dstptr, pOffsets, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventGetEventPool + __zedlllocal ze_result_t ZE_APICALL + zeEventGetEventPool( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_pool_handle_t* phEventPool ///< [out] handle of the event pool for the event + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetEventPool = dditable->Event->pfnGetEventPool; + if( nullptr == pfnGetEventPool ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetEventPool( hEvent, phEventPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventGetSignalScope + __zedlllocal ze_result_t ZE_APICALL + zeEventGetSignalScope( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_scope_flags_t* pSignalScope ///< [out] signal event scope. This is the scope of relevant cache + ///< hierarchies that are flushed on a signal action before the event is + ///< triggered. May be 0 or a valid combination of ::ze_event_scope_flag_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSignalScope = dditable->Event->pfnGetSignalScope; + if( nullptr == pfnGetSignalScope ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSignalScope( hEvent, pSignalScope ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventGetWaitScope + __zedlllocal ze_result_t ZE_APICALL + zeEventGetWaitScope( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_event_scope_flags_t* pWaitScope ///< [out] wait event scope. This is the scope of relevant cache + ///< hierarchies invalidated on a wait action after the event is complete. + ///< May be 0 or a valid combination of ::ze_event_scope_flag_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetWaitScope = dditable->Event->pfnGetWaitScope; + if( nullptr == pfnGetWaitScope ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetWaitScope( hEvent, pWaitScope ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolGetContextHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetContextHandle( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + ze_context_handle_t* phContext ///< [out] handle of the context on which the event pool was created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetContextHandle = dditable->EventPool->pfnGetContextHandle; + if( nullptr == pfnGetContextHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetContextHandle( hEventPool, phContext ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolGetFlags + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolGetFlags( + ze_event_pool_handle_t hEventPool, ///< [in] handle of the event pool + ze_event_pool_flags_t* pFlags ///< [out] creation flags used to create the event pool; may be 0 or a + ///< valid combination of ::ze_event_pool_flag_t + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEventPool )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFlags = dditable->EventPool->pfnGetFlags; + if( nullptr == pfnGetFlags ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFlags( hEventPool, pFlags ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFenceCreate + __zedlllocal ze_result_t ZE_APICALL + zeFenceCreate( + ze_command_queue_handle_t hCommandQueue, ///< [in] handle of command queue + const ze_fence_desc_t* desc, ///< [in] pointer to fence descriptor + ze_fence_handle_t* phFence ///< [out] pointer to handle of fence object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandQueue )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Fence->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hCommandQueue, desc, phFence ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFenceDestroy + __zedlllocal ze_result_t ZE_APICALL + zeFenceDestroy( + ze_fence_handle_t hFence ///< [in][release] handle of fence object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFence )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Fence->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hFence ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFenceHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeFenceHostSynchronize( + ze_fence_handle_t hFence, ///< [in] handle of the fence + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then operates exactly like ::zeFenceQueryStatus; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFence )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnHostSynchronize = dditable->Fence->pfnHostSynchronize; + if( nullptr == pfnHostSynchronize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnHostSynchronize( hFence, timeout ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFenceQueryStatus + __zedlllocal ze_result_t ZE_APICALL + zeFenceQueryStatus( + ze_fence_handle_t hFence ///< [in] handle of the fence + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFence )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryStatus = dditable->Fence->pfnQueryStatus; + if( nullptr == pfnQueryStatus ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryStatus( hFence ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFenceReset + __zedlllocal ze_result_t ZE_APICALL + zeFenceReset( + ze_fence_handle_t hFence ///< [in] handle of the fence + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFence )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReset = dditable->Fence->pfnReset; + if( nullptr == pfnReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReset( hFence ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageGetProperties + __zedlllocal ze_result_t ZE_APICALL + zeImageGetProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_properties_t* pImageProperties ///< [out] pointer to image properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Image->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hDevice, desc, pImageProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageCreate + __zedlllocal ze_result_t ZE_APICALL + zeImageCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t* phImage ///< [out] pointer to handle of image object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Image->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phImage ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageDestroy + __zedlllocal ze_result_t ZE_APICALL + zeImageDestroy( + ze_image_handle_t hImage ///< [in][release] handle of image object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hImage )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Image->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hImage ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemAllocShared + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocShared( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_device_mem_alloc_desc_t* device_desc, ///< [in] pointer to device memory allocation descriptor + const ze_host_mem_alloc_desc_t* host_desc, ///< [in] pointer to host memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + ze_device_handle_t hDevice, ///< [in][optional] device handle to associate with + void** pptr ///< [out] pointer to shared allocation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAllocShared = dditable->Mem->pfnAllocShared; + if( nullptr == pfnAllocShared ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAllocShared( hContext, device_desc, host_desc, size, alignment, hDevice, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemAllocDevice + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocDevice( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_device_mem_alloc_desc_t* device_desc, ///< [in] pointer to device memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + ze_device_handle_t hDevice, ///< [in] handle of the device + void** pptr ///< [out] pointer to device allocation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAllocDevice = dditable->Mem->pfnAllocDevice; + if( nullptr == pfnAllocDevice ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAllocDevice( hContext, device_desc, size, alignment, hDevice, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemAllocHost + __zedlllocal ze_result_t ZE_APICALL + zeMemAllocHost( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_host_mem_alloc_desc_t* host_desc, ///< [in] pointer to host memory allocation descriptor + size_t size, ///< [in] size in bytes to allocate; must be less than or equal to the + ///< `maxMemAllocSize` member of ::ze_device_properties_t + size_t alignment, ///< [in] minimum alignment in bytes for the allocation; must be a power of + ///< two + void** pptr ///< [out] pointer to host allocation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAllocHost = dditable->Mem->pfnAllocHost; + if( nullptr == pfnAllocHost ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAllocHost( hContext, host_desc, size, alignment, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemFree + __zedlllocal ze_result_t ZE_APICALL + zeMemFree( + ze_context_handle_t hContext, ///< [in] handle of the context object + void* ptr ///< [in][release] pointer to memory to free + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnFree = dditable->Mem->pfnFree; + if( nullptr == pfnFree ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnFree( hContext, ptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetAllocProperties + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAllocProperties( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] memory pointer to query + ze_memory_allocation_properties_t* pMemAllocProperties, ///< [in,out] query result for memory allocation properties + ze_device_handle_t* phDevice ///< [out][optional] device associated with this allocation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAllocProperties = dditable->Mem->pfnGetAllocProperties; + if( nullptr == pfnGetAllocProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAllocProperties( hContext, ptr, pMemAllocProperties, phDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetAddressRange + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAddressRange( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] memory pointer to query + void** pBase, ///< [in,out][optional] base address of the allocation + size_t* pSize ///< [in,out][optional] size of the allocation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAddressRange = dditable->Mem->pfnGetAddressRange; + if( nullptr == pfnGetAddressRange ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAddressRange( hContext, ptr, pBase, pSize ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to the device memory allocation + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIpcHandle = dditable->Mem->pfnGetIpcHandle; + if( nullptr == pfnGetIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIpcHandle( hContext, ptr, pIpcHandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandleFromFileDescriptorExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIpcHandleFromFileDescriptorExp = dditable->MemExp->pfnGetIpcHandleFromFileDescriptorExp; + if( nullptr == pfnGetIpcHandleFromFileDescriptorExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetFileDescriptorFromIpcHandleExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFileDescriptorFromIpcHandleExp = dditable->MemExp->pfnGetFileDescriptorFromIpcHandleExp; + if( nullptr == pfnGetFileDescriptorFromIpcHandleExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPutIpcHandle = dditable->Mem->pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPutIpcHandle( hContext, handle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemOpenIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemOpenIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device to associate with the IPC memory handle + ze_ipc_mem_handle_t handle, ///< [in] IPC memory handle + ze_ipc_memory_flags_t flags, ///< [in] flags controlling the operation. + ///< must be 0 (default) or a valid combination of ::ze_ipc_memory_flag_t. + void** pptr ///< [out] pointer to device allocation in this process + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOpenIpcHandle = dditable->Mem->pfnOpenIpcHandle; + if( nullptr == pfnOpenIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOpenIpcHandle( hContext, hDevice, handle, flags, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemCloseIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemCloseIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr ///< [in][release] pointer to device allocation in this process + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCloseIpcHandle = dditable->Mem->pfnCloseIpcHandle; + if( nullptr == pfnCloseIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCloseIpcHandle( hContext, ptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemSetAtomicAccessAttributeExp + __zedlllocal ze_result_t ZE_APICALL + zeMemSetAtomicAccessAttributeExp( + ze_context_handle_t hContext, ///< [in] handle of context + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_atomic_attr_exp_flags_t attr ///< [in] Atomic access attributes to set for the specified range. + ///< Must be 0 (default) or a valid combination of ::ze_memory_atomic_attr_exp_flag_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetAtomicAccessAttributeExp = dditable->MemExp->pfnSetAtomicAccessAttributeExp; + if( nullptr == pfnSetAtomicAccessAttributeExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetAtomicAccessAttributeExp( hContext, hDevice, ptr, size, attr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetAtomicAccessAttributeExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetAtomicAccessAttributeExp( + ze_context_handle_t hContext, ///< [in] handle of context + ze_device_handle_t hDevice, ///< [in] device associated with the memory advice + const void* ptr, ///< [in] Pointer to the start of the memory range + size_t size, ///< [in] Size in bytes of the memory range + ze_memory_atomic_attr_exp_flags_t* pAttr ///< [out] Atomic access attributes for the specified range + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAtomicAccessAttributeExp = dditable->MemExp->pfnGetAtomicAccessAttributeExp; + if( nullptr == pfnGetAtomicAccessAttributeExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAtomicAccessAttributeExp( hContext, hDevice, ptr, size, pAttr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleCreate + __zedlllocal ze_result_t ZE_APICALL + zeModuleCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_module_desc_t* desc, ///< [in] pointer to module descriptor + ze_module_handle_t* phModule, ///< [out] pointer to handle of module object created + ze_module_build_log_handle_t* phBuildLog ///< [out][optional] pointer to handle of module's build log. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Module->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phModule, phBuildLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleDestroy + __zedlllocal ze_result_t ZE_APICALL + zeModuleDestroy( + ze_module_handle_t hModule ///< [in][release] handle of the module + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Module->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hModule ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleDynamicLink + __zedlllocal ze_result_t ZE_APICALL + zeModuleDynamicLink( + uint32_t numModules, ///< [in] number of modules to be linked pointed to by phModules. + ze_module_handle_t* phModules, ///< [in][range(0, numModules)] pointer to an array of modules to + ///< dynamically link together. + ze_module_build_log_handle_t* phLinkLog ///< [out][optional] pointer to handle of dynamic link log. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( phModules[ 0 ] )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDynamicLink = dditable->Module->pfnDynamicLink; + if( nullptr == pfnDynamicLink ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDynamicLink( numModules, phModules, phLinkLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleBuildLogDestroy + __zedlllocal ze_result_t ZE_APICALL + zeModuleBuildLogDestroy( + ze_module_build_log_handle_t hModuleBuildLog ///< [in][release] handle of the module build log object. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModuleBuildLog )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->ModuleBuildLog->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hModuleBuildLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleBuildLogGetString + __zedlllocal ze_result_t ZE_APICALL + zeModuleBuildLogGetString( + ze_module_build_log_handle_t hModuleBuildLog, ///< [in] handle of the module build log object. + size_t* pSize, ///< [in,out] size of build log string. + char* pBuildLog ///< [in,out][optional] pointer to null-terminated string of the log. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModuleBuildLog )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetString = dditable->ModuleBuildLog->pfnGetString; + if( nullptr == pfnGetString ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetString( hModuleBuildLog, pSize, pBuildLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleGetNativeBinary + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetNativeBinary( + ze_module_handle_t hModule, ///< [in] handle of the module + size_t* pSize, ///< [in,out] size of native binary in bytes. + uint8_t* pModuleNativeBinary ///< [in,out][optional] byte pointer to native binary + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetNativeBinary = dditable->Module->pfnGetNativeBinary; + if( nullptr == pfnGetNativeBinary ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetNativeBinary( hModule, pSize, pModuleNativeBinary ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleGetGlobalPointer + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetGlobalPointer( + ze_module_handle_t hModule, ///< [in] handle of the module + const char* pGlobalName, ///< [in] name of global variable in module + size_t* pSize, ///< [in,out][optional] size of global variable + void** pptr ///< [in,out][optional] device visible pointer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetGlobalPointer = dditable->Module->pfnGetGlobalPointer; + if( nullptr == pfnGetGlobalPointer ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetGlobalPointer( hModule, pGlobalName, pSize, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleGetKernelNames + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetKernelNames( + ze_module_handle_t hModule, ///< [in] handle of the module + uint32_t* pCount, ///< [in,out] pointer to the number of names. + ///< if count is zero, then the driver shall update the value with the + ///< total number of names available. + ///< if count is greater than the number of names available, then the + ///< driver shall update the value with the correct number of names available. + const char** pNames ///< [in,out][optional][range(0, *pCount)] array of names of functions. + ///< if count is less than the number of names available, then driver shall + ///< only retrieve that number of names. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetKernelNames = dditable->Module->pfnGetKernelNames; + if( nullptr == pfnGetKernelNames ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetKernelNames( hModule, pCount, pNames ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleGetProperties + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetProperties( + ze_module_handle_t hModule, ///< [in] handle of the module + ze_module_properties_t* pModuleProperties ///< [in,out] query result for module properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Module->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hModule, pModuleProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelCreate + __zedlllocal ze_result_t ZE_APICALL + zeKernelCreate( + ze_module_handle_t hModule, ///< [in] handle of the module + const ze_kernel_desc_t* desc, ///< [in] pointer to kernel descriptor + ze_kernel_handle_t* phKernel ///< [out] handle of the Function object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Kernel->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hModule, desc, phKernel ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelDestroy + __zedlllocal ze_result_t ZE_APICALL + zeKernelDestroy( + ze_kernel_handle_t hKernel ///< [in][release] handle of the kernel object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Kernel->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hKernel ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleGetFunctionPointer + __zedlllocal ze_result_t ZE_APICALL + zeModuleGetFunctionPointer( + ze_module_handle_t hModule, ///< [in] handle of the module + const char* pFunctionName, ///< [in] Name of function to retrieve function pointer for. + void** pfnFunction ///< [out] pointer to function. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFunctionPointer = dditable->Module->pfnGetFunctionPointer; + if( nullptr == pfnGetFunctionPointer ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFunctionPointer( hModule, pFunctionName, pfnFunction ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSetGroupSize + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetGroupSize( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t groupSizeX, ///< [in] group size for X dimension to use for this kernel + uint32_t groupSizeY, ///< [in] group size for Y dimension to use for this kernel + uint32_t groupSizeZ ///< [in] group size for Z dimension to use for this kernel + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetGroupSize = dditable->Kernel->pfnSetGroupSize; + if( nullptr == pfnSetGroupSize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetGroupSize( hKernel, groupSizeX, groupSizeY, groupSizeZ ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSuggestGroupSize + __zedlllocal ze_result_t ZE_APICALL + zeKernelSuggestGroupSize( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t globalSizeX, ///< [in] global width for X dimension + uint32_t globalSizeY, ///< [in] global width for Y dimension + uint32_t globalSizeZ, ///< [in] global width for Z dimension + uint32_t* groupSizeX, ///< [out] recommended size of group for X dimension + uint32_t* groupSizeY, ///< [out] recommended size of group for Y dimension + uint32_t* groupSizeZ ///< [out] recommended size of group for Z dimension + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSuggestGroupSize = dditable->Kernel->pfnSuggestGroupSize; + if( nullptr == pfnSuggestGroupSize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSuggestGroupSize( hKernel, globalSizeX, globalSizeY, globalSizeZ, groupSizeX, groupSizeY, groupSizeZ ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSuggestMaxCooperativeGroupCount + __zedlllocal ze_result_t ZE_APICALL + zeKernelSuggestMaxCooperativeGroupCount( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t* totalGroupCount ///< [out] recommended total group count. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSuggestMaxCooperativeGroupCount = dditable->Kernel->pfnSuggestMaxCooperativeGroupCount; + if( nullptr == pfnSuggestMaxCooperativeGroupCount ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSuggestMaxCooperativeGroupCount( hKernel, totalGroupCount ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSetArgumentValue + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetArgumentValue( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t argIndex, ///< [in] argument index in range [0, num args - 1] + size_t argSize, ///< [in] size of argument type + const void* pArgValue ///< [in][optional] argument value represented as matching arg type. If + ///< null then argument value is considered null. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetArgumentValue = dditable->Kernel->pfnSetArgumentValue; + if( nullptr == pfnSetArgumentValue ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetArgumentValue( hKernel, argIndex, argSize, pArgValue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSetIndirectAccess + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetIndirectAccess( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_indirect_access_flags_t flags ///< [in] kernel indirect access flags + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetIndirectAccess = dditable->Kernel->pfnSetIndirectAccess; + if( nullptr == pfnSetIndirectAccess ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetIndirectAccess( hKernel, flags ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelGetIndirectAccess + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetIndirectAccess( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_indirect_access_flags_t* pFlags ///< [out] query result for kernel indirect access flags. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetIndirectAccess = dditable->Kernel->pfnGetIndirectAccess; + if( nullptr == pfnGetIndirectAccess ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetIndirectAccess( hKernel, pFlags ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelGetSourceAttributes + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetSourceAttributes( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. Otherwise, pString + ///< must point to valid application memory that is greater than or equal + ///< to *pSize bytes in length, and on return the pointed-to string will + ///< contain a space-separated list of kernel source attributes. Note: This + ///< API was originally intended to ship with a char *pString, however this + ///< typo was introduced. Thus the API has to stay this way for backwards + ///< compatible reasons. It can be corrected in v2.0. Suggestion is to + ///< create your own char *pString and then pass to this API with &pString. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSourceAttributes = dditable->Kernel->pfnGetSourceAttributes; + if( nullptr == pfnGetSourceAttributes ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSourceAttributes( hKernel, pSize, pString ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSetCacheConfig + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetCacheConfig( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_cache_config_flags_t flags ///< [in] cache configuration. + ///< must be 0 (default configuration) or a valid combination of ::ze_cache_config_flag_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetCacheConfig = dditable->Kernel->pfnSetCacheConfig; + if( nullptr == pfnSetCacheConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetCacheConfig( hKernel, flags ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelGetProperties + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetProperties( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_kernel_properties_t* pKernelProperties ///< [in,out] query result for kernel properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Kernel->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hKernel, pKernelProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelGetName + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetName( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + size_t* pSize, ///< [in,out] size of kernel name string, including null terminator, in + ///< bytes. + char* pName ///< [in,out][optional] char pointer to kernel name. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetName = dditable->Kernel->pfnGetName; + if( nullptr == pfnGetName ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetName( hKernel, pSize, pName ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendLaunchKernel + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchKernel( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchFuncArgs, ///< [in] thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendLaunchKernel = dditable->CommandList->pfnAppendLaunchKernel; + if( nullptr == pfnAppendLaunchKernel ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendLaunchKernel( hCommandList, hKernel, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendLaunchCooperativeKernel + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchCooperativeKernel( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchFuncArgs, ///< [in] thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendLaunchCooperativeKernel = dditable->CommandList->pfnAppendLaunchCooperativeKernel; + if( nullptr == pfnAppendLaunchCooperativeKernel ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendLaunchCooperativeKernel( hCommandList, hKernel, pLaunchFuncArgs, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendLaunchKernelIndirect + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchKernelIndirect( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + const ze_group_count_t* pLaunchArgumentsBuffer, ///< [in] pointer to device buffer that will contain thread group launch + ///< arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendLaunchKernelIndirect = dditable->CommandList->pfnAppendLaunchKernelIndirect; + if( nullptr == pfnAppendLaunchKernelIndirect ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendLaunchKernelIndirect( hCommandList, hKernel, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendLaunchMultipleKernelsIndirect + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendLaunchMultipleKernelsIndirect( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] maximum number of kernels to launch + ze_kernel_handle_t* phKernels, ///< [in][range(0, numKernels)] handles of the kernel objects + const uint32_t* pCountBuffer, ///< [in] pointer to device memory location that will contain the actual + ///< number of kernels to launch; value must be less than or equal to + ///< numKernels + const ze_group_count_t* pLaunchArgumentsBuffer, ///< [in][range(0, numKernels)] pointer to device buffer that will contain + ///< a contiguous array of thread group launch arguments + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendLaunchMultipleKernelsIndirect = dditable->CommandList->pfnAppendLaunchMultipleKernelsIndirect; + if( nullptr == pfnAppendLaunchMultipleKernelsIndirect ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendLaunchMultipleKernelsIndirect( hCommandList, numKernels, phKernels, pCountBuffer, pLaunchArgumentsBuffer, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextMakeMemoryResident + __zedlllocal ze_result_t ZE_APICALL + zeContextMakeMemoryResident( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + void* ptr, ///< [in] pointer to memory to make resident + size_t size ///< [in] size in bytes to make resident + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnMakeMemoryResident = dditable->Context->pfnMakeMemoryResident; + if( nullptr == pfnMakeMemoryResident ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnMakeMemoryResident( hContext, hDevice, ptr, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextEvictMemory + __zedlllocal ze_result_t ZE_APICALL + zeContextEvictMemory( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + void* ptr, ///< [in] pointer to memory to evict + size_t size ///< [in] size in bytes to evict + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEvictMemory = dditable->Context->pfnEvictMemory; + if( nullptr == pfnEvictMemory ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEvictMemory( hContext, hDevice, ptr, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextMakeImageResident + __zedlllocal ze_result_t ZE_APICALL + zeContextMakeImageResident( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_image_handle_t hImage ///< [in] handle of image to make resident + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnMakeImageResident = dditable->Context->pfnMakeImageResident; + if( nullptr == pfnMakeImageResident ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnMakeImageResident( hContext, hDevice, hImage ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeContextEvictImage + __zedlllocal ze_result_t ZE_APICALL + zeContextEvictImage( + ze_context_handle_t hContext, ///< [in] handle of context object + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_image_handle_t hImage ///< [in] handle of image to make evict + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEvictImage = dditable->Context->pfnEvictImage; + if( nullptr == pfnEvictImage ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEvictImage( hContext, hDevice, hImage ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeSamplerCreate + __zedlllocal ze_result_t ZE_APICALL + zeSamplerCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_sampler_desc_t* desc, ///< [in] pointer to sampler descriptor + ze_sampler_handle_t* phSampler ///< [out] handle of the sampler + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->Sampler->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phSampler ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeSamplerDestroy + __zedlllocal ze_result_t ZE_APICALL + zeSamplerDestroy( + ze_sampler_handle_t hSampler ///< [in][release] handle of the sampler + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hSampler )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->Sampler->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hSampler ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemReserve + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemReserve( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* pStart, ///< [in][optional] pointer to start of region to reserve. If nullptr then + ///< implementation will choose a start address. + size_t size, ///< [in] size in bytes to reserve; must be page aligned. + void** pptr ///< [out] pointer to virtual reservation. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReserve = dditable->VirtualMem->pfnReserve; + if( nullptr == pfnReserve ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReserve( hContext, pStart, size, pptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemFree + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemFree( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of region to free. + size_t size ///< [in] size in bytes to free; must be page aligned. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnFree = dditable->VirtualMem->pfnFree; + if( nullptr == pfnFree ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnFree( hContext, ptr, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemQueryPageSize + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemQueryPageSize( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object + size_t size, ///< [in] unaligned allocation size in bytes + size_t* pagesize ///< [out] pointer to page size to use for start address and size + ///< alignments. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryPageSize = dditable->VirtualMem->pfnQueryPageSize; + if( nullptr == pfnQueryPageSize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryPageSize( hContext, hDevice, size, pagesize ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zePhysicalMemCreate + __zedlllocal ze_result_t ZE_APICALL + zePhysicalMemCreate( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. + ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. + ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->PhysicalMem->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, desc, phPhysicalMemory ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zePhysicalMemDestroy + __zedlllocal ze_result_t ZE_APICALL + zePhysicalMemDestroy( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_physical_mem_handle_t hPhysicalMemory ///< [in][release] handle of physical memory object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->PhysicalMem->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hContext, hPhysicalMemory ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemMap + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemMap( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of virtual address range to map. + size_t size, ///< [in] size in bytes of virtual address range to map; must be page + ///< aligned. + ze_physical_mem_handle_t hPhysicalMemory, ///< [in] handle to physical memory object. + size_t offset, ///< [in] offset into physical memory allocation object; must be page + ///< aligned. + ze_memory_access_attribute_t access ///< [in] specifies page access attributes to apply to the virtual address + ///< range. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnMap = dditable->VirtualMem->pfnMap; + if( nullptr == pfnMap ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnMap( hContext, ptr, size, hPhysicalMemory, offset, access ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemUnmap + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemUnmap( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of region to unmap. + size_t size ///< [in] size in bytes to unmap; must be page aligned. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnUnmap = dditable->VirtualMem->pfnUnmap; + if( nullptr == pfnUnmap ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnUnmap( hContext, ptr, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemSetAccessAttribute + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemSetAccessAttribute( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of reserved virtual address region. + size_t size, ///< [in] size in bytes; must be page aligned. + ze_memory_access_attribute_t access ///< [in] specifies page access attributes to apply to the virtual address + ///< range. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetAccessAttribute = dditable->VirtualMem->pfnSetAccessAttribute; + if( nullptr == pfnSetAccessAttribute ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetAccessAttribute( hContext, ptr, size, access ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeVirtualMemGetAccessAttribute + __zedlllocal ze_result_t ZE_APICALL + zeVirtualMemGetAccessAttribute( + ze_context_handle_t hContext, ///< [in] handle of the context object + const void* ptr, ///< [in] pointer to start of virtual address region for query. + size_t size, ///< [in] size in bytes; must be page aligned. + ze_memory_access_attribute_t* access, ///< [out] query result for page access attribute. + size_t* outSize ///< [out] query result for size of virtual address range, starting at ptr, + ///< that shares same access attribute. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAccessAttribute = dditable->VirtualMem->pfnGetAccessAttribute; + if( nullptr == pfnGetAccessAttribute ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAccessAttribute( hContext, ptr, size, access, outSize ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSetGlobalOffsetExp + __zedlllocal ze_result_t ZE_APICALL + zeKernelSetGlobalOffsetExp( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + uint32_t offsetX, ///< [in] global offset for X dimension to use for this kernel + uint32_t offsetY, ///< [in] global offset for Y dimension to use for this kernel + uint32_t offsetZ ///< [in] global offset for Z dimension to use for this kernel + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_1) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetGlobalOffsetExp = dditable->KernelExp->pfnSetGlobalOffsetExp; + if( nullptr == pfnSetGlobalOffsetExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetGlobalOffsetExp( hKernel, offsetX, offsetY, offsetZ ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelGetBinaryExp + __zedlllocal ze_result_t ZE_APICALL + zeKernelGetBinaryExp( + ze_kernel_handle_t hKernel, ///< [in] Kernel handle. + size_t* pSize, ///< [in,out] pointer to variable with size of GEN ISA binary. + uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_11) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetBinaryExp = dditable->KernelExp->pfnGetBinaryExp; + if( nullptr == pfnGetBinaryExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetBinaryExp( hKernel, pSize, pKernelBinary ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceImportExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_12) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnImportExternalSemaphoreExt = dditable->Device->pfnImportExternalSemaphoreExt; + if( nullptr == pfnImportExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnImportExternalSemaphoreExt( hDevice, desc, phSemaphore ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReleaseExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hSemaphore )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_12) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReleaseExternalSemaphoreExt = dditable->Device->pfnReleaseExternalSemaphoreExt; + if( nullptr == pfnReleaseExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReleaseExternalSemaphoreExt( hSemaphore ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_12) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendSignalExternalSemaphoreExt = dditable->CommandList->pfnAppendSignalExternalSemaphoreExt; + if( nullptr == pfnAppendSignalExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendSignalExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_12) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendWaitExternalSemaphoreExt = dditable->CommandList->pfnAppendWaitExternalSemaphoreExt; + if( nullptr == pfnAppendWaitExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendWaitExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderCreateExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCreateExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + const ze_rtas_builder_ext_desc_t* pDescriptor, ///< [in] pointer to builder descriptor + ze_rtas_builder_ext_handle_t* phBuilder ///< [out] handle of builder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExt = dditable->RTASBuilder->pfnCreateExt; + if( nullptr == pfnCreateExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExt( hDriver, pDescriptor, phBuilder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderGetBuildPropertiesExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderGetBuildPropertiesExt( + ze_rtas_builder_ext_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_ext_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + ze_rtas_builder_ext_properties_t* pProperties ///< [in,out] query result for builder properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetBuildPropertiesExt = dditable->RTASBuilder->pfnGetBuildPropertiesExt; + if( nullptr == pfnGetBuildPropertiesExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetBuildPropertiesExt( hBuilder, pBuildOpDescriptor, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverRTASFormatCompatibilityCheckExt + __zedlllocal ze_result_t ZE_APICALL + zeDriverRTASFormatCompatibilityCheckExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_format_ext_t rtasFormatA, ///< [in] operand A + ze_rtas_format_ext_t rtasFormatB ///< [in] operand B + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnRTASFormatCompatibilityCheckExt = dditable->Driver->pfnRTASFormatCompatibilityCheckExt; + if( nullptr == pfnRTASFormatCompatibilityCheckExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnRTASFormatCompatibilityCheckExt( hDriver, rtasFormatA, rtasFormatB ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderBuildExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderBuildExt( + ze_rtas_builder_ext_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_ext_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + void* pScratchBuffer, ///< [in][range(0, `scratchBufferSizeBytes`)] scratch buffer to be used + ///< during acceleration structure construction + size_t scratchBufferSizeBytes, ///< [in] size of scratch buffer, in bytes + void* pRtasBuffer, ///< [in] pointer to destination buffer + size_t rtasBufferSizeBytes, ///< [in] destination buffer size, in bytes + ze_rtas_parallel_operation_ext_handle_t hParallelOperation, ///< [in][optional] handle to parallel operation object + void* pBuildUserPtr, ///< [in][optional] pointer passed to callbacks + ze_rtas_aabb_ext_t* pBounds, ///< [in,out][optional] pointer to destination address for acceleration + ///< structure bounds + size_t* pRtasBufferSizeBytes ///< [out][optional] updated acceleration structure size requirement, in + ///< bytes + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnBuildExt = dditable->RTASBuilder->pfnBuildExt; + if( nullptr == pfnBuildExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnBuildExt( hBuilder, pBuildOpDescriptor, pScratchBuffer, scratchBufferSizeBytes, pRtasBuffer, rtasBufferSizeBytes, hParallelOperation, pBuildUserPtr, pBounds, pRtasBufferSizeBytes ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderCommandListAppendCopyExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCommandListAppendCopyExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination in device memory to copy the ray tracing + ///< acceleration structure to + const void* srcptr, ///< [in] pointer to a valid source ray tracing acceleration structure in + ///< host memory to copy from + size_t size, ///< [in] size in bytes to copy + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCommandListAppendCopyExt = dditable->RTASBuilder->pfnCommandListAppendCopyExt; + if( nullptr == pfnCommandListAppendCopyExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCommandListAppendCopyExt( hCommandList, dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderDestroyExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderDestroyExt( + ze_rtas_builder_ext_handle_t hBuilder ///< [in][release] handle of builder object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExt = dditable->RTASBuilder->pfnDestroyExt; + if( nullptr == pfnDestroyExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExt( hBuilder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationCreateExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationCreateExt( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_parallel_operation_ext_handle_t* phParallelOperation///< [out] handle of parallel operation object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExt = dditable->RTASParallelOperation->pfnCreateExt; + if( nullptr == pfnCreateExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExt( hDriver, phParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationGetPropertiesExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationGetPropertiesExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation, ///< [in] handle of parallel operation object + ze_rtas_parallel_operation_ext_properties_t* pProperties///< [in,out] query result for parallel operation properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPropertiesExt = dditable->RTASParallelOperation->pfnGetPropertiesExt; + if( nullptr == pfnGetPropertiesExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPropertiesExt( hParallelOperation, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationJoinExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationJoinExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation ///< [in] handle of parallel operation object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnJoinExt = dditable->RTASParallelOperation->pfnJoinExt; + if( nullptr == pfnJoinExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnJoinExt( hParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationDestroyExt + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationDestroyExt( + ze_rtas_parallel_operation_ext_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExt = dditable->RTASParallelOperation->pfnDestroyExt; + if( nullptr == pfnDestroyExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExt( hParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetVectorWidthPropertiesExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetVectorWidthPropertiesExt( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of vector width properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of vector width properties available. + ///< if count is greater than the number of vector width properties + ///< available, then the driver shall update the value with the correct + ///< number of vector width properties available. + ze_device_vector_width_properties_ext_t* pVectorWidthProperties ///< [in,out][optional][range(0, *pCount)] array of vector width properties. + ///< if count is less than the number of properties available, then the + ///< driver will return only the number requested. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVectorWidthPropertiesExt = dditable->Device->pfnGetVectorWidthPropertiesExt; + if( nullptr == pfnGetVectorWidthPropertiesExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVectorWidthPropertiesExt( hDevice, pCount, pVectorWidthProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReserveCacheExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReserveCacheExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + size_t cacheLevel, ///< [in] cache level where application want to reserve. If zero, then the + ///< driver shall default to last level of cache and attempt to reserve in + ///< that cache. + size_t cacheReservationSize ///< [in] value for reserving size, in bytes. If zero, then the driver + ///< shall remove prior reservation + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReserveCacheExt = dditable->Device->pfnReserveCacheExt; + if( nullptr == pfnReserveCacheExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReserveCacheExt( hDevice, cacheLevel, cacheReservationSize ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceSetCacheAdviceExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceSetCacheAdviceExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + void* ptr, ///< [in] memory pointer to query + size_t regionSize, ///< [in] region size, in pages + ze_cache_ext_region_t cacheRegion ///< [in] reservation region + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetCacheAdviceExt = dditable->Device->pfnSetCacheAdviceExt; + if( nullptr == pfnSetCacheAdviceExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetCacheAdviceExt( hDevice, ptr, regionSize, cacheRegion ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryTimestampsExp + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryTimestampsExp( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of timestamp results. + ///< if count is zero, then the driver shall update the value with the + ///< total number of timestamps available. + ///< if count is greater than the number of timestamps available, then the + ///< driver shall update the value with the correct number of timestamps available. + ze_kernel_timestamp_result_t* pTimestamps ///< [in,out][optional][range(0, *pCount)] array of timestamp results. + ///< if count is less than the number of timestamps available, then driver + ///< shall only retrieve that number of timestamps. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryTimestampsExp = dditable->EventExp->pfnQueryTimestampsExp; + if( nullptr == pfnQueryTimestampsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryTimestampsExp( hEvent, hDevice, pCount, pTimestamps ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageGetMemoryPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zeImageGetMemoryPropertiesExp( + ze_image_handle_t hImage, ///< [in] handle of image object + ze_image_memory_properties_exp_t* pMemoryProperties ///< [in,out] query result for image memory properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hImage )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetMemoryPropertiesExp = dditable->ImageExp->pfnGetMemoryPropertiesExp; + if( nullptr == pfnGetMemoryPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetMemoryPropertiesExp( hImage, pMemoryProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageViewCreateExt + __zedlllocal ze_result_t ZE_APICALL + zeImageViewCreateExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t hImage, ///< [in] handle of image object to create view from + ze_image_handle_t* phImageView ///< [out] pointer to handle of image object created for view + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnViewCreateExt = dditable->Image->pfnViewCreateExt; + if( nullptr == pfnViewCreateExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnViewCreateExt( hContext, hDevice, desc, hImage, phImageView ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageViewCreateExp + __zedlllocal ze_result_t ZE_APICALL + zeImageViewCreateExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + const ze_image_desc_t* desc, ///< [in] pointer to image descriptor + ze_image_handle_t hImage, ///< [in] handle of image object to create view from + ze_image_handle_t* phImageView ///< [out] pointer to handle of image object created for view + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnViewCreateExp = dditable->ImageExp->pfnViewCreateExp; + if( nullptr == pfnViewCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnViewCreateExp( hContext, hDevice, desc, hImage, phImageView ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeKernelSchedulingHintExp + __zedlllocal ze_result_t ZE_APICALL + zeKernelSchedulingHintExp( + ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object + ze_scheduling_hint_exp_desc_t* pHint ///< [in] pointer to kernel scheduling hint descriptor + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSchedulingHintExp = dditable->KernelExp->pfnSchedulingHintExp; + if( nullptr == pfnSchedulingHintExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSchedulingHintExp( hKernel, pHint ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDevicePciGetPropertiesExt + __zedlllocal ze_result_t ZE_APICALL + zeDevicePciGetPropertiesExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object. + ze_pci_ext_properties_t* pPciProperties ///< [in,out] returns the PCI properties of the device. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPciGetPropertiesExt = dditable->Device->pfnPciGetPropertiesExt; + if( nullptr == pfnPciGetPropertiesExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPciGetPropertiesExt( hDevice, pPciProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopyToMemoryExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyToMemoryExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + void* dstptr, ///< [in] pointer to destination memory to copy to + ze_image_handle_t hSrcImage, ///< [in] handle of source image to copy from + const ze_image_region_t* pSrcRegion, ///< [in][optional] source region descriptor + uint32_t destRowPitch, ///< [in] size in bytes of the 1D slice of the 2D region of a 2D or 3D + ///< image or each image of a 1D or 2D image array being written + uint32_t destSlicePitch, ///< [in] size in bytes of the 2D slice of the 3D region of a 3D image or + ///< each image of a 1D or 2D image array being written + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopyToMemoryExt = dditable->CommandList->pfnAppendImageCopyToMemoryExt; + if( nullptr == pfnAppendImageCopyToMemoryExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopyToMemoryExt( hCommandList, dstptr, hSrcImage, pSrcRegion, destRowPitch, destSlicePitch, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendImageCopyFromMemoryExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendImageCopyFromMemoryExt( + ze_command_list_handle_t hCommandList, ///< [in] handle of command list + ze_image_handle_t hDstImage, ///< [in] handle of destination image to copy to + const void* srcptr, ///< [in] pointer to source memory to copy from + const ze_image_region_t* pDstRegion, ///< [in][optional] destination region descriptor + uint32_t srcRowPitch, ///< [in] size in bytes of the 1D slice of the 2D region of a 2D or 3D + ///< image or each image of a 1D or 2D image array being read + uint32_t srcSlicePitch, ///< [in] size in bytes of the 2D slice of the 3D region of a 3D image or + ///< each image of a 1D or 2D image array being read + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; must be 0 + ///< if `nullptr == phWaitEvents` + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendImageCopyFromMemoryExt = dditable->CommandList->pfnAppendImageCopyFromMemoryExt; + if( nullptr == pfnAppendImageCopyFromMemoryExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendImageCopyFromMemoryExt( hCommandList, hDstImage, srcptr, pDstRegion, srcRowPitch, srcSlicePitch, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageGetAllocPropertiesExt + __zedlllocal ze_result_t ZE_APICALL + zeImageGetAllocPropertiesExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_image_handle_t hImage, ///< [in] handle of image object to query + ze_image_allocation_ext_properties_t* pImageAllocProperties ///< [in,out] query result for image allocation properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAllocPropertiesExt = dditable->Image->pfnGetAllocPropertiesExt; + if( nullptr == pfnGetAllocPropertiesExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAllocPropertiesExt( hContext, hImage, pImageAllocProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeModuleInspectLinkageExt + __zedlllocal ze_result_t ZE_APICALL + zeModuleInspectLinkageExt( + ze_linkage_inspection_ext_desc_t* pInspectDesc, ///< [in] pointer to linkage inspection descriptor structure. + uint32_t numModules, ///< [in] number of modules to be inspected pointed to by phModules. + ze_module_handle_t* phModules, ///< [in][range(0, numModules)] pointer to an array of modules to be + ///< inspected for import dependencies. + ze_module_build_log_handle_t* phLog ///< [out] pointer to handle of linkage inspection log. Log object will + ///< contain separate lists of imports, un-resolvable imports, and exports. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( phModules[ 0 ] )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnInspectLinkageExt = dditable->Module->pfnInspectLinkageExt; + if( nullptr == pfnInspectLinkageExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnInspectLinkageExt( pInspectDesc, numModules, phModules, phLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemFreeExt + __zedlllocal ze_result_t ZE_APICALL + zeMemFreeExt( + ze_context_handle_t hContext, ///< [in] handle of the context object + const ze_memory_free_ext_desc_t* pMemFreeDesc, ///< [in] pointer to memory free descriptor + void* ptr ///< [in][release] pointer to memory to free + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_3) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnFreeExt = dditable->Mem->pfnFreeExt; + if( nullptr == pfnFreeExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnFreeExt( hContext, pMemFreeDesc, ptr ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricVertexGetExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetExp( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of fabric vertices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of fabric vertices available. + ///< if count is greater than the number of fabric vertices available, then + ///< the driver shall update the value with the correct number of fabric + ///< vertices available. + ze_fabric_vertex_handle_t* phVertices ///< [in,out][optional][range(0, *pCount)] array of handle of fabric vertices. + ///< if count is less than the number of fabric vertices available, then + ///< driver shall only retrieve that number of fabric vertices. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExp = dditable->FabricVertexExp->pfnGetExp; + if( nullptr == pfnGetExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExp( hDriver, pCount, phVertices ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricVertexGetSubVerticesExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetSubVerticesExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex object + uint32_t* pCount, ///< [in,out] pointer to the number of sub-vertices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub-vertices available. + ///< if count is greater than the number of sub-vertices available, then + ///< the driver shall update the value with the correct number of + ///< sub-vertices available. + ze_fabric_vertex_handle_t* phSubvertices ///< [in,out][optional][range(0, *pCount)] array of handle of sub-vertices. + ///< if count is less than the number of sub-vertices available, then + ///< driver shall only retrieve that number of sub-vertices. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVertex )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSubVerticesExp = dditable->FabricVertexExp->pfnGetSubVerticesExp; + if( nullptr == pfnGetSubVerticesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSubVerticesExp( hVertex, pCount, phSubvertices ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricVertexGetPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetPropertiesExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex + ze_fabric_vertex_exp_properties_t* pVertexProperties///< [in,out] query result for fabric vertex properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVertex )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPropertiesExp = dditable->FabricVertexExp->pfnGetPropertiesExp; + if( nullptr == pfnGetPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPropertiesExp( hVertex, pVertexProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricVertexGetDeviceExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricVertexGetDeviceExp( + ze_fabric_vertex_handle_t hVertex, ///< [in] handle of the fabric vertex + ze_device_handle_t* phDevice ///< [out] device handle corresponding to fabric vertex + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVertex )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDeviceExp = dditable->FabricVertexExp->pfnGetDeviceExp; + if( nullptr == pfnGetDeviceExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDeviceExp( hVertex, phDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceGetFabricVertexExp + __zedlllocal ze_result_t ZE_APICALL + zeDeviceGetFabricVertexExp( + ze_device_handle_t hDevice, ///< [in] handle of the device + ze_fabric_vertex_handle_t* phVertex ///< [out] fabric vertex handle corresponding to device + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFabricVertexExp = dditable->DeviceExp->pfnGetFabricVertexExp; + if( nullptr == pfnGetFabricVertexExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFabricVertexExp( hDevice, phVertex ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricEdgeGetExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetExp( + ze_fabric_vertex_handle_t hVertexA, ///< [in] handle of first fabric vertex instance + ze_fabric_vertex_handle_t hVertexB, ///< [in] handle of second fabric vertex instance + uint32_t* pCount, ///< [in,out] pointer to the number of fabric edges. + ///< if count is zero, then the driver shall update the value with the + ///< total number of fabric edges available. + ///< if count is greater than the number of fabric edges available, then + ///< the driver shall update the value with the correct number of fabric + ///< edges available. + ze_fabric_edge_handle_t* phEdges ///< [in,out][optional][range(0, *pCount)] array of handle of fabric edges. + ///< if count is less than the number of fabric edges available, then + ///< driver shall only retrieve that number of fabric edges. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVertexA )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExp = dditable->FabricEdgeExp->pfnGetExp; + if( nullptr == pfnGetExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExp( hVertexA, hVertexB, pCount, phEdges ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricEdgeGetVerticesExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetVerticesExp( + ze_fabric_edge_handle_t hEdge, ///< [in] handle of the fabric edge instance + ze_fabric_vertex_handle_t* phVertexA, ///< [out] fabric vertex connected to one end of the given fabric edge. + ze_fabric_vertex_handle_t* phVertexB ///< [out] fabric vertex connected to other end of the given fabric edge. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEdge )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVerticesExp = dditable->FabricEdgeExp->pfnGetVerticesExp; + if( nullptr == pfnGetVerticesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVerticesExp( hEdge, phVertexA, phVertexB ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeFabricEdgeGetPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zeFabricEdgeGetPropertiesExp( + ze_fabric_edge_handle_t hEdge, ///< [in] handle of the fabric edge + ze_fabric_edge_exp_properties_t* pEdgeProperties///< [in,out] query result for fabric edge properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEdge )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPropertiesExp = dditable->FabricEdgeExp->pfnGetPropertiesExp; + if( nullptr == pfnGetPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPropertiesExp( hEdge, pEdgeProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestampsExt + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in,out][optional][range(0, *pCount)] pointer to event query + ///< properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEvent )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnQueryKernelTimestampsExt = dditable->Event->pfnQueryKernelTimestampsExt; + if( nullptr == pfnQueryKernelTimestampsExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderCreateExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderCreateExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + const ze_rtas_builder_exp_desc_t* pDescriptor, ///< [in] pointer to builder descriptor + ze_rtas_builder_exp_handle_t* phBuilder ///< [out] handle of builder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExp = dditable->RTASBuilderExp->pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExp( hDriver, pDescriptor, phBuilder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderGetBuildPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderGetBuildPropertiesExp( + ze_rtas_builder_exp_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_exp_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + ze_rtas_builder_exp_properties_t* pProperties ///< [in,out] query result for builder properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetBuildPropertiesExp = dditable->RTASBuilderExp->pfnGetBuildPropertiesExp; + if( nullptr == pfnGetBuildPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetBuildPropertiesExp( hBuilder, pBuildOpDescriptor, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverRTASFormatCompatibilityCheckExp + __zedlllocal ze_result_t ZE_APICALL + zeDriverRTASFormatCompatibilityCheckExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_format_exp_t rtasFormatA, ///< [in] operand A + ze_rtas_format_exp_t rtasFormatB ///< [in] operand B + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnRTASFormatCompatibilityCheckExp = dditable->DriverExp->pfnRTASFormatCompatibilityCheckExp; + if( nullptr == pfnRTASFormatCompatibilityCheckExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnRTASFormatCompatibilityCheckExp( hDriver, rtasFormatA, rtasFormatB ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderBuildExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderBuildExp( + ze_rtas_builder_exp_handle_t hBuilder, ///< [in] handle of builder object + const ze_rtas_builder_build_op_exp_desc_t* pBuildOpDescriptor, ///< [in] pointer to build operation descriptor + void* pScratchBuffer, ///< [in][range(0, `scratchBufferSizeBytes`)] scratch buffer to be used + ///< during acceleration structure construction + size_t scratchBufferSizeBytes, ///< [in] size of scratch buffer, in bytes + void* pRtasBuffer, ///< [in] pointer to destination buffer + size_t rtasBufferSizeBytes, ///< [in] destination buffer size, in bytes + ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in][optional] handle to parallel operation object + void* pBuildUserPtr, ///< [in][optional] pointer passed to callbacks + ze_rtas_aabb_exp_t* pBounds, ///< [in,out][optional] pointer to destination address for acceleration + ///< structure bounds + size_t* pRtasBufferSizeBytes ///< [out][optional] updated acceleration structure size requirement, in + ///< bytes + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnBuildExp = dditable->RTASBuilderExp->pfnBuildExp; + if( nullptr == pfnBuildExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnBuildExp( hBuilder, pBuildOpDescriptor, pScratchBuffer, scratchBufferSizeBytes, pRtasBuffer, rtasBufferSizeBytes, hParallelOperation, pBuildUserPtr, pBounds, pRtasBufferSizeBytes ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASBuilderDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASBuilderDestroyExp( + ze_rtas_builder_exp_handle_t hBuilder ///< [in][release] handle of builder object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hBuilder )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->RTASBuilderExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( hBuilder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationCreateExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationCreateExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_parallel_operation_exp_handle_t* phParallelOperation///< [out] handle of parallel operation object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExp = dditable->RTASParallelOperationExp->pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExp( hDriver, phParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationGetPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationGetPropertiesExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in] handle of parallel operation object + ze_rtas_parallel_operation_exp_properties_t* pProperties///< [in,out] query result for parallel operation properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPropertiesExp = dditable->RTASParallelOperationExp->pfnGetPropertiesExp; + if( nullptr == pfnGetPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPropertiesExp( hParallelOperation, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationJoinExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationJoinExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in] handle of parallel operation object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnJoinExp = dditable->RTASParallelOperationExp->pfnJoinExp; + if( nullptr == pfnJoinExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnJoinExp( hParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeRTASParallelOperationDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zeRTASParallelOperationDestroyExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hParallelOperation )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->RTASParallelOperationExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( hParallelOperation ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetPitchFor2dImage + __zedlllocal ze_result_t ZE_APICALL + zeMemGetPitchFor2dImage( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + size_t imageWidth, ///< [in] imageWidth + size_t imageHeight, ///< [in] imageHeight + unsigned int elementSizeInBytes, ///< [in] Element size in bytes + size_t * rowPitch ///< [out] rowPitch + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPitchFor2dImage = dditable->Mem->pfnGetPitchFor2dImage; + if( nullptr == pfnGetPitchFor2dImage ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPitchFor2dImage( hContext, hDevice, imageWidth, imageHeight, elementSizeInBytes, rowPitch ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeImageGetDeviceOffsetExp + __zedlllocal ze_result_t ZE_APICALL + zeImageGetDeviceOffsetExp( + ze_image_handle_t hImage, ///< [in] handle of the image + uint64_t* pDeviceOffset ///< [out] bindless device offset for image + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hImage )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDeviceOffsetExp = dditable->ImageExp->pfnGetDeviceOffsetExp; + if( nullptr == pfnGetDeviceOffsetExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDeviceOffsetExp( hImage, pDeviceOffset ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListCreateCloneExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListCreateCloneExp( + ze_command_list_handle_t hCommandList, ///< [in] handle to source command list (the command list to clone) + ze_command_list_handle_t* phClonedCommandList ///< [out] pointer to handle of the cloned command list + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateCloneExp = dditable->CommandListExp->pfnCreateCloneExp; + if( nullptr == pfnCreateCloneExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateCloneExp( hCommandList, phClonedCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListImmediateAppendCommandListsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListImmediateAppendCommandListsExp( + ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list + uint32_t numCommandLists, ///< [in] number of command lists + ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] handles of command lists + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + ///< - if not null, this event is signaled after the completion of all + ///< appended command lists + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing appended + ///< command lists; must be 0 if nullptr == phWaitEvents + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before executing appended command lists. + ///< - if not null, all wait events must be satisfied prior to the start + ///< of any appended command list(s) + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandListImmediate )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnImmediateAppendCommandListsExp = dditable->CommandListExp->pfnImmediateAppendCommandListsExp; + if( nullptr == pfnImmediateAppendCommandListsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnImmediateAppendCommandListsExp( hCommandListImmediate, numCommandLists, phCommandLists, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetNextCommandIdExp = dditable->CommandListExp->pfnGetNextCommandIdExp; + if( nullptr == pfnGetNextCommandIdExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdWithKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetNextCommandIdWithKernelsExp = dditable->CommandListExp->pfnGetNextCommandIdWithKernelsExp; + if( nullptr == pfnGetNextCommandIdWithKernelsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetNextCommandIdWithKernelsExp( hCommandList, desc, numKernels, phKernels, pCommandId ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnUpdateMutableCommandsExp = dditable->CommandListExp->pfnUpdateMutableCommandsExp; + if( nullptr == pfnUpdateMutableCommandsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnUpdateMutableCommandsExp( hCommandList, desc ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnUpdateMutableCommandSignalEventExp = dditable->CommandListExp->pfnUpdateMutableCommandSignalEventExp; + if( nullptr == pfnUpdateMutableCommandSignalEventExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnUpdateMutableCommandWaitEventsExp = dditable->CommandListExp->pfnUpdateMutableCommandWaitEventsExp; + if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pCore; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnUpdateMutableCommandKernelsExp = dditable->CommandListExp->pfnUpdateMutableCommandKernelsExp; + if( nullptr == pfnUpdateMutableCommandKernelsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnUpdateMutableCommandKernelsExp( hCommandList, numKernels, pCommandId, phKernels ); + return result; + } + + + /////////////////////////////////////////////////////////////////////////////// + /// @brief function for removing the ddi driver tables for ze + __zedlllocal void ZE_APICALL + zeDestroyDDiDriverTables(ze_dditable_driver_t* pDdiTable) + { + // Delete ddi tables + delete pDdiTable->Global; + delete pDdiTable->RTASBuilder; + delete pDdiTable->RTASBuilderExp; + delete pDdiTable->RTASParallelOperation; + delete pDdiTable->RTASParallelOperationExp; + delete pDdiTable->Driver; + delete pDdiTable->DriverExp; + delete pDdiTable->Device; + delete pDdiTable->DeviceExp; + delete pDdiTable->Context; + delete pDdiTable->CommandQueue; + delete pDdiTable->CommandList; + delete pDdiTable->CommandListExp; + delete pDdiTable->Event; + delete pDdiTable->EventExp; + delete pDdiTable->EventPool; + delete pDdiTable->Fence; + delete pDdiTable->Image; + delete pDdiTable->ImageExp; + delete pDdiTable->Kernel; + delete pDdiTable->KernelExp; + delete pDdiTable->Mem; + delete pDdiTable->MemExp; + delete pDdiTable->Module; + delete pDdiTable->ModuleBuildLog; + delete pDdiTable->PhysicalMem; + delete pDdiTable->Sampler; + delete pDdiTable->VirtualMem; + delete pDdiTable->FabricEdgeExp; + delete pDdiTable->FabricVertexExp; + delete pDdiTable; + } + +} // namespace loader_driver_ddi \ No newline at end of file diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index fb05f7e6..b3ef06ad 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,6 +18,10 @@ namespace loader { + ze_handle_t* loaderDispatch = nullptr; + ze_dditable_t* loaderZeDdiTable = nullptr; + zet_dditable_t* loaderZetDdiTable = nullptr; + zes_dditable_t* loaderZesDdiTable = nullptr; /////////////////////////////////////////////////////////////////////////////// context_t *context; @@ -172,10 +176,13 @@ namespace loader } for (auto handle : driverHandles) { - ze_driver_properties_t properties = {}; - properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; - properties.pNext = nullptr; - ze_result_t res = driver.dditable.ze.Driver.pfnGetProperties(handle, &properties); + driver.properties = {}; + driver.properties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; + driver.properties.pNext = nullptr; + ze_driver_properties_t driverProperties = {}; + driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; + driverProperties.pNext = &driver.properties; + ze_result_t res = driver.dditable.ze.Driver.pfnGetProperties(handle, &driverProperties); if (res != ZE_RESULT_SUCCESS) { if (debugTraceEnabled) { std::string message = "driverSorting " + driver.name + " failed, zeDriverGetProperties returned "; @@ -183,7 +190,7 @@ namespace loader } continue; } - driver.properties = properties; + driver.driverDDIHandleSupportQueried = true; uint32_t deviceCount = 0; res = driver.dditable.ze.Device.pfnGet( handle, &deviceCount, nullptr ); if( ZE_RESULT_SUCCESS != res ) { @@ -457,7 +464,21 @@ namespace loader if (driverEnvironmentQueried) { return ZE_RESULT_SUCCESS; } + loader::loaderDispatch = new ze_handle_t(); + loader::loaderDispatch->pCore = new ze_dditable_driver_t(); + loader::loaderDispatch->pCore->version = ZE_API_VERSION_CURRENT; + loader::loaderDispatch->pCore->isValidFlag = 1; + loader::loaderDispatch->pTools = new zet_dditable_driver_t(); + loader::loaderDispatch->pTools->version = ZE_API_VERSION_CURRENT; + loader::loaderDispatch->pTools->isValidFlag = 1; + loader::loaderDispatch->pSysman = new zes_dditable_driver_t(); + loader::loaderDispatch->pSysman->version = ZE_API_VERSION_CURRENT; + loader::loaderDispatch->pSysman->isValidFlag = 1; + loader::loaderZeDdiTable = new ze_dditable_t(); + loader::loaderZetDdiTable = new zet_dditable_t(); + loader::loaderZesDdiTable = new zes_dditable_t(); debugTraceEnabled = getenv_tobool( "ZE_ENABLE_LOADER_DEBUG_TRACE" ); + driverDDIPathDefault = getenv_tobool( "ZE_ENABLE_LOADER_DRIVER_DDI_PATH" ); auto discoveredDrivers = discoverEnabledDrivers(); std::string loadLibraryErrorValue; @@ -661,7 +682,10 @@ namespace loader } } } - + loader_driver_ddi::zeDestroyDDiDriverTables(loader::loaderDispatch->pCore); + loader_driver_ddi::zetDestroyDDiDriverTables(loader::loaderDispatch->pTools); + loader_driver_ddi::zesDestroyDDiDriverTables(loader::loaderDispatch->pSysman); + delete loader::loaderDispatch; }; void context_t::add_loader_version(){ diff --git a/source/loader/ze_loader_api.cpp b/source/loader/ze_loader_api.cpp index 3c1c8902..314ec1ba 100644 --- a/source/loader/ze_loader_api.cpp +++ b/source/loader/ze_loader_api.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -87,57 +87,89 @@ zelLoaderGetVersionsInternal( ZE_DLLEXPORT ze_result_t ZE_APICALL zelLoaderTranslateHandleInternal( zel_handle_type_t handleType, - void *handleIn, + void *handleIn, void **handleOut) { + if (!handleIn || !handleOut) { + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + } if(!loader::context->intercept_enabled) { *handleOut = handleIn; return ZE_RESULT_SUCCESS; } + *handleOut = handleIn; switch(handleType){ case ZEL_HANDLE_DRIVER: - *handleOut = reinterpret_cast( handleIn )->handle; + if (loader::context->ze_driver_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; case ZEL_HANDLE_DEVICE: - *handleOut = reinterpret_cast( handleIn )->handle; + if (loader::context->ze_device_factory.hasInstance(reinterpret_cast(handleIn)->handle)){ + *handleOut = reinterpret_cast( handleIn )->handle; + } break; case ZEL_HANDLE_CONTEXT: - *handleOut = reinterpret_cast( handleIn )->handle; - break; - case ZEL_HANDLE_COMMAND_QUEUE: - *handleOut = reinterpret_cast( handleIn )->handle; + if (loader::context->ze_context_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } + break; + case ZEL_HANDLE_COMMAND_QUEUE: + if (loader::context->ze_command_queue_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_COMMAND_LIST: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_COMMAND_LIST: + if (loader::context->ze_command_list_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_FENCE: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_FENCE: + if (loader::context->ze_fence_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_EVENT_POOL: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_EVENT_POOL: + if (loader::context->ze_event_pool_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_EVENT: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_EVENT: + if (loader::context->ze_event_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_IMAGE: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_IMAGE: + if (loader::context->ze_image_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_MODULE: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_MODULE: + if (loader::context->ze_module_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_MODULE_BUILD_LOG: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_MODULE_BUILD_LOG: + if (loader::context->ze_module_build_log_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_KERNEL: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_KERNEL: + if (loader::context->ze_kernel_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_SAMPLER: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_SAMPLER: + if (loader::context->ze_sampler_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; - case ZEL_HANDLE_PHYSICAL_MEM: - *handleOut = reinterpret_cast( handleIn )->handle; + case ZEL_HANDLE_PHYSICAL_MEM: + if (loader::context->ze_physical_mem_factory.hasInstance(reinterpret_cast(handleIn)->handle)) { + *handleOut = reinterpret_cast( handleIn )->handle; + } break; default: return ZE_RESULT_ERROR_INVALID_ENUMERATION; diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 94f123e9..1ce407f2 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -12,9 +12,7 @@ #include #include -#include "ze_ddi.h" -#include "zet_ddi.h" -#include "zes_ddi.h" +#include "ze_ddi_common.h" #include "ze_util.h" #include "ze_object.h" @@ -54,9 +52,10 @@ namespace loader std::string name; bool driverInuse = false; zel_driver_type_t driverType = ZEL_DRIVER_TYPE_FORCE_UINT32; - ze_driver_properties_t properties; + ze_driver_ddi_handles_ext_properties_t properties; bool pciOrderingRequested = false; bool legacyInitAttempted = false; + bool driverDDIHandleSupportQueried = false; }; using driver_vector_t = std::vector< driver_t >; @@ -154,6 +153,7 @@ namespace loader ~context_t(); bool intercept_enabled = false; bool debugTraceEnabled = false; + bool driverDDIPathDefault = false; bool tracingLayerEnabled = false; std::once_flag coreDriverSortOnce; std::once_flag sysmanDriverSortOnce; @@ -164,5 +164,9 @@ namespace loader std::shared_ptr zel_logger; }; + extern ze_handle_t* loaderDispatch; + extern ze_dditable_t* loaderZeDdiTable; + extern zet_dditable_t* loaderZetDdiTable; + extern zes_dditable_t* loaderZesDdiTable; extern context_t *context; } diff --git a/source/loader/ze_object.h b/source/loader/ze_object.h index 0420e737..417d82bf 100644 --- a/source/loader/ze_object.h +++ b/source/loader/ze_object.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,7 @@ */ #pragma once #include "ze_singleton.h" +#include "ze_ddi_common.h" ////////////////////////////////////////////////////////////////////////// struct dditable_t @@ -18,13 +19,21 @@ struct dditable_t zes_dditable_t zes; }; +namespace loader { + + extern ze_handle_t* loaderDispatch; + +} + ////////////////////////////////////////////////////////////////////////// template class object_t { public: using handle_t = _handle_t; - + ze_dditable_driver_t *pCore; + zet_dditable_driver_t *pTools; + zes_dditable_driver_t *pSysman; handle_t handle; dditable_t* dditable; @@ -33,6 +42,9 @@ class object_t object_t( handle_t _handle, dditable_t* _dditable ) : handle( _handle ), dditable( _dditable ) { + pCore = loader::loaderDispatch->pCore; + pTools = loader::loaderDispatch->pTools; + pSysman = loader::loaderDispatch->pSysman; } ~object_t() = default; diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index 9e80fa9d..179e72f8 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,8 @@ */ #include "ze_loader_internal.h" +using namespace loader_driver_ddi; + namespace loader { /////////////////////////////////////////////////////////////////////////////// @@ -103,8 +105,28 @@ namespace loader { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { uint32_t driver_index = total_driver_handle_count + i; - phDrivers[ driver_index ] = reinterpret_cast( - context->zes_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + if (drv.driverDDIHandleSupportQueried == false) { + drv.properties = {}; + drv.properties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; + drv.properties.pNext = nullptr; + ze_driver_properties_t driverProperties = {}; + driverProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; + driverProperties.pNext = nullptr; + driverProperties.pNext = &drv.properties; + ze_result_t res = drv.dditable.ze.Driver.pfnGetProperties(phDrivers[ driver_index ], &driverProperties); + if (res != ZE_RESULT_SUCCESS) { + if (loader::context->debugTraceEnabled) { + std::string message = drv.name + " failed zeDriverGetProperties query, returned "; + loader::context->debug_trace_message(message, loader::to_string(res)); + } + return res; + } + drv.driverDDIHandleSupportQueried = true; + } + if (!(drv.properties.flags & ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED) || !loader::context->driverDDIPathDefault) { + phDrivers[ driver_index ] = reinterpret_cast( + context->zes_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + } } } catch( std::bad_alloc& ) @@ -4584,6 +4606,348 @@ namespace loader extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Global table +__zedlllocal void ZE_APICALL +zesGetGlobalProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Global->pfnInit = loader::zesInit; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Device table +__zedlllocal void ZE_APICALL +zesGetDeviceProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Device->pfnGetProperties = loader::zesDeviceGetProperties; + loader::loaderDispatch->pSysman->Device->pfnGetState = loader::zesDeviceGetState; + loader::loaderDispatch->pSysman->Device->pfnReset = loader::zesDeviceReset; + loader::loaderDispatch->pSysman->Device->pfnProcessesGetState = loader::zesDeviceProcessesGetState; + loader::loaderDispatch->pSysman->Device->pfnPciGetProperties = loader::zesDevicePciGetProperties; + loader::loaderDispatch->pSysman->Device->pfnPciGetState = loader::zesDevicePciGetState; + loader::loaderDispatch->pSysman->Device->pfnPciGetBars = loader::zesDevicePciGetBars; + loader::loaderDispatch->pSysman->Device->pfnPciGetStats = loader::zesDevicePciGetStats; + loader::loaderDispatch->pSysman->Device->pfnEnumDiagnosticTestSuites = loader::zesDeviceEnumDiagnosticTestSuites; + loader::loaderDispatch->pSysman->Device->pfnEnumEngineGroups = loader::zesDeviceEnumEngineGroups; + loader::loaderDispatch->pSysman->Device->pfnEventRegister = loader::zesDeviceEventRegister; + loader::loaderDispatch->pSysman->Device->pfnEnumFabricPorts = loader::zesDeviceEnumFabricPorts; + loader::loaderDispatch->pSysman->Device->pfnEnumFans = loader::zesDeviceEnumFans; + loader::loaderDispatch->pSysman->Device->pfnEnumFirmwares = loader::zesDeviceEnumFirmwares; + loader::loaderDispatch->pSysman->Device->pfnEnumFrequencyDomains = loader::zesDeviceEnumFrequencyDomains; + loader::loaderDispatch->pSysman->Device->pfnEnumLeds = loader::zesDeviceEnumLeds; + loader::loaderDispatch->pSysman->Device->pfnEnumMemoryModules = loader::zesDeviceEnumMemoryModules; + loader::loaderDispatch->pSysman->Device->pfnEnumPerformanceFactorDomains = loader::zesDeviceEnumPerformanceFactorDomains; + loader::loaderDispatch->pSysman->Device->pfnEnumPowerDomains = loader::zesDeviceEnumPowerDomains; + loader::loaderDispatch->pSysman->Device->pfnGetCardPowerDomain = loader::zesDeviceGetCardPowerDomain; + loader::loaderDispatch->pSysman->Device->pfnEnumPsus = loader::zesDeviceEnumPsus; + loader::loaderDispatch->pSysman->Device->pfnEnumRasErrorSets = loader::zesDeviceEnumRasErrorSets; + loader::loaderDispatch->pSysman->Device->pfnEnumSchedulers = loader::zesDeviceEnumSchedulers; + loader::loaderDispatch->pSysman->Device->pfnEnumStandbyDomains = loader::zesDeviceEnumStandbyDomains; + loader::loaderDispatch->pSysman->Device->pfnEnumTemperatureSensors = loader::zesDeviceEnumTemperatureSensors; + loader::loaderDispatch->pSysman->Device->pfnEccAvailable = loader::zesDeviceEccAvailable; + loader::loaderDispatch->pSysman->Device->pfnEccConfigurable = loader::zesDeviceEccConfigurable; + loader::loaderDispatch->pSysman->Device->pfnGetEccState = loader::zesDeviceGetEccState; + loader::loaderDispatch->pSysman->Device->pfnSetEccState = loader::zesDeviceSetEccState; + loader::loaderDispatch->pSysman->Device->pfnGet = loader::zesDeviceGet; + loader::loaderDispatch->pSysman->Device->pfnSetOverclockWaiver = loader::zesDeviceSetOverclockWaiver; + loader::loaderDispatch->pSysman->Device->pfnGetOverclockDomains = loader::zesDeviceGetOverclockDomains; + loader::loaderDispatch->pSysman->Device->pfnGetOverclockControls = loader::zesDeviceGetOverclockControls; + loader::loaderDispatch->pSysman->Device->pfnResetOverclockSettings = loader::zesDeviceResetOverclockSettings; + loader::loaderDispatch->pSysman->Device->pfnReadOverclockState = loader::zesDeviceReadOverclockState; + loader::loaderDispatch->pSysman->Device->pfnEnumOverclockDomains = loader::zesDeviceEnumOverclockDomains; + loader::loaderDispatch->pSysman->Device->pfnResetExt = loader::zesDeviceResetExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for DeviceExp table +__zedlllocal void ZE_APICALL +zesGetDeviceExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->DeviceExp->pfnEnumEnabledVFExp = loader::zesDeviceEnumEnabledVFExp; + loader::loaderDispatch->pSysman->DeviceExp->pfnGetSubDevicePropertiesExp = loader::zesDeviceGetSubDevicePropertiesExp; + loader::loaderDispatch->pSysman->DeviceExp->pfnEnumActiveVFExp = loader::zesDeviceEnumActiveVFExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Driver table +__zedlllocal void ZE_APICALL +zesGetDriverProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Driver->pfnEventListen = loader::zesDriverEventListen; + loader::loaderDispatch->pSysman->Driver->pfnEventListenEx = loader::zesDriverEventListenEx; + loader::loaderDispatch->pSysman->Driver->pfnGet = loader::zesDriverGet; + loader::loaderDispatch->pSysman->Driver->pfnGetExtensionProperties = loader::zesDriverGetExtensionProperties; + loader::loaderDispatch->pSysman->Driver->pfnGetExtensionFunctionAddress = loader::zesDriverGetExtensionFunctionAddress; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for DriverExp table +__zedlllocal void ZE_APICALL +zesGetDriverExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->DriverExp->pfnGetDeviceByUuidExp = loader::zesDriverGetDeviceByUuidExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Diagnostics table +__zedlllocal void ZE_APICALL +zesGetDiagnosticsProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Diagnostics->pfnGetProperties = loader::zesDiagnosticsGetProperties; + loader::loaderDispatch->pSysman->Diagnostics->pfnGetTests = loader::zesDiagnosticsGetTests; + loader::loaderDispatch->pSysman->Diagnostics->pfnRunTests = loader::zesDiagnosticsRunTests; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Engine table +__zedlllocal void ZE_APICALL +zesGetEngineProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Engine->pfnGetProperties = loader::zesEngineGetProperties; + loader::loaderDispatch->pSysman->Engine->pfnGetActivity = loader::zesEngineGetActivity; + loader::loaderDispatch->pSysman->Engine->pfnGetActivityExt = loader::zesEngineGetActivityExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for FabricPort table +__zedlllocal void ZE_APICALL +zesGetFabricPortProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->FabricPort->pfnGetProperties = loader::zesFabricPortGetProperties; + loader::loaderDispatch->pSysman->FabricPort->pfnGetLinkType = loader::zesFabricPortGetLinkType; + loader::loaderDispatch->pSysman->FabricPort->pfnGetConfig = loader::zesFabricPortGetConfig; + loader::loaderDispatch->pSysman->FabricPort->pfnSetConfig = loader::zesFabricPortSetConfig; + loader::loaderDispatch->pSysman->FabricPort->pfnGetState = loader::zesFabricPortGetState; + loader::loaderDispatch->pSysman->FabricPort->pfnGetThroughput = loader::zesFabricPortGetThroughput; + loader::loaderDispatch->pSysman->FabricPort->pfnGetFabricErrorCounters = loader::zesFabricPortGetFabricErrorCounters; + loader::loaderDispatch->pSysman->FabricPort->pfnGetMultiPortThroughput = loader::zesFabricPortGetMultiPortThroughput; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Fan table +__zedlllocal void ZE_APICALL +zesGetFanProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Fan->pfnGetProperties = loader::zesFanGetProperties; + loader::loaderDispatch->pSysman->Fan->pfnGetConfig = loader::zesFanGetConfig; + loader::loaderDispatch->pSysman->Fan->pfnSetDefaultMode = loader::zesFanSetDefaultMode; + loader::loaderDispatch->pSysman->Fan->pfnSetFixedSpeedMode = loader::zesFanSetFixedSpeedMode; + loader::loaderDispatch->pSysman->Fan->pfnSetSpeedTableMode = loader::zesFanSetSpeedTableMode; + loader::loaderDispatch->pSysman->Fan->pfnGetState = loader::zesFanGetState; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Firmware table +__zedlllocal void ZE_APICALL +zesGetFirmwareProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Firmware->pfnGetProperties = loader::zesFirmwareGetProperties; + loader::loaderDispatch->pSysman->Firmware->pfnFlash = loader::zesFirmwareFlash; + loader::loaderDispatch->pSysman->Firmware->pfnGetFlashProgress = loader::zesFirmwareGetFlashProgress; + loader::loaderDispatch->pSysman->Firmware->pfnGetConsoleLogs = loader::zesFirmwareGetConsoleLogs; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for FirmwareExp table +__zedlllocal void ZE_APICALL +zesGetFirmwareExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->FirmwareExp->pfnGetSecurityVersionExp = loader::zesFirmwareGetSecurityVersionExp; + loader::loaderDispatch->pSysman->FirmwareExp->pfnSetSecurityVersionExp = loader::zesFirmwareSetSecurityVersionExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Frequency table +__zedlllocal void ZE_APICALL +zesGetFrequencyProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Frequency->pfnGetProperties = loader::zesFrequencyGetProperties; + loader::loaderDispatch->pSysman->Frequency->pfnGetAvailableClocks = loader::zesFrequencyGetAvailableClocks; + loader::loaderDispatch->pSysman->Frequency->pfnGetRange = loader::zesFrequencyGetRange; + loader::loaderDispatch->pSysman->Frequency->pfnSetRange = loader::zesFrequencySetRange; + loader::loaderDispatch->pSysman->Frequency->pfnGetState = loader::zesFrequencyGetState; + loader::loaderDispatch->pSysman->Frequency->pfnGetThrottleTime = loader::zesFrequencyGetThrottleTime; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetCapabilities = loader::zesFrequencyOcGetCapabilities; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetFrequencyTarget = loader::zesFrequencyOcGetFrequencyTarget; + loader::loaderDispatch->pSysman->Frequency->pfnOcSetFrequencyTarget = loader::zesFrequencyOcSetFrequencyTarget; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetVoltageTarget = loader::zesFrequencyOcGetVoltageTarget; + loader::loaderDispatch->pSysman->Frequency->pfnOcSetVoltageTarget = loader::zesFrequencyOcSetVoltageTarget; + loader::loaderDispatch->pSysman->Frequency->pfnOcSetMode = loader::zesFrequencyOcSetMode; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetMode = loader::zesFrequencyOcGetMode; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetIccMax = loader::zesFrequencyOcGetIccMax; + loader::loaderDispatch->pSysman->Frequency->pfnOcSetIccMax = loader::zesFrequencyOcSetIccMax; + loader::loaderDispatch->pSysman->Frequency->pfnOcGetTjMax = loader::zesFrequencyOcGetTjMax; + loader::loaderDispatch->pSysman->Frequency->pfnOcSetTjMax = loader::zesFrequencyOcSetTjMax; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Led table +__zedlllocal void ZE_APICALL +zesGetLedProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Led->pfnGetProperties = loader::zesLedGetProperties; + loader::loaderDispatch->pSysman->Led->pfnGetState = loader::zesLedGetState; + loader::loaderDispatch->pSysman->Led->pfnSetState = loader::zesLedSetState; + loader::loaderDispatch->pSysman->Led->pfnSetColor = loader::zesLedSetColor; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Memory table +__zedlllocal void ZE_APICALL +zesGetMemoryProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Memory->pfnGetProperties = loader::zesMemoryGetProperties; + loader::loaderDispatch->pSysman->Memory->pfnGetState = loader::zesMemoryGetState; + loader::loaderDispatch->pSysman->Memory->pfnGetBandwidth = loader::zesMemoryGetBandwidth; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Overclock table +__zedlllocal void ZE_APICALL +zesGetOverclockProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Overclock->pfnGetDomainProperties = loader::zesOverclockGetDomainProperties; + loader::loaderDispatch->pSysman->Overclock->pfnGetDomainVFProperties = loader::zesOverclockGetDomainVFProperties; + loader::loaderDispatch->pSysman->Overclock->pfnGetDomainControlProperties = loader::zesOverclockGetDomainControlProperties; + loader::loaderDispatch->pSysman->Overclock->pfnGetControlCurrentValue = loader::zesOverclockGetControlCurrentValue; + loader::loaderDispatch->pSysman->Overclock->pfnGetControlPendingValue = loader::zesOverclockGetControlPendingValue; + loader::loaderDispatch->pSysman->Overclock->pfnSetControlUserValue = loader::zesOverclockSetControlUserValue; + loader::loaderDispatch->pSysman->Overclock->pfnGetControlState = loader::zesOverclockGetControlState; + loader::loaderDispatch->pSysman->Overclock->pfnGetVFPointValues = loader::zesOverclockGetVFPointValues; + loader::loaderDispatch->pSysman->Overclock->pfnSetVFPointValues = loader::zesOverclockSetVFPointValues; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for PerformanceFactor table +__zedlllocal void ZE_APICALL +zesGetPerformanceFactorProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->PerformanceFactor->pfnGetProperties = loader::zesPerformanceFactorGetProperties; + loader::loaderDispatch->pSysman->PerformanceFactor->pfnGetConfig = loader::zesPerformanceFactorGetConfig; + loader::loaderDispatch->pSysman->PerformanceFactor->pfnSetConfig = loader::zesPerformanceFactorSetConfig; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Power table +__zedlllocal void ZE_APICALL +zesGetPowerProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Power->pfnGetProperties = loader::zesPowerGetProperties; + loader::loaderDispatch->pSysman->Power->pfnGetEnergyCounter = loader::zesPowerGetEnergyCounter; + loader::loaderDispatch->pSysman->Power->pfnGetLimits = loader::zesPowerGetLimits; + loader::loaderDispatch->pSysman->Power->pfnSetLimits = loader::zesPowerSetLimits; + loader::loaderDispatch->pSysman->Power->pfnGetEnergyThreshold = loader::zesPowerGetEnergyThreshold; + loader::loaderDispatch->pSysman->Power->pfnSetEnergyThreshold = loader::zesPowerSetEnergyThreshold; + loader::loaderDispatch->pSysman->Power->pfnGetLimitsExt = loader::zesPowerGetLimitsExt; + loader::loaderDispatch->pSysman->Power->pfnSetLimitsExt = loader::zesPowerSetLimitsExt; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Psu table +__zedlllocal void ZE_APICALL +zesGetPsuProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Psu->pfnGetProperties = loader::zesPsuGetProperties; + loader::loaderDispatch->pSysman->Psu->pfnGetState = loader::zesPsuGetState; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Ras table +__zedlllocal void ZE_APICALL +zesGetRasProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Ras->pfnGetProperties = loader::zesRasGetProperties; + loader::loaderDispatch->pSysman->Ras->pfnGetConfig = loader::zesRasGetConfig; + loader::loaderDispatch->pSysman->Ras->pfnSetConfig = loader::zesRasSetConfig; + loader::loaderDispatch->pSysman->Ras->pfnGetState = loader::zesRasGetState; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for RasExp table +__zedlllocal void ZE_APICALL +zesGetRasExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->RasExp->pfnGetStateExp = loader::zesRasGetStateExp; + loader::loaderDispatch->pSysman->RasExp->pfnClearStateExp = loader::zesRasClearStateExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Scheduler table +__zedlllocal void ZE_APICALL +zesGetSchedulerProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Scheduler->pfnGetProperties = loader::zesSchedulerGetProperties; + loader::loaderDispatch->pSysman->Scheduler->pfnGetCurrentMode = loader::zesSchedulerGetCurrentMode; + loader::loaderDispatch->pSysman->Scheduler->pfnGetTimeoutModeProperties = loader::zesSchedulerGetTimeoutModeProperties; + loader::loaderDispatch->pSysman->Scheduler->pfnGetTimesliceModeProperties = loader::zesSchedulerGetTimesliceModeProperties; + loader::loaderDispatch->pSysman->Scheduler->pfnSetTimeoutMode = loader::zesSchedulerSetTimeoutMode; + loader::loaderDispatch->pSysman->Scheduler->pfnSetTimesliceMode = loader::zesSchedulerSetTimesliceMode; + loader::loaderDispatch->pSysman->Scheduler->pfnSetExclusiveMode = loader::zesSchedulerSetExclusiveMode; + loader::loaderDispatch->pSysman->Scheduler->pfnSetComputeUnitDebugMode = loader::zesSchedulerSetComputeUnitDebugMode; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Standby table +__zedlllocal void ZE_APICALL +zesGetStandbyProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Standby->pfnGetProperties = loader::zesStandbyGetProperties; + loader::loaderDispatch->pSysman->Standby->pfnGetMode = loader::zesStandbyGetMode; + loader::loaderDispatch->pSysman->Standby->pfnSetMode = loader::zesStandbySetMode; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Temperature table +__zedlllocal void ZE_APICALL +zesGetTemperatureProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->Temperature->pfnGetProperties = loader::zesTemperatureGetProperties; + loader::loaderDispatch->pSysman->Temperature->pfnGetConfig = loader::zesTemperatureGetConfig; + loader::loaderDispatch->pSysman->Temperature->pfnSetConfig = loader::zesTemperatureSetConfig; + loader::loaderDispatch->pSysman->Temperature->pfnGetState = loader::zesTemperatureGetState; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for VFManagementExp table +__zedlllocal void ZE_APICALL +zesGetVFManagementExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFCapabilitiesExp = loader::zesVFManagementGetVFCapabilitiesExp; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFMemoryUtilizationExp2 = loader::zesVFManagementGetVFMemoryUtilizationExp2; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFEngineUtilizationExp2 = loader::zesVFManagementGetVFEngineUtilizationExp2; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFCapabilitiesExp2 = loader::zesVFManagementGetVFCapabilitiesExp2; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFPropertiesExp = loader::zesVFManagementGetVFPropertiesExp; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFMemoryUtilizationExp = loader::zesVFManagementGetVFMemoryUtilizationExp; + loader::loaderDispatch->pSysman->VFManagementExp->pfnGetVFEngineUtilizationExp = loader::zesVFManagementGetVFEngineUtilizationExp; + loader::loaderDispatch->pSysman->VFManagementExp->pfnSetVFTelemetryModeExp = loader::zesVFManagementSetVFTelemetryModeExp; + loader::loaderDispatch->pSysman->VFManagementExp->pfnSetVFTelemetrySamplingIntervalExp = loader::zesVFManagementSetVFTelemetrySamplingIntervalExp; +} + + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Global table /// with current process' addresses @@ -4643,9 +5007,11 @@ zesGetGlobalProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Global = new zes_global_dditable_t; if (version >= ZE_API_VERSION_1_5) { - pDdiTable->pfnInit = loader::zesInit; + pDdiTable->pfnInit = loader::zesInit; } + zesGetGlobalProcAddrTableLegacy(); } else { @@ -4722,117 +5088,267 @@ zesGetDeviceProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Device = new zes_device_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesDeviceGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesDeviceGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesDeviceGetState; + } else { pDdiTable->pfnGetState = loader::zesDeviceGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReset = loader_driver_ddi::zesDeviceReset; + } else { pDdiTable->pfnReset = loader::zesDeviceReset; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnProcessesGetState = loader_driver_ddi::zesDeviceProcessesGetState; + } else { pDdiTable->pfnProcessesGetState = loader::zesDeviceProcessesGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPciGetProperties = loader_driver_ddi::zesDevicePciGetProperties; + } else { pDdiTable->pfnPciGetProperties = loader::zesDevicePciGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPciGetState = loader_driver_ddi::zesDevicePciGetState; + } else { pDdiTable->pfnPciGetState = loader::zesDevicePciGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPciGetBars = loader_driver_ddi::zesDevicePciGetBars; + } else { pDdiTable->pfnPciGetBars = loader::zesDevicePciGetBars; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnPciGetStats = loader_driver_ddi::zesDevicePciGetStats; + } else { pDdiTable->pfnPciGetStats = loader::zesDevicePciGetStats; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumDiagnosticTestSuites = loader_driver_ddi::zesDeviceEnumDiagnosticTestSuites; + } else { pDdiTable->pfnEnumDiagnosticTestSuites = loader::zesDeviceEnumDiagnosticTestSuites; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumEngineGroups = loader_driver_ddi::zesDeviceEnumEngineGroups; + } else { pDdiTable->pfnEnumEngineGroups = loader::zesDeviceEnumEngineGroups; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEventRegister = loader_driver_ddi::zesDeviceEventRegister; + } else { pDdiTable->pfnEventRegister = loader::zesDeviceEventRegister; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumFabricPorts = loader_driver_ddi::zesDeviceEnumFabricPorts; + } else { pDdiTable->pfnEnumFabricPorts = loader::zesDeviceEnumFabricPorts; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumFans = loader_driver_ddi::zesDeviceEnumFans; + } else { pDdiTable->pfnEnumFans = loader::zesDeviceEnumFans; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumFirmwares = loader_driver_ddi::zesDeviceEnumFirmwares; + } else { pDdiTable->pfnEnumFirmwares = loader::zesDeviceEnumFirmwares; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumFrequencyDomains = loader_driver_ddi::zesDeviceEnumFrequencyDomains; + } else { pDdiTable->pfnEnumFrequencyDomains = loader::zesDeviceEnumFrequencyDomains; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumLeds = loader_driver_ddi::zesDeviceEnumLeds; + } else { pDdiTable->pfnEnumLeds = loader::zesDeviceEnumLeds; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumMemoryModules = loader_driver_ddi::zesDeviceEnumMemoryModules; + } else { pDdiTable->pfnEnumMemoryModules = loader::zesDeviceEnumMemoryModules; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumPerformanceFactorDomains = loader_driver_ddi::zesDeviceEnumPerformanceFactorDomains; + } else { pDdiTable->pfnEnumPerformanceFactorDomains = loader::zesDeviceEnumPerformanceFactorDomains; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumPowerDomains = loader_driver_ddi::zesDeviceEnumPowerDomains; + } else { pDdiTable->pfnEnumPowerDomains = loader::zesDeviceEnumPowerDomains; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetCardPowerDomain = loader_driver_ddi::zesDeviceGetCardPowerDomain; + } else { pDdiTable->pfnGetCardPowerDomain = loader::zesDeviceGetCardPowerDomain; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumPsus = loader_driver_ddi::zesDeviceEnumPsus; + } else { pDdiTable->pfnEnumPsus = loader::zesDeviceEnumPsus; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumRasErrorSets = loader_driver_ddi::zesDeviceEnumRasErrorSets; + } else { pDdiTable->pfnEnumRasErrorSets = loader::zesDeviceEnumRasErrorSets; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumSchedulers = loader_driver_ddi::zesDeviceEnumSchedulers; + } else { pDdiTable->pfnEnumSchedulers = loader::zesDeviceEnumSchedulers; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumStandbyDomains = loader_driver_ddi::zesDeviceEnumStandbyDomains; + } else { pDdiTable->pfnEnumStandbyDomains = loader::zesDeviceEnumStandbyDomains; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumTemperatureSensors = loader_driver_ddi::zesDeviceEnumTemperatureSensors; + } else { pDdiTable->pfnEnumTemperatureSensors = loader::zesDeviceEnumTemperatureSensors; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEccAvailable = loader_driver_ddi::zesDeviceEccAvailable; + } else { pDdiTable->pfnEccAvailable = loader::zesDeviceEccAvailable; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEccConfigurable = loader_driver_ddi::zesDeviceEccConfigurable; + } else { pDdiTable->pfnEccConfigurable = loader::zesDeviceEccConfigurable; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetEccState = loader_driver_ddi::zesDeviceGetEccState; + } else { pDdiTable->pfnGetEccState = loader::zesDeviceGetEccState; } + } if (version >= ZE_API_VERSION_1_4) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetEccState = loader_driver_ddi::zesDeviceSetEccState; + } else { pDdiTable->pfnSetEccState = loader::zesDeviceSetEccState; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGet = loader_driver_ddi::zesDeviceGet; + } else { pDdiTable->pfnGet = loader::zesDeviceGet; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetOverclockWaiver = loader_driver_ddi::zesDeviceSetOverclockWaiver; + } else { pDdiTable->pfnSetOverclockWaiver = loader::zesDeviceSetOverclockWaiver; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetOverclockDomains = loader_driver_ddi::zesDeviceGetOverclockDomains; + } else { pDdiTable->pfnGetOverclockDomains = loader::zesDeviceGetOverclockDomains; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetOverclockControls = loader_driver_ddi::zesDeviceGetOverclockControls; + } else { pDdiTable->pfnGetOverclockControls = loader::zesDeviceGetOverclockControls; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnResetOverclockSettings = loader_driver_ddi::zesDeviceResetOverclockSettings; + } else { pDdiTable->pfnResetOverclockSettings = loader::zesDeviceResetOverclockSettings; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadOverclockState = loader_driver_ddi::zesDeviceReadOverclockState; + } else { pDdiTable->pfnReadOverclockState = loader::zesDeviceReadOverclockState; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumOverclockDomains = loader_driver_ddi::zesDeviceEnumOverclockDomains; + } else { pDdiTable->pfnEnumOverclockDomains = loader::zesDeviceEnumOverclockDomains; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnResetExt = loader_driver_ddi::zesDeviceResetExt; + } else { pDdiTable->pfnResetExt = loader::zesDeviceResetExt; } + } + zesGetDeviceProcAddrTableLegacy(); } else { @@ -4899,15 +5415,29 @@ zesGetDeviceExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->DeviceExp = new zes_device_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumEnabledVFExp = loader_driver_ddi::zesDeviceEnumEnabledVFExp; + } else { pDdiTable->pfnEnumEnabledVFExp = loader::zesDeviceEnumEnabledVFExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSubDevicePropertiesExp = loader_driver_ddi::zesDeviceGetSubDevicePropertiesExp; + } else { pDdiTable->pfnGetSubDevicePropertiesExp = loader::zesDeviceGetSubDevicePropertiesExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnumActiveVFExp = loader_driver_ddi::zesDeviceEnumActiveVFExp; + } else { pDdiTable->pfnEnumActiveVFExp = loader::zesDeviceEnumActiveVFExp; } + } + zesGetDeviceExpProcAddrTableLegacy(); } else { @@ -4984,21 +5514,39 @@ zesGetDriverProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Driver = new zes_driver_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEventListen = loader_driver_ddi::zesDriverEventListen; + } else { pDdiTable->pfnEventListen = loader::zesDriverEventListen; } + } if (version >= ZE_API_VERSION_1_1) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEventListenEx = loader_driver_ddi::zesDriverEventListenEx; + } else { pDdiTable->pfnEventListenEx = loader::zesDriverEventListenEx; } + } if (version >= ZE_API_VERSION_1_5) { - pDdiTable->pfnGet = loader::zesDriverGet; + pDdiTable->pfnGet = loader::zesDriverGet; } if (version >= ZE_API_VERSION_1_8) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExtensionProperties = loader_driver_ddi::zesDriverGetExtensionProperties; + } else { pDdiTable->pfnGetExtensionProperties = loader::zesDriverGetExtensionProperties; } + } if (version >= ZE_API_VERSION_1_8) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExtensionFunctionAddress = loader_driver_ddi::zesDriverGetExtensionFunctionAddress; + } else { pDdiTable->pfnGetExtensionFunctionAddress = loader::zesDriverGetExtensionFunctionAddress; } + } + zesGetDriverProcAddrTableLegacy(); } else { @@ -5065,9 +5613,15 @@ zesGetDriverExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->DriverExp = new zes_driver_exp_dditable_t; if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDeviceByUuidExp = loader_driver_ddi::zesDriverGetDeviceByUuidExp; + } else { pDdiTable->pfnGetDeviceByUuidExp = loader::zesDriverGetDeviceByUuidExp; } + } + zesGetDriverExpProcAddrTableLegacy(); } else { @@ -5144,15 +5698,29 @@ zesGetDiagnosticsProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Diagnostics = new zes_diagnostics_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesDiagnosticsGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesDiagnosticsGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetTests = loader_driver_ddi::zesDiagnosticsGetTests; + } else { pDdiTable->pfnGetTests = loader::zesDiagnosticsGetTests; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnRunTests = loader_driver_ddi::zesDiagnosticsRunTests; + } else { pDdiTable->pfnRunTests = loader::zesDiagnosticsRunTests; } + } + zesGetDiagnosticsProcAddrTableLegacy(); } else { @@ -5229,15 +5797,29 @@ zesGetEngineProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Engine = new zes_engine_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesEngineGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesEngineGetProperties; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetActivity = loader_driver_ddi::zesEngineGetActivity; + } else { pDdiTable->pfnGetActivity = loader::zesEngineGetActivity; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetActivityExt = loader_driver_ddi::zesEngineGetActivityExt; + } else { pDdiTable->pfnGetActivityExt = loader::zesEngineGetActivityExt; } + } + zesGetEngineProcAddrTableLegacy(); } else { @@ -5314,30 +5896,64 @@ zesGetFabricPortProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->FabricPort = new zes_fabric_port_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesFabricPortGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesFabricPortGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetLinkType = loader_driver_ddi::zesFabricPortGetLinkType; + } else { pDdiTable->pfnGetLinkType = loader::zesFabricPortGetLinkType; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConfig = loader_driver_ddi::zesFabricPortGetConfig; + } else { pDdiTable->pfnGetConfig = loader::zesFabricPortGetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetConfig = loader_driver_ddi::zesFabricPortSetConfig; + } else { pDdiTable->pfnSetConfig = loader::zesFabricPortSetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesFabricPortGetState; + } else { pDdiTable->pfnGetState = loader::zesFabricPortGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetThroughput = loader_driver_ddi::zesFabricPortGetThroughput; + } else { pDdiTable->pfnGetThroughput = loader::zesFabricPortGetThroughput; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFabricErrorCounters = loader_driver_ddi::zesFabricPortGetFabricErrorCounters; + } else { pDdiTable->pfnGetFabricErrorCounters = loader::zesFabricPortGetFabricErrorCounters; } + } if (version >= ZE_API_VERSION_1_7) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetMultiPortThroughput = loader_driver_ddi::zesFabricPortGetMultiPortThroughput; + } else { pDdiTable->pfnGetMultiPortThroughput = loader::zesFabricPortGetMultiPortThroughput; } + } + zesGetFabricPortProcAddrTableLegacy(); } else { @@ -5414,24 +6030,50 @@ zesGetFanProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Fan = new zes_fan_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesFanGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesFanGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConfig = loader_driver_ddi::zesFanGetConfig; + } else { pDdiTable->pfnGetConfig = loader::zesFanGetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetDefaultMode = loader_driver_ddi::zesFanSetDefaultMode; + } else { pDdiTable->pfnSetDefaultMode = loader::zesFanSetDefaultMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetFixedSpeedMode = loader_driver_ddi::zesFanSetFixedSpeedMode; + } else { pDdiTable->pfnSetFixedSpeedMode = loader::zesFanSetFixedSpeedMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetSpeedTableMode = loader_driver_ddi::zesFanSetSpeedTableMode; + } else { pDdiTable->pfnSetSpeedTableMode = loader::zesFanSetSpeedTableMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesFanGetState; + } else { pDdiTable->pfnGetState = loader::zesFanGetState; } + } + zesGetFanProcAddrTableLegacy(); } else { @@ -5508,18 +6150,36 @@ zesGetFirmwareProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Firmware = new zes_firmware_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesFirmwareGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesFirmwareGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnFlash = loader_driver_ddi::zesFirmwareFlash; + } else { pDdiTable->pfnFlash = loader::zesFirmwareFlash; } + } if (version >= ZE_API_VERSION_1_8) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetFlashProgress = loader_driver_ddi::zesFirmwareGetFlashProgress; + } else { pDdiTable->pfnGetFlashProgress = loader::zesFirmwareGetFlashProgress; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConsoleLogs = loader_driver_ddi::zesFirmwareGetConsoleLogs; + } else { pDdiTable->pfnGetConsoleLogs = loader::zesFirmwareGetConsoleLogs; } + } + zesGetFirmwareProcAddrTableLegacy(); } else { @@ -5586,12 +6246,22 @@ zesGetFirmwareExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->FirmwareExp = new zes_firmware_exp_dditable_t; if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetSecurityVersionExp = loader_driver_ddi::zesFirmwareGetSecurityVersionExp; + } else { pDdiTable->pfnGetSecurityVersionExp = loader::zesFirmwareGetSecurityVersionExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetSecurityVersionExp = loader_driver_ddi::zesFirmwareSetSecurityVersionExp; + } else { pDdiTable->pfnSetSecurityVersionExp = loader::zesFirmwareSetSecurityVersionExp; } + } + zesGetFirmwareExpProcAddrTableLegacy(); } else { @@ -5668,57 +6338,127 @@ zesGetFrequencyProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Frequency = new zes_frequency_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesFrequencyGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesFrequencyGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetAvailableClocks = loader_driver_ddi::zesFrequencyGetAvailableClocks; + } else { pDdiTable->pfnGetAvailableClocks = loader::zesFrequencyGetAvailableClocks; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetRange = loader_driver_ddi::zesFrequencyGetRange; + } else { pDdiTable->pfnGetRange = loader::zesFrequencyGetRange; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetRange = loader_driver_ddi::zesFrequencySetRange; + } else { pDdiTable->pfnSetRange = loader::zesFrequencySetRange; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesFrequencyGetState; + } else { pDdiTable->pfnGetState = loader::zesFrequencyGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetThrottleTime = loader_driver_ddi::zesFrequencyGetThrottleTime; + } else { pDdiTable->pfnGetThrottleTime = loader::zesFrequencyGetThrottleTime; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetCapabilities = loader_driver_ddi::zesFrequencyOcGetCapabilities; + } else { pDdiTable->pfnOcGetCapabilities = loader::zesFrequencyOcGetCapabilities; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetFrequencyTarget = loader_driver_ddi::zesFrequencyOcGetFrequencyTarget; + } else { pDdiTable->pfnOcGetFrequencyTarget = loader::zesFrequencyOcGetFrequencyTarget; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcSetFrequencyTarget = loader_driver_ddi::zesFrequencyOcSetFrequencyTarget; + } else { pDdiTable->pfnOcSetFrequencyTarget = loader::zesFrequencyOcSetFrequencyTarget; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetVoltageTarget = loader_driver_ddi::zesFrequencyOcGetVoltageTarget; + } else { pDdiTable->pfnOcGetVoltageTarget = loader::zesFrequencyOcGetVoltageTarget; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcSetVoltageTarget = loader_driver_ddi::zesFrequencyOcSetVoltageTarget; + } else { pDdiTable->pfnOcSetVoltageTarget = loader::zesFrequencyOcSetVoltageTarget; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcSetMode = loader_driver_ddi::zesFrequencyOcSetMode; + } else { pDdiTable->pfnOcSetMode = loader::zesFrequencyOcSetMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetMode = loader_driver_ddi::zesFrequencyOcGetMode; + } else { pDdiTable->pfnOcGetMode = loader::zesFrequencyOcGetMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetIccMax = loader_driver_ddi::zesFrequencyOcGetIccMax; + } else { pDdiTable->pfnOcGetIccMax = loader::zesFrequencyOcGetIccMax; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcSetIccMax = loader_driver_ddi::zesFrequencyOcSetIccMax; + } else { pDdiTable->pfnOcSetIccMax = loader::zesFrequencyOcSetIccMax; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcGetTjMax = loader_driver_ddi::zesFrequencyOcGetTjMax; + } else { pDdiTable->pfnOcGetTjMax = loader::zesFrequencyOcGetTjMax; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOcSetTjMax = loader_driver_ddi::zesFrequencyOcSetTjMax; + } else { pDdiTable->pfnOcSetTjMax = loader::zesFrequencyOcSetTjMax; } + } + zesGetFrequencyProcAddrTableLegacy(); } else { @@ -5795,18 +6535,36 @@ zesGetLedProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Led = new zes_led_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesLedGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesLedGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesLedGetState; + } else { pDdiTable->pfnGetState = loader::zesLedGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetState = loader_driver_ddi::zesLedSetState; + } else { pDdiTable->pfnSetState = loader::zesLedSetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetColor = loader_driver_ddi::zesLedSetColor; + } else { pDdiTable->pfnSetColor = loader::zesLedSetColor; } + } + zesGetLedProcAddrTableLegacy(); } else { @@ -5883,15 +6641,29 @@ zesGetMemoryProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Memory = new zes_memory_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesMemoryGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesMemoryGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesMemoryGetState; + } else { pDdiTable->pfnGetState = loader::zesMemoryGetState; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetBandwidth = loader_driver_ddi::zesMemoryGetBandwidth; + } else { pDdiTable->pfnGetBandwidth = loader::zesMemoryGetBandwidth; } + } + zesGetMemoryProcAddrTableLegacy(); } else { @@ -5972,33 +6744,71 @@ zesGetOverclockProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Overclock = new zes_overclock_dditable_t; if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDomainProperties = loader_driver_ddi::zesOverclockGetDomainProperties; + } else { pDdiTable->pfnGetDomainProperties = loader::zesOverclockGetDomainProperties; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDomainVFProperties = loader_driver_ddi::zesOverclockGetDomainVFProperties; + } else { pDdiTable->pfnGetDomainVFProperties = loader::zesOverclockGetDomainVFProperties; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDomainControlProperties = loader_driver_ddi::zesOverclockGetDomainControlProperties; + } else { pDdiTable->pfnGetDomainControlProperties = loader::zesOverclockGetDomainControlProperties; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetControlCurrentValue = loader_driver_ddi::zesOverclockGetControlCurrentValue; + } else { pDdiTable->pfnGetControlCurrentValue = loader::zesOverclockGetControlCurrentValue; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetControlPendingValue = loader_driver_ddi::zesOverclockGetControlPendingValue; + } else { pDdiTable->pfnGetControlPendingValue = loader::zesOverclockGetControlPendingValue; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetControlUserValue = loader_driver_ddi::zesOverclockSetControlUserValue; + } else { pDdiTable->pfnSetControlUserValue = loader::zesOverclockSetControlUserValue; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetControlState = loader_driver_ddi::zesOverclockGetControlState; + } else { pDdiTable->pfnGetControlState = loader::zesOverclockGetControlState; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFPointValues = loader_driver_ddi::zesOverclockGetVFPointValues; + } else { pDdiTable->pfnGetVFPointValues = loader::zesOverclockGetVFPointValues; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetVFPointValues = loader_driver_ddi::zesOverclockSetVFPointValues; + } else { pDdiTable->pfnSetVFPointValues = loader::zesOverclockSetVFPointValues; } + } + zesGetOverclockProcAddrTableLegacy(); } else { @@ -6075,15 +6885,29 @@ zesGetPerformanceFactorProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->PerformanceFactor = new zes_performance_factor_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesPerformanceFactorGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesPerformanceFactorGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConfig = loader_driver_ddi::zesPerformanceFactorGetConfig; + } else { pDdiTable->pfnGetConfig = loader::zesPerformanceFactorGetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetConfig = loader_driver_ddi::zesPerformanceFactorSetConfig; + } else { pDdiTable->pfnSetConfig = loader::zesPerformanceFactorSetConfig; } + } + zesGetPerformanceFactorProcAddrTableLegacy(); } else { @@ -6160,30 +6984,64 @@ zesGetPowerProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Power = new zes_power_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesPowerGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesPowerGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetEnergyCounter = loader_driver_ddi::zesPowerGetEnergyCounter; + } else { pDdiTable->pfnGetEnergyCounter = loader::zesPowerGetEnergyCounter; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetLimits = loader_driver_ddi::zesPowerGetLimits; + } else { pDdiTable->pfnGetLimits = loader::zesPowerGetLimits; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetLimits = loader_driver_ddi::zesPowerSetLimits; + } else { pDdiTable->pfnSetLimits = loader::zesPowerSetLimits; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetEnergyThreshold = loader_driver_ddi::zesPowerGetEnergyThreshold; + } else { pDdiTable->pfnGetEnergyThreshold = loader::zesPowerGetEnergyThreshold; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetEnergyThreshold = loader_driver_ddi::zesPowerSetEnergyThreshold; + } else { pDdiTable->pfnSetEnergyThreshold = loader::zesPowerSetEnergyThreshold; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetLimitsExt = loader_driver_ddi::zesPowerGetLimitsExt; + } else { pDdiTable->pfnGetLimitsExt = loader::zesPowerGetLimitsExt; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetLimitsExt = loader_driver_ddi::zesPowerSetLimitsExt; + } else { pDdiTable->pfnSetLimitsExt = loader::zesPowerSetLimitsExt; } + } + zesGetPowerProcAddrTableLegacy(); } else { @@ -6260,12 +7118,22 @@ zesGetPsuProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Psu = new zes_psu_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesPsuGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesPsuGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesPsuGetState; + } else { pDdiTable->pfnGetState = loader::zesPsuGetState; } + } + zesGetPsuProcAddrTableLegacy(); } else { @@ -6342,18 +7210,36 @@ zesGetRasProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Ras = new zes_ras_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesRasGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesRasGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConfig = loader_driver_ddi::zesRasGetConfig; + } else { pDdiTable->pfnGetConfig = loader::zesRasGetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetConfig = loader_driver_ddi::zesRasSetConfig; + } else { pDdiTable->pfnSetConfig = loader::zesRasSetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesRasGetState; + } else { pDdiTable->pfnGetState = loader::zesRasGetState; } + } + zesGetRasProcAddrTableLegacy(); } else { @@ -6420,12 +7306,22 @@ zesGetRasExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->RasExp = new zes_ras_exp_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetStateExp = loader_driver_ddi::zesRasGetStateExp; + } else { pDdiTable->pfnGetStateExp = loader::zesRasGetStateExp; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnClearStateExp = loader_driver_ddi::zesRasClearStateExp; + } else { pDdiTable->pfnClearStateExp = loader::zesRasClearStateExp; } + } + zesGetRasExpProcAddrTableLegacy(); } else { @@ -6502,30 +7398,64 @@ zesGetSchedulerProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Scheduler = new zes_scheduler_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesSchedulerGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesSchedulerGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetCurrentMode = loader_driver_ddi::zesSchedulerGetCurrentMode; + } else { pDdiTable->pfnGetCurrentMode = loader::zesSchedulerGetCurrentMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetTimeoutModeProperties = loader_driver_ddi::zesSchedulerGetTimeoutModeProperties; + } else { pDdiTable->pfnGetTimeoutModeProperties = loader::zesSchedulerGetTimeoutModeProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetTimesliceModeProperties = loader_driver_ddi::zesSchedulerGetTimesliceModeProperties; + } else { pDdiTable->pfnGetTimesliceModeProperties = loader::zesSchedulerGetTimesliceModeProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetTimeoutMode = loader_driver_ddi::zesSchedulerSetTimeoutMode; + } else { pDdiTable->pfnSetTimeoutMode = loader::zesSchedulerSetTimeoutMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetTimesliceMode = loader_driver_ddi::zesSchedulerSetTimesliceMode; + } else { pDdiTable->pfnSetTimesliceMode = loader::zesSchedulerSetTimesliceMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetExclusiveMode = loader_driver_ddi::zesSchedulerSetExclusiveMode; + } else { pDdiTable->pfnSetExclusiveMode = loader::zesSchedulerSetExclusiveMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetComputeUnitDebugMode = loader_driver_ddi::zesSchedulerSetComputeUnitDebugMode; + } else { pDdiTable->pfnSetComputeUnitDebugMode = loader::zesSchedulerSetComputeUnitDebugMode; } + } + zesGetSchedulerProcAddrTableLegacy(); } else { @@ -6602,15 +7532,29 @@ zesGetStandbyProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Standby = new zes_standby_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesStandbyGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesStandbyGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetMode = loader_driver_ddi::zesStandbyGetMode; + } else { pDdiTable->pfnGetMode = loader::zesStandbyGetMode; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetMode = loader_driver_ddi::zesStandbySetMode; + } else { pDdiTable->pfnSetMode = loader::zesStandbySetMode; } + } + zesGetStandbyProcAddrTableLegacy(); } else { @@ -6687,18 +7631,36 @@ zesGetTemperatureProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->Temperature = new zes_temperature_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zesTemperatureGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zesTemperatureGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConfig = loader_driver_ddi::zesTemperatureGetConfig; + } else { pDdiTable->pfnGetConfig = loader::zesTemperatureGetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetConfig = loader_driver_ddi::zesTemperatureSetConfig; + } else { pDdiTable->pfnSetConfig = loader::zesTemperatureSetConfig; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetState = loader_driver_ddi::zesTemperatureGetState; + } else { pDdiTable->pfnGetState = loader::zesTemperatureGetState; } + } + zesGetTemperatureProcAddrTableLegacy(); } else { @@ -6765,33 +7727,71 @@ zesGetVFManagementExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pSysman->VFManagementExp = new zes_vf_management_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFCapabilitiesExp = loader_driver_ddi::zesVFManagementGetVFCapabilitiesExp; + } else { pDdiTable->pfnGetVFCapabilitiesExp = loader::zesVFManagementGetVFCapabilitiesExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFMemoryUtilizationExp2 = loader_driver_ddi::zesVFManagementGetVFMemoryUtilizationExp2; + } else { pDdiTable->pfnGetVFMemoryUtilizationExp2 = loader::zesVFManagementGetVFMemoryUtilizationExp2; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFEngineUtilizationExp2 = loader_driver_ddi::zesVFManagementGetVFEngineUtilizationExp2; + } else { pDdiTable->pfnGetVFEngineUtilizationExp2 = loader::zesVFManagementGetVFEngineUtilizationExp2; } + } if (version >= ZE_API_VERSION_1_12) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFCapabilitiesExp2 = loader_driver_ddi::zesVFManagementGetVFCapabilitiesExp2; + } else { pDdiTable->pfnGetVFCapabilitiesExp2 = loader::zesVFManagementGetVFCapabilitiesExp2; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFPropertiesExp = loader_driver_ddi::zesVFManagementGetVFPropertiesExp; + } else { pDdiTable->pfnGetVFPropertiesExp = loader::zesVFManagementGetVFPropertiesExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFMemoryUtilizationExp = loader_driver_ddi::zesVFManagementGetVFMemoryUtilizationExp; + } else { pDdiTable->pfnGetVFMemoryUtilizationExp = loader::zesVFManagementGetVFMemoryUtilizationExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetVFEngineUtilizationExp = loader_driver_ddi::zesVFManagementGetVFEngineUtilizationExp; + } else { pDdiTable->pfnGetVFEngineUtilizationExp = loader::zesVFManagementGetVFEngineUtilizationExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetVFTelemetryModeExp = loader_driver_ddi::zesVFManagementSetVFTelemetryModeExp; + } else { pDdiTable->pfnSetVFTelemetryModeExp = loader::zesVFManagementSetVFTelemetryModeExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetVFTelemetrySamplingIntervalExp = loader_driver_ddi::zesVFManagementSetVFTelemetrySamplingIntervalExp; + } else { pDdiTable->pfnSetVFTelemetrySamplingIntervalExp = loader::zesVFManagementSetVFTelemetrySamplingIntervalExp; } + } + zesGetVFManagementExpProcAddrTableLegacy(); } else { @@ -6816,4 +7816,4 @@ zesGetVFManagementExpProcAddrTable( #if defined(__cplusplus) }; -#endif +#endif \ No newline at end of file diff --git a/source/loader/zes_ldrddi.h b/source/loader/zes_ldrddi.h index 53573c17..a9438284 100644 --- a/source/loader/zes_ldrddi.h +++ b/source/loader/zes_ldrddi.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -70,3 +70,1247 @@ namespace loader using zes_vf_factory_t = singleton_factory_t < zes_vf_object_t, zes_vf_handle_t >; } + +namespace loader_driver_ddi +{ + __zedlllocal void ZE_APICALL + zesDestroyDDiDriverTables(zes_dditable_driver_t* pDdiTable); + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetExtensionProperties( + zes_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of extension properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of extension properties available. + ///< if count is greater than the number of extension properties available, + ///< then the driver shall update the value with the correct number of + ///< extension properties available. + zes_driver_extension_properties_t* pExtensionProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< extension properties. + ///< if count is less than the number of extension properties available, + ///< then driver shall only retrieve that number of extension properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetExtensionFunctionAddress( + zes_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char* name, ///< [in] extension function name + void** ppFunctionAddress ///< [out] pointer to function pointer + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGet( + zes_driver_handle_t hDriver, ///< [in] handle of the sysman driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of sysman devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sysman devices available. + ///< if count is greater than the number of sysman devices available, then + ///< the driver shall update the value with the correct number of sysman + ///< devices available. + zes_device_handle_t* phDevices ///< [in,out][optional][range(0, *pCount)] array of handle of sysman devices. + ///< if count is less than the number of sysman devices available, then + ///< driver shall only retrieve that number of sysman devices. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetProperties( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_device_properties_t* pProperties ///< [in,out] Structure that will contain information about the device. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_device_state_t* pState ///< [in,out] Structure that will contain information about the device. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceReset( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + ze_bool_t force ///< [in] If set to true, all applications that are currently using the + ///< device will be forcibly killed. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceResetExt( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + zes_reset_properties_t* pProperties ///< [in] Device reset properties to apply + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceProcessesGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + uint32_t* pCount, ///< [in,out] pointer to the number of processes. + ///< if count is zero, then the driver shall update the value with the + ///< total number of processes currently attached to the device. + ///< if count is greater than the number of processes currently attached to + ///< the device, then the driver shall update the value with the correct + ///< number of processes. + zes_process_state_t* pProcesses ///< [in,out][optional][range(0, *pCount)] array of process information. + ///< if count is less than the number of processes currently attached to + ///< the device, then the driver shall only retrieve information about that + ///< number of processes. In this case, the return code will ::ZE_RESULT_ERROR_INVALID_SIZE. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetProperties( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_properties_t* pProperties ///< [in,out] Will contain the PCI properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_state_t* pState ///< [in,out] Will contain the PCI properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetBars( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of PCI bars. + ///< if count is zero, then the driver shall update the value with the + ///< total number of PCI bars that are setup. + ///< if count is greater than the number of PCI bars that are setup, then + ///< the driver shall update the value with the correct number of PCI bars. + zes_pci_bar_properties_t* pProperties ///< [in,out][optional][range(0, *pCount)] array of information about setup + ///< PCI bars. + ///< if count is less than the number of PCI bars that are setup, then the + ///< driver shall only retrieve information about that number of PCI bars. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetStats( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_stats_t* pStats ///< [in,out] Will contain a snapshot of the latest stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceSetOverclockWaiver( + zes_device_handle_t hDevice ///< [in] Sysman handle of the device. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetOverclockDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pOverclockDomains ///< [in,out] Returns the overclock domains that are supported (a bit for + ///< each of enum ::zes_overclock_domain_t). If no bits are set, the device + ///< doesn't support overclocking. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetOverclockControls( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_overclock_domain_t domainType, ///< [in] Domain type. + uint32_t* pAvailableControls ///< [in,out] Returns the overclock controls that are supported for the + ///< specified overclock domain (a bit for each of enum + ///< ::zes_overclock_control_t). + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceResetOverclockSettings( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + ze_bool_t onShippedState ///< [in] True will reset to shipped state; false will reset to + ///< manufacturing state + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceReadOverclockState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_overclock_mode_t* pOverclockMode, ///< [out] One of overclock mode. + ze_bool_t* pWaiverSetting, ///< [out] Waiver setting: 0 = Waiver not set, 1 = waiver has been set. + ze_bool_t* pOverclockState, ///< [out] Current settings 0 =manufacturing state, 1= shipped state).. + zes_pending_action_t* pPendingAction, ///< [out] This enum is returned when the driver attempts to set an + ///< overclock control or reset overclock settings. + ze_bool_t* pPendingReset ///< [out] Pending reset 0 =manufacturing state, 1= shipped state).. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumOverclockDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_overclock_handle_t* phDomainHandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_properties_t* pDomainProperties ///< [in,out] The overclock properties for the specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainVFProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_property_t* pVFProperties ///< [in,out] The VF min,max,step for a specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainControlProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Handle for the component. + zes_control_property_t* pControlProperties ///< [in,out] overclock control values. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlCurrentValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component. + zes_overclock_control_t DomainControl, ///< [in] Overclock Control. + double* pValue ///< [in,out] Getting overclock control value for the specified control. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlPendingValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Overclock Control. + double* pValue ///< [out] Returns the pending value for a given control. The units and + ///< format of the value depend on the control type. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockSetControlUserValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Domain Control. + double pValue, ///< [in] The new value of the control. The units and format of the value + ///< depend on the control type. + zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlState( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Domain Control. + zes_control_state_t* pControlState, ///< [out] Current overclock control state. + zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting. + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetVFPointValues( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read. + zes_vf_array_type_t VFArrayType, ///< [in] User,Default or Live VF array to read from + uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1). + uint32_t* PointValue ///< [out] Returns the frequency in 1kHz units or voltage in millivolt + ///< units from the custom V-F curve at the specified zero-based index + ); + __zedlllocal ze_result_t ZE_APICALL + zesOverclockSetVFPointValues( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read. + uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1). + uint32_t PointValue ///< [in] Writes frequency in 1kHz units or voltage in millivolt units to + ///< custom V-F curve at the specified zero-based index + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumDiagnosticTestSuites( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_diag_handle_t* phDiagnostics ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsGetProperties( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + zes_diag_properties_t* pProperties ///< [in,out] Structure describing the properties of a diagnostics test + ///< suite + ); + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsGetTests( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] pointer to the number of tests. + ///< if count is zero, then the driver shall update the value with the + ///< total number of tests that are available. + ///< if count is greater than the number of tests that are available, then + ///< the driver shall update the value with the correct number of tests. + zes_diag_test_t* pTests ///< [in,out][optional][range(0, *pCount)] array of information about + ///< individual tests sorted by increasing value of the `index` member of ::zes_diag_test_t. + ///< if count is less than the number of tests that are available, then the + ///< driver shall only retrieve that number of tests. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsRunTests( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + uint32_t startIndex, ///< [in] The index of the first test to run. Set to + ///< ::ZES_DIAG_FIRST_TEST_INDEX to start from the beginning. + uint32_t endIndex, ///< [in] The index of the last test to run. Set to + ///< ::ZES_DIAG_LAST_TEST_INDEX to complete all tests after the start test. + zes_diag_result_t* pResult ///< [in,out] The result of the diagnostics + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEccAvailable( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + ze_bool_t* pAvailable ///< [out] ECC functionality is available (true)/unavailable (false). + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEccConfigurable( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + ze_bool_t* pConfigurable ///< [out] ECC can be enabled/disabled (true)/enabled/disabled (false). + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetEccState( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + zes_device_ecc_properties_t* pState ///< [out] ECC state, pending state, and pending action for state change. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceSetEccState( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + const zes_device_ecc_desc_t* newState, ///< [in] Pointer to desired ECC state. + zes_device_ecc_properties_t* pState ///< [out] ECC state, pending state, and pending action for state change. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEngineGroups( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_engine_handle_t* phEngine ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetProperties( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + zes_engine_properties_t* pProperties ///< [in,out] The properties for the specified engine group. + ); + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetActivity( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + zes_engine_stats_t* pStats ///< [in,out] Will contain a snapshot of the engine group activity + ///< counters. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEventRegister( + zes_device_handle_t hDevice, ///< [in] The device handle. + zes_event_type_flags_t events ///< [in] List of events to listen to. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDriverEventListen( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then will check status and return immediately; + ///< if `UINT32_MAX`, then function will not return until events arrive. + uint32_t count, ///< [in] Number of device handles in phDevices. + zes_device_handle_t* phDevices, ///< [in][range(0, count)] Device handles to listen to for events. Only + ///< devices from the provided driver handle can be specified in this list. + uint32_t* pNumDeviceEvents, ///< [in,out] Will contain the actual number of devices in phDevices that + ///< generated events. If non-zero, check pEvents to determine the devices + ///< and events that were received. + zes_event_type_flags_t* pEvents ///< [in,out] An array that will continue the list of events for each + ///< device listened in phDevices. + ///< This array must be at least as big as count. + ///< For every device handle in phDevices, this will provide the events + ///< that occurred for that device at the same position in this array. If + ///< no event was received for a given device, the corresponding array + ///< entry will be zero. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDriverEventListenEx( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint64_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then will check status and return immediately; + ///< if `UINT64_MAX`, then function will not return until events arrive. + uint32_t count, ///< [in] Number of device handles in phDevices. + zes_device_handle_t* phDevices, ///< [in][range(0, count)] Device handles to listen to for events. Only + ///< devices from the provided driver handle can be specified in this list. + uint32_t* pNumDeviceEvents, ///< [in,out] Will contain the actual number of devices in phDevices that + ///< generated events. If non-zero, check pEvents to determine the devices + ///< and events that were received. + zes_event_type_flags_t* pEvents ///< [in,out] An array that will continue the list of events for each + ///< device listened in phDevices. + ///< This array must be at least as big as count. + ///< For every device handle in phDevices, this will provide the events + ///< that occurred for that device at the same position in this array. If + ///< no event was received for a given device, the corresponding array + ///< entry will be zero. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFabricPorts( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_fabric_port_handle_t* phPort ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetProperties( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_properties_t* pProperties ///< [in,out] Will contain properties of the Fabric Port. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetLinkType( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_link_type_t* pLinkType ///< [in,out] Will contain details about the link attached to the Fabric + ///< port. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetConfig( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_config_t* pConfig ///< [in,out] Will contain configuration of the Fabric Port. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortSetConfig( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + const zes_fabric_port_config_t* pConfig ///< [in] Contains new configuration of the Fabric Port. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetState( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_state_t* pState ///< [in,out] Will contain the current state of the Fabric Port + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetThroughput( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_throughput_t* pThroughput ///< [in,out] Will contain the Fabric port throughput counters. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetFabricErrorCounters( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_error_counters_t* pErrors ///< [in,out] Will contain the Fabric port Error counters. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetMultiPortThroughput( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t numPorts, ///< [in] Number of ports enumerated in function ::zesDeviceEnumFabricPorts + zes_fabric_port_handle_t* phPort, ///< [in][range(0, numPorts)] array of fabric port handles provided by user + ///< to gather throughput values. + zes_fabric_port_throughput_t** pThroughput ///< [out][range(0, numPorts)] array of fabric port throughput counters + ///< from multiple ports of type ::zes_fabric_port_throughput_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFans( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_fan_handle_t* phFan ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanGetProperties( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_properties_t* pProperties ///< [in,out] Will contain the properties of the fan. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanGetConfig( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_config_t* pConfig ///< [in,out] Will contain the current configuration of the fan. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanSetDefaultMode( + zes_fan_handle_t hFan ///< [in] Handle for the component. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanSetFixedSpeedMode( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + const zes_fan_speed_t* speed ///< [in] The fixed fan speed setting + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanSetSpeedTableMode( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + const zes_fan_speed_table_t* speedTable ///< [in] A table containing temperature/speed pairs. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFanGetState( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_speed_units_t units, ///< [in] The units in which the fan speed should be returned. + int32_t* pSpeed ///< [in,out] Will contain the current speed of the fan in the units + ///< requested. A value of -1 indicates that the fan speed cannot be + ///< measured. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFirmwares( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_firmware_handle_t* phFirmware ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetProperties( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + zes_firmware_properties_t* pProperties ///< [in,out] Pointer to an array that will hold the properties of the + ///< firmware + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareFlash( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + void* pImage, ///< [in] Image of the new firmware to flash. + uint32_t size ///< [in] Size of the flash image. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetFlashProgress( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + uint32_t* pCompletionPercent ///< [in,out] Pointer to the Completion Percentage of Firmware Update + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetConsoleLogs( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + size_t* pSize, ///< [in,out] size of firmware log + char* pFirmwareLog ///< [in,out][optional] pointer to null-terminated string of the log. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFrequencyDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_freq_handle_t* phFrequency ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetProperties( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_properties_t* pProperties ///< [in,out] The frequency properties for the specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetAvailableClocks( + zes_freq_handle_t hFrequency, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of frequencies. + ///< if count is zero, then the driver shall update the value with the + ///< total number of frequencies that are available. + ///< if count is greater than the number of frequencies that are available, + ///< then the driver shall update the value with the correct number of frequencies. + double* phFrequency ///< [in,out][optional][range(0, *pCount)] array of frequencies in units of + ///< MHz and sorted from slowest to fastest. + ///< if count is less than the number of frequencies that are available, + ///< then the driver shall only retrieve that number of frequencies. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetRange( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_range_t* pLimits ///< [in,out] The range between which the hardware can operate for the + ///< specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencySetRange( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + const zes_freq_range_t* pLimits ///< [in] The limits between which the hardware can operate for the + ///< specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetState( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_state_t* pState ///< [in,out] Frequency state for the specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetThrottleTime( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_throttle_time_t* pThrottleTime ///< [in,out] Will contain a snapshot of the throttle time counters for the + ///< specified domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetCapabilities( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_capabilities_t* pOcCapabilities ///< [in,out] Pointer to the capabilities structure. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetFrequencyTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pCurrentOcFrequency ///< [out] Overclocking Frequency in MHz, if extended moded is supported, + ///< will returned in 1 Mhz granularity, else, in multiples of 50 Mhz. This + ///< cannot be greater than the `maxOcFrequency` member of + ///< ::zes_oc_capabilities_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetFrequencyTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double CurrentOcFrequency ///< [in] Overclocking Frequency in MHz, if extended moded is supported, it + ///< could be set in 1 Mhz granularity, else, in multiples of 50 Mhz. This + ///< cannot be greater than the `maxOcFrequency` member of + ///< ::zes_oc_capabilities_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetVoltageTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pCurrentVoltageTarget, ///< [out] Overclock voltage in Volts. This cannot be greater than the + ///< `maxOcVoltage` member of ::zes_oc_capabilities_t. + double* pCurrentVoltageOffset ///< [out] This voltage offset is applied to all points on the + ///< voltage/frequency curve, including the new overclock voltageTarget. + ///< Valid range is between the `minOcVoltageOffset` and + ///< `maxOcVoltageOffset` members of ::zes_oc_capabilities_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetVoltageTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double CurrentVoltageTarget, ///< [in] Overclock voltage in Volts. This cannot be greater than the + ///< `maxOcVoltage` member of ::zes_oc_capabilities_t. + double CurrentVoltageOffset ///< [in] This voltage offset is applied to all points on the + ///< voltage/frequency curve, include the new overclock voltageTarget. + ///< Valid range is between the `minOcVoltageOffset` and + ///< `maxOcVoltageOffset` members of ::zes_oc_capabilities_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetMode( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_mode_t CurrentOcMode ///< [in] Current Overclocking Mode ::zes_oc_mode_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetMode( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_mode_t* pCurrentOcMode ///< [out] Current Overclocking Mode ::zes_oc_mode_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetIccMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pOcIccMax ///< [in,out] Will contain the maximum current limit in Amperes on + ///< successful return. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetIccMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double ocIccMax ///< [in] The new maximum current limit in Amperes. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetTjMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pOcTjMax ///< [in,out] Will contain the maximum temperature limit in degrees Celsius + ///< on successful return. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetTjMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double ocTjMax ///< [in] The new maximum temperature limit in degrees Celsius. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumLeds( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_led_handle_t* phLed ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesLedGetProperties( + zes_led_handle_t hLed, ///< [in] Handle for the component. + zes_led_properties_t* pProperties ///< [in,out] Will contain the properties of the LED. + ); + __zedlllocal ze_result_t ZE_APICALL + zesLedGetState( + zes_led_handle_t hLed, ///< [in] Handle for the component. + zes_led_state_t* pState ///< [in,out] Will contain the current state of the LED. + ); + __zedlllocal ze_result_t ZE_APICALL + zesLedSetState( + zes_led_handle_t hLed, ///< [in] Handle for the component. + ze_bool_t enable ///< [in] Set to TRUE to turn the LED on, FALSE to turn off. + ); + __zedlllocal ze_result_t ZE_APICALL + zesLedSetColor( + zes_led_handle_t hLed, ///< [in] Handle for the component. + const zes_led_color_t* pColor ///< [in] New color of the LED. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumMemoryModules( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_mem_handle_t* phMemory ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetProperties( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_properties_t* pProperties ///< [in,out] Will contain memory properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetState( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_state_t* pState ///< [in,out] Will contain the current health and allocated memory. + ); + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetBandwidth( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_bandwidth_t* pBandwidth ///< [in,out] Will contain the total number of bytes read from and written + ///< to memory, as well as the current maximum bandwidth. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPerformanceFactorDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_perf_handle_t* phPerf ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorGetProperties( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + zes_perf_properties_t* pProperties ///< [in,out] Will contain information about the specified Performance + ///< Factor domain. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorGetConfig( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + double* pFactor ///< [in,out] Will contain the actual Performance Factor being used by the + ///< hardware (may not be the same as the requested Performance Factor). + ); + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorSetConfig( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + double factor ///< [in] The new Performance Factor. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPowerDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_pwr_handle_t* phPower ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetCardPowerDomain( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pwr_handle_t* phPower ///< [in,out] power domain handle for the entire PCIe card. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetProperties( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_properties_t* pProperties ///< [in,out] Structure that will contain property data. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetEnergyCounter( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_energy_counter_t* pEnergy ///< [in,out] Will contain the latest snapshot of the energy counter and + ///< timestamp when the last counter value was measured. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetLimits( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_sustained_limit_t* pSustained, ///< [in,out][optional] The sustained power limit. If this is null, the + ///< current sustained power limits will not be returned. + zes_power_burst_limit_t* pBurst, ///< [in,out][optional] The burst power limit. If this is null, the current + ///< peak power limits will not be returned. + zes_power_peak_limit_t* pPeak ///< [in,out][optional] The peak power limit. If this is null, the peak + ///< power limits will not be returned. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetLimits( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + const zes_power_sustained_limit_t* pSustained, ///< [in][optional] The sustained power limit. If this is null, no changes + ///< will be made to the sustained power limits. + const zes_power_burst_limit_t* pBurst, ///< [in][optional] The burst power limit. If this is null, no changes will + ///< be made to the burst power limits. + const zes_power_peak_limit_t* pPeak ///< [in][optional] The peak power limit. If this is null, no changes will + ///< be made to the peak power limits. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetEnergyThreshold( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_energy_threshold_t* pThreshold ///< [in,out] Returns information about the energy threshold setting - + ///< enabled/energy threshold/process ID. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetEnergyThreshold( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + double threshold ///< [in] The energy threshold to be set in joules. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPsus( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_psu_handle_t* phPsu ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPsuGetProperties( + zes_psu_handle_t hPsu, ///< [in] Handle for the component. + zes_psu_properties_t* pProperties ///< [in,out] Will contain the properties of the power supply. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPsuGetState( + zes_psu_handle_t hPsu, ///< [in] Handle for the component. + zes_psu_state_t* pState ///< [in,out] Will contain the current state of the power supply. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumRasErrorSets( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_ras_handle_t* phRas ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasGetProperties( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_properties_t* pProperties ///< [in,out] Structure describing RAS properties + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasGetConfig( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_config_t* pConfig ///< [in,out] Will be populed with the current RAS configuration - + ///< thresholds used to trigger events + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasSetConfig( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + const zes_ras_config_t* pConfig ///< [in] Change the RAS configuration - thresholds used to trigger events + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasGetState( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + ze_bool_t clear, ///< [in] Set to 1 to clear the counters of this type + zes_ras_state_t* pState ///< [in,out] Breakdown of where errors have occurred + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumSchedulers( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_sched_handle_t* phScheduler ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetProperties( + zes_sched_handle_t hScheduler, ///< [in] Handle for the component. + zes_sched_properties_t* pProperties ///< [in,out] Structure that will contain property data. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetCurrentMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_mode_t* pMode ///< [in,out] Will contain the current scheduler mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetTimeoutModeProperties( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t getDefaults, ///< [in] If TRUE, the driver will return the system default properties for + ///< this mode, otherwise it will return the current properties. + zes_sched_timeout_properties_t* pConfig ///< [in,out] Will contain the current parameters for this mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetTimesliceModeProperties( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t getDefaults, ///< [in] If TRUE, the driver will return the system default properties for + ///< this mode, otherwise it will return the current properties. + zes_sched_timeslice_properties_t* pConfig ///< [in,out] Will contain the current parameters for this mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetTimeoutMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_timeout_properties_t* pProperties, ///< [in] The properties to use when configurating this mode. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetTimesliceMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_timeslice_properties_t* pProperties, ///< [in] The properties to use when configurating this mode. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetExclusiveMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetComputeUnitDebugMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumStandbyDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_standby_handle_t* phStandby ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesStandbyGetProperties( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_properties_t* pProperties ///< [in,out] Will contain the standby hardware properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesStandbyGetMode( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_promo_mode_t* pMode ///< [in,out] Will contain the current standby mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesStandbySetMode( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_promo_mode_t mode ///< [in] New standby mode. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumTemperatureSensors( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_temp_handle_t* phTemperature ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetProperties( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + zes_temp_properties_t* pProperties ///< [in,out] Will contain the temperature sensor properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetConfig( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + zes_temp_config_t* pConfig ///< [in,out] Returns current configuration. + ); + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureSetConfig( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + const zes_temp_config_t* pConfig ///< [in] New configuration. + ); + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetState( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + double* pTemperature ///< [in,out] Will contain the temperature read from the specified sensor + ///< in degrees Celsius. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetLimitsExt( + zes_pwr_handle_t hPower, ///< [in] Power domain handle instance. + uint32_t* pCount, ///< [in,out] Pointer to the number of power limit descriptors. If count is + ///< zero, then the driver shall update the value with the total number of + ///< components of this type that are available. If count is greater than + ///< the number of components of this type that are available, then the + ///< driver shall update the value with the correct number of components. + zes_power_limit_ext_desc_t* pSustained ///< [in,out][optional][range(0, *pCount)] Array of query results for power + ///< limit descriptors. If count is less than the number of components of + ///< this type that are available, then the driver shall only retrieve that + ///< number of components. + ); + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetLimitsExt( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in] Pointer to the number of power limit descriptors. + zes_power_limit_ext_desc_t* pSustained ///< [in][optional][range(0, *pCount)] Array of power limit descriptors. + ); + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetActivityExt( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_engine_stats_t* pStats ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector with engine stat for + ///< PF at index 0 of the vector followed by user provided pCount-1 number + ///< of VF engine stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasGetStateExp( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] pointer to the number of RAS state structures that can be retrieved. + ///< if count is zero, then the driver shall update the value with the + ///< total number of error categories for which state can be retrieved. + ///< if count is greater than the number of RAS states available, then the + ///< driver shall update the value with the correct number of RAS states available. + zes_ras_state_exp_t* pState ///< [in,out][optional][range(0, *pCount)] array of query results for RAS + ///< error states for different categories. + ///< if count is less than the number of RAS states available, then driver + ///< shall only retrieve that number of RAS states. + ); + __zedlllocal ze_result_t ZE_APICALL + zesRasClearStateExp( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_error_category_exp_t category ///< [in] category for which error counter is to be cleared. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetSecurityVersionExp( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + char* pVersion ///< [in,out] NULL terminated string value. The string "unknown" will be + ///< returned if this property cannot be determined. + ); + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareSetSecurityVersionExp( + zes_firmware_handle_t hFirmware ///< [in] Handle for the component. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetSubDevicePropertiesExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of sub devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub devices currently attached to the device. + ///< if count is greater than the number of sub devices currently attached + ///< to the device, then the driver shall update the value with the correct + ///< number of sub devices. + zes_subdevice_exp_properties_t* pSubdeviceProps ///< [in,out][optional][range(0, *pCount)] array of sub device property structures. + ///< if count is less than the number of sysman sub devices available, then + ///< the driver shall only retrieve that number of sub device property structures. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetDeviceByUuidExp( + zes_driver_handle_t hDriver, ///< [in] handle of the sysman driver instance + zes_uuid_t uuid, ///< [in] universal unique identifier. + zes_device_handle_t* phDevice, ///< [out] Sysman handle of the device. + ze_bool_t* onSubdevice, ///< [out] True if the UUID belongs to the sub-device; false means that + ///< UUID belongs to the root device. + uint32_t* subdeviceId ///< [out] If onSubdevice is true, this gives the ID of the sub-device + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumActiveVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFPropertiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_vf_util_mem_exp_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_vf_util_engine_exp_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementSetVFTelemetryModeExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid + ///< combination of ::zes_vf_info_util_exp_flag_t. + ze_bool_t enable ///< [in] Enable utilization telemetry. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementSetVFTelemetrySamplingIntervalExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid + ///< combination of ::zes_vf_info_util_exp_flag_t. + uint64_t samplingInterval ///< [in] Sampling interval value. + ); + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ); + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +__zedlllocal void ZE_APICALL +zesGetGlobalProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetDeviceProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetDeviceExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetDriverProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetDriverExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetDiagnosticsProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetEngineProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetFabricPortProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetFanProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetFirmwareProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetFirmwareExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetFrequencyProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetLedProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetMemoryProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetOverclockProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetPerformanceFactorProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetPowerProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetPsuProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetRasProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetRasExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetSchedulerProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetStandbyProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetTemperatureProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zesGetVFManagementExpProcAddrTableLegacy(); + +#if defined(__cplusplus) +}; +#endif diff --git a/source/loader/zes_ldrddi_driver_ddi.cpp b/source/loader/zes_ldrddi_driver_ddi.cpp new file mode 100644 index 00000000..55a39b08 --- /dev/null +++ b/source/loader/zes_ldrddi_driver_ddi.cpp @@ -0,0 +1,4316 @@ +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file zes_ldrddi_driver_ddi.cpp + * + */ +#include "ze_loader_internal.h" + +namespace loader_driver_ddi +{ + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDriverGetExtensionProperties + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetExtensionProperties( + zes_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of extension properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of extension properties available. + ///< if count is greater than the number of extension properties available, + ///< then the driver shall update the value with the correct number of + ///< extension properties available. + zes_driver_extension_properties_t* pExtensionProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< extension properties. + ///< if count is less than the number of extension properties available, + ///< then driver shall only retrieve that number of extension properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_8) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExtensionProperties = dditable->Driver->pfnGetExtensionProperties; + if( nullptr == pfnGetExtensionProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExtensionProperties( hDriver, pCount, pExtensionProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDriverGetExtensionFunctionAddress + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetExtensionFunctionAddress( + zes_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char* name, ///< [in] extension function name + void** ppFunctionAddress ///< [out] pointer to function pointer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_8) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExtensionFunctionAddress = dditable->Driver->pfnGetExtensionFunctionAddress; + if( nullptr == pfnGetExtensionFunctionAddress ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExtensionFunctionAddress( hDriver, name, ppFunctionAddress ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGet + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGet( + zes_driver_handle_t hDriver, ///< [in] handle of the sysman driver instance + uint32_t* pCount, ///< [in,out] pointer to the number of sysman devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sysman devices available. + ///< if count is greater than the number of sysman devices available, then + ///< the driver shall update the value with the correct number of sysman + ///< devices available. + zes_device_handle_t* phDevices ///< [in,out][optional][range(0, *pCount)] array of handle of sysman devices. + ///< if count is less than the number of sysman devices available, then + ///< driver shall only retrieve that number of sysman devices. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGet = dditable->Device->pfnGet; + if( nullptr == pfnGet ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGet( hDriver, pCount, phDevices ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetProperties( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_device_properties_t* pProperties ///< [in,out] Structure that will contain information about the device. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Device->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hDevice, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetState + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_device_state_t* pState ///< [in,out] Structure that will contain information about the device. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Device->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hDevice, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceReset + __zedlllocal ze_result_t ZE_APICALL + zesDeviceReset( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + ze_bool_t force ///< [in] If set to true, all applications that are currently using the + ///< device will be forcibly killed. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReset = dditable->Device->pfnReset; + if( nullptr == pfnReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReset( hDevice, force ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceResetExt + __zedlllocal ze_result_t ZE_APICALL + zesDeviceResetExt( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + zes_reset_properties_t* pProperties ///< [in] Device reset properties to apply + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnResetExt = dditable->Device->pfnResetExt; + if( nullptr == pfnResetExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnResetExt( hDevice, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceProcessesGetState + __zedlllocal ze_result_t ZE_APICALL + zesDeviceProcessesGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle for the device + uint32_t* pCount, ///< [in,out] pointer to the number of processes. + ///< if count is zero, then the driver shall update the value with the + ///< total number of processes currently attached to the device. + ///< if count is greater than the number of processes currently attached to + ///< the device, then the driver shall update the value with the correct + ///< number of processes. + zes_process_state_t* pProcesses ///< [in,out][optional][range(0, *pCount)] array of process information. + ///< if count is less than the number of processes currently attached to + ///< the device, then the driver shall only retrieve information about that + ///< number of processes. In this case, the return code will ::ZE_RESULT_ERROR_INVALID_SIZE. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnProcessesGetState = dditable->Device->pfnProcessesGetState; + if( nullptr == pfnProcessesGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnProcessesGetState( hDevice, pCount, pProcesses ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDevicePciGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetProperties( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_properties_t* pProperties ///< [in,out] Will contain the PCI properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPciGetProperties = dditable->Device->pfnPciGetProperties; + if( nullptr == pfnPciGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPciGetProperties( hDevice, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDevicePciGetState + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_state_t* pState ///< [in,out] Will contain the PCI properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPciGetState = dditable->Device->pfnPciGetState; + if( nullptr == pfnPciGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPciGetState( hDevice, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDevicePciGetBars + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetBars( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of PCI bars. + ///< if count is zero, then the driver shall update the value with the + ///< total number of PCI bars that are setup. + ///< if count is greater than the number of PCI bars that are setup, then + ///< the driver shall update the value with the correct number of PCI bars. + zes_pci_bar_properties_t* pProperties ///< [in,out][optional][range(0, *pCount)] array of information about setup + ///< PCI bars. + ///< if count is less than the number of PCI bars that are setup, then the + ///< driver shall only retrieve information about that number of PCI bars. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPciGetBars = dditable->Device->pfnPciGetBars; + if( nullptr == pfnPciGetBars ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPciGetBars( hDevice, pCount, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDevicePciGetStats + __zedlllocal ze_result_t ZE_APICALL + zesDevicePciGetStats( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pci_stats_t* pStats ///< [in,out] Will contain a snapshot of the latest stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnPciGetStats = dditable->Device->pfnPciGetStats; + if( nullptr == pfnPciGetStats ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnPciGetStats( hDevice, pStats ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceSetOverclockWaiver + __zedlllocal ze_result_t ZE_APICALL + zesDeviceSetOverclockWaiver( + zes_device_handle_t hDevice ///< [in] Sysman handle of the device. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetOverclockWaiver = dditable->Device->pfnSetOverclockWaiver; + if( nullptr == pfnSetOverclockWaiver ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetOverclockWaiver( hDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetOverclockDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetOverclockDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pOverclockDomains ///< [in,out] Returns the overclock domains that are supported (a bit for + ///< each of enum ::zes_overclock_domain_t). If no bits are set, the device + ///< doesn't support overclocking. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetOverclockDomains = dditable->Device->pfnGetOverclockDomains; + if( nullptr == pfnGetOverclockDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetOverclockDomains( hDevice, pOverclockDomains ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetOverclockControls + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetOverclockControls( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_overclock_domain_t domainType, ///< [in] Domain type. + uint32_t* pAvailableControls ///< [in,out] Returns the overclock controls that are supported for the + ///< specified overclock domain (a bit for each of enum + ///< ::zes_overclock_control_t). + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetOverclockControls = dditable->Device->pfnGetOverclockControls; + if( nullptr == pfnGetOverclockControls ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetOverclockControls( hDevice, domainType, pAvailableControls ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceResetOverclockSettings + __zedlllocal ze_result_t ZE_APICALL + zesDeviceResetOverclockSettings( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + ze_bool_t onShippedState ///< [in] True will reset to shipped state; false will reset to + ///< manufacturing state + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnResetOverclockSettings = dditable->Device->pfnResetOverclockSettings; + if( nullptr == pfnResetOverclockSettings ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnResetOverclockSettings( hDevice, onShippedState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceReadOverclockState + __zedlllocal ze_result_t ZE_APICALL + zesDeviceReadOverclockState( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_overclock_mode_t* pOverclockMode, ///< [out] One of overclock mode. + ze_bool_t* pWaiverSetting, ///< [out] Waiver setting: 0 = Waiver not set, 1 = waiver has been set. + ze_bool_t* pOverclockState, ///< [out] Current settings 0 =manufacturing state, 1= shipped state).. + zes_pending_action_t* pPendingAction, ///< [out] This enum is returned when the driver attempts to set an + ///< overclock control or reset overclock settings. + ze_bool_t* pPendingReset ///< [out] Pending reset 0 =manufacturing state, 1= shipped state).. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadOverclockState = dditable->Device->pfnReadOverclockState; + if( nullptr == pfnReadOverclockState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadOverclockState( hDevice, pOverclockMode, pWaiverSetting, pOverclockState, pPendingAction, pPendingReset ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumOverclockDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumOverclockDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_overclock_handle_t* phDomainHandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumOverclockDomains = dditable->Device->pfnEnumOverclockDomains; + if( nullptr == pfnEnumOverclockDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumOverclockDomains( hDevice, pCount, phDomainHandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetDomainProperties + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_properties_t* pDomainProperties ///< [in,out] The overclock properties for the specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDomainProperties = dditable->Overclock->pfnGetDomainProperties; + if( nullptr == pfnGetDomainProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDomainProperties( hDomainHandle, pDomainProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetDomainVFProperties + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainVFProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_property_t* pVFProperties ///< [in,out] The VF min,max,step for a specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDomainVFProperties = dditable->Overclock->pfnGetDomainVFProperties; + if( nullptr == pfnGetDomainVFProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDomainVFProperties( hDomainHandle, pVFProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetDomainControlProperties + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetDomainControlProperties( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Handle for the component. + zes_control_property_t* pControlProperties ///< [in,out] overclock control values. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDomainControlProperties = dditable->Overclock->pfnGetDomainControlProperties; + if( nullptr == pfnGetDomainControlProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDomainControlProperties( hDomainHandle, DomainControl, pControlProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetControlCurrentValue + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlCurrentValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component. + zes_overclock_control_t DomainControl, ///< [in] Overclock Control. + double* pValue ///< [in,out] Getting overclock control value for the specified control. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetControlCurrentValue = dditable->Overclock->pfnGetControlCurrentValue; + if( nullptr == pfnGetControlCurrentValue ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetControlCurrentValue( hDomainHandle, DomainControl, pValue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetControlPendingValue + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlPendingValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Overclock Control. + double* pValue ///< [out] Returns the pending value for a given control. The units and + ///< format of the value depend on the control type. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetControlPendingValue = dditable->Overclock->pfnGetControlPendingValue; + if( nullptr == pfnGetControlPendingValue ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetControlPendingValue( hDomainHandle, DomainControl, pValue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockSetControlUserValue + __zedlllocal ze_result_t ZE_APICALL + zesOverclockSetControlUserValue( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Domain Control. + double pValue, ///< [in] The new value of the control. The units and format of the value + ///< depend on the control type. + zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetControlUserValue = dditable->Overclock->pfnSetControlUserValue; + if( nullptr == pfnSetControlUserValue ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetControlUserValue( hDomainHandle, DomainControl, pValue, pPendingAction ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetControlState + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetControlState( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_overclock_control_t DomainControl, ///< [in] Domain Control. + zes_control_state_t* pControlState, ///< [out] Current overclock control state. + zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetControlState = dditable->Overclock->pfnGetControlState; + if( nullptr == pfnGetControlState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetControlState( hDomainHandle, DomainControl, pControlState, pPendingAction ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockGetVFPointValues + __zedlllocal ze_result_t ZE_APICALL + zesOverclockGetVFPointValues( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read. + zes_vf_array_type_t VFArrayType, ///< [in] User,Default or Live VF array to read from + uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1). + uint32_t* PointValue ///< [out] Returns the frequency in 1kHz units or voltage in millivolt + ///< units from the custom V-F curve at the specified zero-based index + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFPointValues = dditable->Overclock->pfnGetVFPointValues; + if( nullptr == pfnGetVFPointValues ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFPointValues( hDomainHandle, VFType, VFArrayType, PointIndex, PointValue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesOverclockSetVFPointValues + __zedlllocal ze_result_t ZE_APICALL + zesOverclockSetVFPointValues( + zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain. + zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read. + uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1). + uint32_t PointValue ///< [in] Writes frequency in 1kHz units or voltage in millivolt units to + ///< custom V-F curve at the specified zero-based index + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDomainHandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetVFPointValues = dditable->Overclock->pfnSetVFPointValues; + if( nullptr == pfnSetVFPointValues ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetVFPointValues( hDomainHandle, VFType, PointIndex, PointValue ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumDiagnosticTestSuites + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumDiagnosticTestSuites( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_diag_handle_t* phDiagnostics ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumDiagnosticTestSuites = dditable->Device->pfnEnumDiagnosticTestSuites; + if( nullptr == pfnEnumDiagnosticTestSuites ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumDiagnosticTestSuites( hDevice, pCount, phDiagnostics ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDiagnosticsGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsGetProperties( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + zes_diag_properties_t* pProperties ///< [in,out] Structure describing the properties of a diagnostics test + ///< suite + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDiagnostics )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Diagnostics->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hDiagnostics, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDiagnosticsGetTests + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsGetTests( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] pointer to the number of tests. + ///< if count is zero, then the driver shall update the value with the + ///< total number of tests that are available. + ///< if count is greater than the number of tests that are available, then + ///< the driver shall update the value with the correct number of tests. + zes_diag_test_t* pTests ///< [in,out][optional][range(0, *pCount)] array of information about + ///< individual tests sorted by increasing value of the `index` member of ::zes_diag_test_t. + ///< if count is less than the number of tests that are available, then the + ///< driver shall only retrieve that number of tests. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDiagnostics )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetTests = dditable->Diagnostics->pfnGetTests; + if( nullptr == pfnGetTests ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetTests( hDiagnostics, pCount, pTests ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDiagnosticsRunTests + __zedlllocal ze_result_t ZE_APICALL + zesDiagnosticsRunTests( + zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component. + uint32_t startIndex, ///< [in] The index of the first test to run. Set to + ///< ::ZES_DIAG_FIRST_TEST_INDEX to start from the beginning. + uint32_t endIndex, ///< [in] The index of the last test to run. Set to + ///< ::ZES_DIAG_LAST_TEST_INDEX to complete all tests after the start test. + zes_diag_result_t* pResult ///< [in,out] The result of the diagnostics + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDiagnostics )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnRunTests = dditable->Diagnostics->pfnRunTests; + if( nullptr == pfnRunTests ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnRunTests( hDiagnostics, startIndex, endIndex, pResult ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEccAvailable + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEccAvailable( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + ze_bool_t* pAvailable ///< [out] ECC functionality is available (true)/unavailable (false). + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEccAvailable = dditable->Device->pfnEccAvailable; + if( nullptr == pfnEccAvailable ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEccAvailable( hDevice, pAvailable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEccConfigurable + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEccConfigurable( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + ze_bool_t* pConfigurable ///< [out] ECC can be enabled/disabled (true)/enabled/disabled (false). + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEccConfigurable = dditable->Device->pfnEccConfigurable; + if( nullptr == pfnEccConfigurable ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEccConfigurable( hDevice, pConfigurable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetEccState + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetEccState( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + zes_device_ecc_properties_t* pState ///< [out] ECC state, pending state, and pending action for state change. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetEccState = dditable->Device->pfnGetEccState; + if( nullptr == pfnGetEccState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetEccState( hDevice, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceSetEccState + __zedlllocal ze_result_t ZE_APICALL + zesDeviceSetEccState( + zes_device_handle_t hDevice, ///< [in] Handle for the component. + const zes_device_ecc_desc_t* newState, ///< [in] Pointer to desired ECC state. + zes_device_ecc_properties_t* pState ///< [out] ECC state, pending state, and pending action for state change. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_4) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetEccState = dditable->Device->pfnSetEccState; + if( nullptr == pfnSetEccState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetEccState( hDevice, newState, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumEngineGroups + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEngineGroups( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_engine_handle_t* phEngine ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumEngineGroups = dditable->Device->pfnEnumEngineGroups; + if( nullptr == pfnEnumEngineGroups ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumEngineGroups( hDevice, pCount, phEngine ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesEngineGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetProperties( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + zes_engine_properties_t* pProperties ///< [in,out] The properties for the specified engine group. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEngine )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Engine->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hEngine, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesEngineGetActivity + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetActivity( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + zes_engine_stats_t* pStats ///< [in,out] Will contain a snapshot of the engine group activity + ///< counters. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEngine )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetActivity = dditable->Engine->pfnGetActivity; + if( nullptr == pfnGetActivity ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetActivity( hEngine, pStats ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEventRegister + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEventRegister( + zes_device_handle_t hDevice, ///< [in] The device handle. + zes_event_type_flags_t events ///< [in] List of events to listen to. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEventRegister = dditable->Device->pfnEventRegister; + if( nullptr == pfnEventRegister ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEventRegister( hDevice, events ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDriverEventListen + __zedlllocal ze_result_t ZE_APICALL + zesDriverEventListen( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint32_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then will check status and return immediately; + ///< if `UINT32_MAX`, then function will not return until events arrive. + uint32_t count, ///< [in] Number of device handles in phDevices. + zes_device_handle_t* phDevices, ///< [in][range(0, count)] Device handles to listen to for events. Only + ///< devices from the provided driver handle can be specified in this list. + uint32_t* pNumDeviceEvents, ///< [in,out] Will contain the actual number of devices in phDevices that + ///< generated events. If non-zero, check pEvents to determine the devices + ///< and events that were received. + zes_event_type_flags_t* pEvents ///< [in,out] An array that will continue the list of events for each + ///< device listened in phDevices. + ///< This array must be at least as big as count. + ///< For every device handle in phDevices, this will provide the events + ///< that occurred for that device at the same position in this array. If + ///< no event was received for a given device, the corresponding array + ///< entry will be zero. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEventListen = dditable->Driver->pfnEventListen; + if( nullptr == pfnEventListen ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEventListen( hDriver, timeout, count, phDevices, pNumDeviceEvents, pEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDriverEventListenEx + __zedlllocal ze_result_t ZE_APICALL + zesDriverEventListenEx( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + uint64_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then will check status and return immediately; + ///< if `UINT64_MAX`, then function will not return until events arrive. + uint32_t count, ///< [in] Number of device handles in phDevices. + zes_device_handle_t* phDevices, ///< [in][range(0, count)] Device handles to listen to for events. Only + ///< devices from the provided driver handle can be specified in this list. + uint32_t* pNumDeviceEvents, ///< [in,out] Will contain the actual number of devices in phDevices that + ///< generated events. If non-zero, check pEvents to determine the devices + ///< and events that were received. + zes_event_type_flags_t* pEvents ///< [in,out] An array that will continue the list of events for each + ///< device listened in phDevices. + ///< This array must be at least as big as count. + ///< For every device handle in phDevices, this will provide the events + ///< that occurred for that device at the same position in this array. If + ///< no event was received for a given device, the corresponding array + ///< entry will be zero. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_1) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEventListenEx = dditable->Driver->pfnEventListenEx; + if( nullptr == pfnEventListenEx ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEventListenEx( hDriver, timeout, count, phDevices, pNumDeviceEvents, pEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumFabricPorts + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFabricPorts( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_fabric_port_handle_t* phPort ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumFabricPorts = dditable->Device->pfnEnumFabricPorts; + if( nullptr == pfnEnumFabricPorts ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumFabricPorts( hDevice, pCount, phPort ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetProperties( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_properties_t* pProperties ///< [in,out] Will contain properties of the Fabric Port. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->FabricPort->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hPort, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetLinkType + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetLinkType( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_link_type_t* pLinkType ///< [in,out] Will contain details about the link attached to the Fabric + ///< port. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetLinkType = dditable->FabricPort->pfnGetLinkType; + if( nullptr == pfnGetLinkType ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetLinkType( hPort, pLinkType ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetConfig + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetConfig( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_config_t* pConfig ///< [in,out] Will contain configuration of the Fabric Port. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConfig = dditable->FabricPort->pfnGetConfig; + if( nullptr == pfnGetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConfig( hPort, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortSetConfig + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortSetConfig( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + const zes_fabric_port_config_t* pConfig ///< [in] Contains new configuration of the Fabric Port. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetConfig = dditable->FabricPort->pfnSetConfig; + if( nullptr == pfnSetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetConfig( hPort, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetState + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetState( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_state_t* pState ///< [in,out] Will contain the current state of the Fabric Port + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->FabricPort->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hPort, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetThroughput + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetThroughput( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_throughput_t* pThroughput ///< [in,out] Will contain the Fabric port throughput counters. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetThroughput = dditable->FabricPort->pfnGetThroughput; + if( nullptr == pfnGetThroughput ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetThroughput( hPort, pThroughput ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetFabricErrorCounters + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetFabricErrorCounters( + zes_fabric_port_handle_t hPort, ///< [in] Handle for the component. + zes_fabric_port_error_counters_t* pErrors ///< [in,out] Will contain the Fabric port Error counters. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPort )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFabricErrorCounters = dditable->FabricPort->pfnGetFabricErrorCounters; + if( nullptr == pfnGetFabricErrorCounters ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFabricErrorCounters( hPort, pErrors ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFabricPortGetMultiPortThroughput + __zedlllocal ze_result_t ZE_APICALL + zesFabricPortGetMultiPortThroughput( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t numPorts, ///< [in] Number of ports enumerated in function ::zesDeviceEnumFabricPorts + zes_fabric_port_handle_t* phPort, ///< [in][range(0, numPorts)] array of fabric port handles provided by user + ///< to gather throughput values. + zes_fabric_port_throughput_t** pThroughput ///< [out][range(0, numPorts)] array of fabric port throughput counters + ///< from multiple ports of type ::zes_fabric_port_throughput_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetMultiPortThroughput = dditable->FabricPort->pfnGetMultiPortThroughput; + if( nullptr == pfnGetMultiPortThroughput ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetMultiPortThroughput( hDevice, numPorts, phPort, pThroughput ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumFans + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFans( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_fan_handle_t* phFan ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumFans = dditable->Device->pfnEnumFans; + if( nullptr == pfnEnumFans ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumFans( hDevice, pCount, phFan ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesFanGetProperties( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_properties_t* pProperties ///< [in,out] Will contain the properties of the fan. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Fan->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hFan, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanGetConfig + __zedlllocal ze_result_t ZE_APICALL + zesFanGetConfig( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_config_t* pConfig ///< [in,out] Will contain the current configuration of the fan. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConfig = dditable->Fan->pfnGetConfig; + if( nullptr == pfnGetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConfig( hFan, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanSetDefaultMode + __zedlllocal ze_result_t ZE_APICALL + zesFanSetDefaultMode( + zes_fan_handle_t hFan ///< [in] Handle for the component. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetDefaultMode = dditable->Fan->pfnSetDefaultMode; + if( nullptr == pfnSetDefaultMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetDefaultMode( hFan ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanSetFixedSpeedMode + __zedlllocal ze_result_t ZE_APICALL + zesFanSetFixedSpeedMode( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + const zes_fan_speed_t* speed ///< [in] The fixed fan speed setting + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetFixedSpeedMode = dditable->Fan->pfnSetFixedSpeedMode; + if( nullptr == pfnSetFixedSpeedMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetFixedSpeedMode( hFan, speed ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanSetSpeedTableMode + __zedlllocal ze_result_t ZE_APICALL + zesFanSetSpeedTableMode( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + const zes_fan_speed_table_t* speedTable ///< [in] A table containing temperature/speed pairs. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetSpeedTableMode = dditable->Fan->pfnSetSpeedTableMode; + if( nullptr == pfnSetSpeedTableMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetSpeedTableMode( hFan, speedTable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFanGetState + __zedlllocal ze_result_t ZE_APICALL + zesFanGetState( + zes_fan_handle_t hFan, ///< [in] Handle for the component. + zes_fan_speed_units_t units, ///< [in] The units in which the fan speed should be returned. + int32_t* pSpeed ///< [in,out] Will contain the current speed of the fan in the units + ///< requested. A value of -1 indicates that the fan speed cannot be + ///< measured. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFan )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Fan->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hFan, units, pSpeed ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumFirmwares + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFirmwares( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_firmware_handle_t* phFirmware ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumFirmwares = dditable->Device->pfnEnumFirmwares; + if( nullptr == pfnEnumFirmwares ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumFirmwares( hDevice, pCount, phFirmware ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetProperties( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + zes_firmware_properties_t* pProperties ///< [in,out] Pointer to an array that will hold the properties of the + ///< firmware + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Firmware->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hFirmware, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareFlash + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareFlash( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + void* pImage, ///< [in] Image of the new firmware to flash. + uint32_t size ///< [in] Size of the flash image. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnFlash = dditable->Firmware->pfnFlash; + if( nullptr == pfnFlash ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnFlash( hFirmware, pImage, size ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareGetFlashProgress + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetFlashProgress( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + uint32_t* pCompletionPercent ///< [in,out] Pointer to the Completion Percentage of Firmware Update + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_8) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetFlashProgress = dditable->Firmware->pfnGetFlashProgress; + if( nullptr == pfnGetFlashProgress ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetFlashProgress( hFirmware, pCompletionPercent ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareGetConsoleLogs + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetConsoleLogs( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + size_t* pSize, ///< [in,out] size of firmware log + char* pFirmwareLog ///< [in,out][optional] pointer to null-terminated string of the log. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConsoleLogs = dditable->Firmware->pfnGetConsoleLogs; + if( nullptr == pfnGetConsoleLogs ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConsoleLogs( hFirmware, pSize, pFirmwareLog ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumFrequencyDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumFrequencyDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_freq_handle_t* phFrequency ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumFrequencyDomains = dditable->Device->pfnEnumFrequencyDomains; + if( nullptr == pfnEnumFrequencyDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumFrequencyDomains( hDevice, pCount, phFrequency ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetProperties( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_properties_t* pProperties ///< [in,out] The frequency properties for the specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Frequency->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hFrequency, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyGetAvailableClocks + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetAvailableClocks( + zes_freq_handle_t hFrequency, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of frequencies. + ///< if count is zero, then the driver shall update the value with the + ///< total number of frequencies that are available. + ///< if count is greater than the number of frequencies that are available, + ///< then the driver shall update the value with the correct number of frequencies. + double* phFrequency ///< [in,out][optional][range(0, *pCount)] array of frequencies in units of + ///< MHz and sorted from slowest to fastest. + ///< if count is less than the number of frequencies that are available, + ///< then the driver shall only retrieve that number of frequencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetAvailableClocks = dditable->Frequency->pfnGetAvailableClocks; + if( nullptr == pfnGetAvailableClocks ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetAvailableClocks( hFrequency, pCount, phFrequency ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyGetRange + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetRange( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_range_t* pLimits ///< [in,out] The range between which the hardware can operate for the + ///< specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetRange = dditable->Frequency->pfnGetRange; + if( nullptr == pfnGetRange ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetRange( hFrequency, pLimits ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencySetRange + __zedlllocal ze_result_t ZE_APICALL + zesFrequencySetRange( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + const zes_freq_range_t* pLimits ///< [in] The limits between which the hardware can operate for the + ///< specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetRange = dditable->Frequency->pfnSetRange; + if( nullptr == pfnSetRange ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetRange( hFrequency, pLimits ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyGetState + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetState( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_state_t* pState ///< [in,out] Frequency state for the specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Frequency->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hFrequency, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyGetThrottleTime + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyGetThrottleTime( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_freq_throttle_time_t* pThrottleTime ///< [in,out] Will contain a snapshot of the throttle time counters for the + ///< specified domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetThrottleTime = dditable->Frequency->pfnGetThrottleTime; + if( nullptr == pfnGetThrottleTime ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetThrottleTime( hFrequency, pThrottleTime ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetCapabilities + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetCapabilities( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_capabilities_t* pOcCapabilities ///< [in,out] Pointer to the capabilities structure. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetCapabilities = dditable->Frequency->pfnOcGetCapabilities; + if( nullptr == pfnOcGetCapabilities ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetCapabilities( hFrequency, pOcCapabilities ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetFrequencyTarget + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetFrequencyTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pCurrentOcFrequency ///< [out] Overclocking Frequency in MHz, if extended moded is supported, + ///< will returned in 1 Mhz granularity, else, in multiples of 50 Mhz. This + ///< cannot be greater than the `maxOcFrequency` member of + ///< ::zes_oc_capabilities_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetFrequencyTarget = dditable->Frequency->pfnOcGetFrequencyTarget; + if( nullptr == pfnOcGetFrequencyTarget ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetFrequencyTarget( hFrequency, pCurrentOcFrequency ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcSetFrequencyTarget + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetFrequencyTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double CurrentOcFrequency ///< [in] Overclocking Frequency in MHz, if extended moded is supported, it + ///< could be set in 1 Mhz granularity, else, in multiples of 50 Mhz. This + ///< cannot be greater than the `maxOcFrequency` member of + ///< ::zes_oc_capabilities_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcSetFrequencyTarget = dditable->Frequency->pfnOcSetFrequencyTarget; + if( nullptr == pfnOcSetFrequencyTarget ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcSetFrequencyTarget( hFrequency, CurrentOcFrequency ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetVoltageTarget + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetVoltageTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pCurrentVoltageTarget, ///< [out] Overclock voltage in Volts. This cannot be greater than the + ///< `maxOcVoltage` member of ::zes_oc_capabilities_t. + double* pCurrentVoltageOffset ///< [out] This voltage offset is applied to all points on the + ///< voltage/frequency curve, including the new overclock voltageTarget. + ///< Valid range is between the `minOcVoltageOffset` and + ///< `maxOcVoltageOffset` members of ::zes_oc_capabilities_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetVoltageTarget = dditable->Frequency->pfnOcGetVoltageTarget; + if( nullptr == pfnOcGetVoltageTarget ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetVoltageTarget( hFrequency, pCurrentVoltageTarget, pCurrentVoltageOffset ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcSetVoltageTarget + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetVoltageTarget( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double CurrentVoltageTarget, ///< [in] Overclock voltage in Volts. This cannot be greater than the + ///< `maxOcVoltage` member of ::zes_oc_capabilities_t. + double CurrentVoltageOffset ///< [in] This voltage offset is applied to all points on the + ///< voltage/frequency curve, include the new overclock voltageTarget. + ///< Valid range is between the `minOcVoltageOffset` and + ///< `maxOcVoltageOffset` members of ::zes_oc_capabilities_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcSetVoltageTarget = dditable->Frequency->pfnOcSetVoltageTarget; + if( nullptr == pfnOcSetVoltageTarget ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcSetVoltageTarget( hFrequency, CurrentVoltageTarget, CurrentVoltageOffset ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcSetMode + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetMode( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_mode_t CurrentOcMode ///< [in] Current Overclocking Mode ::zes_oc_mode_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcSetMode = dditable->Frequency->pfnOcSetMode; + if( nullptr == pfnOcSetMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcSetMode( hFrequency, CurrentOcMode ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetMode + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetMode( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + zes_oc_mode_t* pCurrentOcMode ///< [out] Current Overclocking Mode ::zes_oc_mode_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetMode = dditable->Frequency->pfnOcGetMode; + if( nullptr == pfnOcGetMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetMode( hFrequency, pCurrentOcMode ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetIccMax + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetIccMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pOcIccMax ///< [in,out] Will contain the maximum current limit in Amperes on + ///< successful return. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetIccMax = dditable->Frequency->pfnOcGetIccMax; + if( nullptr == pfnOcGetIccMax ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetIccMax( hFrequency, pOcIccMax ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcSetIccMax + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetIccMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double ocIccMax ///< [in] The new maximum current limit in Amperes. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcSetIccMax = dditable->Frequency->pfnOcSetIccMax; + if( nullptr == pfnOcSetIccMax ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcSetIccMax( hFrequency, ocIccMax ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcGetTjMax + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcGetTjMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double* pOcTjMax ///< [in,out] Will contain the maximum temperature limit in degrees Celsius + ///< on successful return. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcGetTjMax = dditable->Frequency->pfnOcGetTjMax; + if( nullptr == pfnOcGetTjMax ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcGetTjMax( hFrequency, pOcTjMax ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFrequencyOcSetTjMax + __zedlllocal ze_result_t ZE_APICALL + zesFrequencyOcSetTjMax( + zes_freq_handle_t hFrequency, ///< [in] Handle for the component. + double ocTjMax ///< [in] The new maximum temperature limit in degrees Celsius. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFrequency )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOcSetTjMax = dditable->Frequency->pfnOcSetTjMax; + if( nullptr == pfnOcSetTjMax ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOcSetTjMax( hFrequency, ocTjMax ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumLeds + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumLeds( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_led_handle_t* phLed ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumLeds = dditable->Device->pfnEnumLeds; + if( nullptr == pfnEnumLeds ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumLeds( hDevice, pCount, phLed ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesLedGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesLedGetProperties( + zes_led_handle_t hLed, ///< [in] Handle for the component. + zes_led_properties_t* pProperties ///< [in,out] Will contain the properties of the LED. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hLed )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Led->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hLed, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesLedGetState + __zedlllocal ze_result_t ZE_APICALL + zesLedGetState( + zes_led_handle_t hLed, ///< [in] Handle for the component. + zes_led_state_t* pState ///< [in,out] Will contain the current state of the LED. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hLed )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Led->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hLed, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesLedSetState + __zedlllocal ze_result_t ZE_APICALL + zesLedSetState( + zes_led_handle_t hLed, ///< [in] Handle for the component. + ze_bool_t enable ///< [in] Set to TRUE to turn the LED on, FALSE to turn off. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hLed )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetState = dditable->Led->pfnSetState; + if( nullptr == pfnSetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetState( hLed, enable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesLedSetColor + __zedlllocal ze_result_t ZE_APICALL + zesLedSetColor( + zes_led_handle_t hLed, ///< [in] Handle for the component. + const zes_led_color_t* pColor ///< [in] New color of the LED. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hLed )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetColor = dditable->Led->pfnSetColor; + if( nullptr == pfnSetColor ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetColor( hLed, pColor ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumMemoryModules + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumMemoryModules( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_mem_handle_t* phMemory ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumMemoryModules = dditable->Device->pfnEnumMemoryModules; + if( nullptr == pfnEnumMemoryModules ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumMemoryModules( hDevice, pCount, phMemory ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesMemoryGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetProperties( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_properties_t* pProperties ///< [in,out] Will contain memory properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMemory )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Memory->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hMemory, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesMemoryGetState + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetState( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_state_t* pState ///< [in,out] Will contain the current health and allocated memory. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMemory )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Memory->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hMemory, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesMemoryGetBandwidth + __zedlllocal ze_result_t ZE_APICALL + zesMemoryGetBandwidth( + zes_mem_handle_t hMemory, ///< [in] Handle for the component. + zes_mem_bandwidth_t* pBandwidth ///< [in,out] Will contain the total number of bytes read from and written + ///< to memory, as well as the current maximum bandwidth. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMemory )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetBandwidth = dditable->Memory->pfnGetBandwidth; + if( nullptr == pfnGetBandwidth ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetBandwidth( hMemory, pBandwidth ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumPerformanceFactorDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPerformanceFactorDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_perf_handle_t* phPerf ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumPerformanceFactorDomains = dditable->Device->pfnEnumPerformanceFactorDomains; + if( nullptr == pfnEnumPerformanceFactorDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumPerformanceFactorDomains( hDevice, pCount, phPerf ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPerformanceFactorGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorGetProperties( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + zes_perf_properties_t* pProperties ///< [in,out] Will contain information about the specified Performance + ///< Factor domain. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPerf )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->PerformanceFactor->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hPerf, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPerformanceFactorGetConfig + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorGetConfig( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + double* pFactor ///< [in,out] Will contain the actual Performance Factor being used by the + ///< hardware (may not be the same as the requested Performance Factor). + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPerf )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConfig = dditable->PerformanceFactor->pfnGetConfig; + if( nullptr == pfnGetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConfig( hPerf, pFactor ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPerformanceFactorSetConfig + __zedlllocal ze_result_t ZE_APICALL + zesPerformanceFactorSetConfig( + zes_perf_handle_t hPerf, ///< [in] Handle for the Performance Factor domain. + double factor ///< [in] The new Performance Factor. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPerf )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetConfig = dditable->PerformanceFactor->pfnSetConfig; + if( nullptr == pfnSetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetConfig( hPerf, factor ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumPowerDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPowerDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_pwr_handle_t* phPower ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumPowerDomains = dditable->Device->pfnEnumPowerDomains; + if( nullptr == pfnEnumPowerDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumPowerDomains( hDevice, pCount, phPower ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetCardPowerDomain + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetCardPowerDomain( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + zes_pwr_handle_t* phPower ///< [in,out] power domain handle for the entire PCIe card. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetCardPowerDomain = dditable->Device->pfnGetCardPowerDomain; + if( nullptr == pfnGetCardPowerDomain ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetCardPowerDomain( hDevice, phPower ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetProperties( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_properties_t* pProperties ///< [in,out] Structure that will contain property data. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Power->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hPower, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerGetEnergyCounter + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetEnergyCounter( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_energy_counter_t* pEnergy ///< [in,out] Will contain the latest snapshot of the energy counter and + ///< timestamp when the last counter value was measured. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetEnergyCounter = dditable->Power->pfnGetEnergyCounter; + if( nullptr == pfnGetEnergyCounter ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetEnergyCounter( hPower, pEnergy ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerGetLimits + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetLimits( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_power_sustained_limit_t* pSustained, ///< [in,out][optional] The sustained power limit. If this is null, the + ///< current sustained power limits will not be returned. + zes_power_burst_limit_t* pBurst, ///< [in,out][optional] The burst power limit. If this is null, the current + ///< peak power limits will not be returned. + zes_power_peak_limit_t* pPeak ///< [in,out][optional] The peak power limit. If this is null, the peak + ///< power limits will not be returned. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetLimits = dditable->Power->pfnGetLimits; + if( nullptr == pfnGetLimits ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetLimits( hPower, pSustained, pBurst, pPeak ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerSetLimits + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetLimits( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + const zes_power_sustained_limit_t* pSustained, ///< [in][optional] The sustained power limit. If this is null, no changes + ///< will be made to the sustained power limits. + const zes_power_burst_limit_t* pBurst, ///< [in][optional] The burst power limit. If this is null, no changes will + ///< be made to the burst power limits. + const zes_power_peak_limit_t* pPeak ///< [in][optional] The peak power limit. If this is null, no changes will + ///< be made to the peak power limits. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetLimits = dditable->Power->pfnSetLimits; + if( nullptr == pfnSetLimits ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetLimits( hPower, pSustained, pBurst, pPeak ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerGetEnergyThreshold + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetEnergyThreshold( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + zes_energy_threshold_t* pThreshold ///< [in,out] Returns information about the energy threshold setting - + ///< enabled/energy threshold/process ID. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetEnergyThreshold = dditable->Power->pfnGetEnergyThreshold; + if( nullptr == pfnGetEnergyThreshold ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetEnergyThreshold( hPower, pThreshold ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerSetEnergyThreshold + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetEnergyThreshold( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + double threshold ///< [in] The energy threshold to be set in joules. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetEnergyThreshold = dditable->Power->pfnSetEnergyThreshold; + if( nullptr == pfnSetEnergyThreshold ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetEnergyThreshold( hPower, threshold ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumPsus + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumPsus( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_psu_handle_t* phPsu ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumPsus = dditable->Device->pfnEnumPsus; + if( nullptr == pfnEnumPsus ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumPsus( hDevice, pCount, phPsu ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPsuGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesPsuGetProperties( + zes_psu_handle_t hPsu, ///< [in] Handle for the component. + zes_psu_properties_t* pProperties ///< [in,out] Will contain the properties of the power supply. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPsu )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Psu->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hPsu, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPsuGetState + __zedlllocal ze_result_t ZE_APICALL + zesPsuGetState( + zes_psu_handle_t hPsu, ///< [in] Handle for the component. + zes_psu_state_t* pState ///< [in,out] Will contain the current state of the power supply. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPsu )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Psu->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hPsu, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumRasErrorSets + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumRasErrorSets( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_ras_handle_t* phRas ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumRasErrorSets = dditable->Device->pfnEnumRasErrorSets; + if( nullptr == pfnEnumRasErrorSets ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumRasErrorSets( hDevice, pCount, phRas ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesRasGetProperties( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_properties_t* pProperties ///< [in,out] Structure describing RAS properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Ras->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hRas, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasGetConfig + __zedlllocal ze_result_t ZE_APICALL + zesRasGetConfig( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_config_t* pConfig ///< [in,out] Will be populed with the current RAS configuration - + ///< thresholds used to trigger events + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConfig = dditable->Ras->pfnGetConfig; + if( nullptr == pfnGetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConfig( hRas, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasSetConfig + __zedlllocal ze_result_t ZE_APICALL + zesRasSetConfig( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + const zes_ras_config_t* pConfig ///< [in] Change the RAS configuration - thresholds used to trigger events + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetConfig = dditable->Ras->pfnSetConfig; + if( nullptr == pfnSetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetConfig( hRas, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasGetState + __zedlllocal ze_result_t ZE_APICALL + zesRasGetState( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + ze_bool_t clear, ///< [in] Set to 1 to clear the counters of this type + zes_ras_state_t* pState ///< [in,out] Breakdown of where errors have occurred + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Ras->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hRas, clear, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumSchedulers + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumSchedulers( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_sched_handle_t* phScheduler ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumSchedulers = dditable->Device->pfnEnumSchedulers; + if( nullptr == pfnEnumSchedulers ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumSchedulers( hDevice, pCount, phScheduler ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetProperties( + zes_sched_handle_t hScheduler, ///< [in] Handle for the component. + zes_sched_properties_t* pProperties ///< [in,out] Structure that will contain property data. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Scheduler->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hScheduler, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerGetCurrentMode + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetCurrentMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_mode_t* pMode ///< [in,out] Will contain the current scheduler mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetCurrentMode = dditable->Scheduler->pfnGetCurrentMode; + if( nullptr == pfnGetCurrentMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetCurrentMode( hScheduler, pMode ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerGetTimeoutModeProperties + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetTimeoutModeProperties( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t getDefaults, ///< [in] If TRUE, the driver will return the system default properties for + ///< this mode, otherwise it will return the current properties. + zes_sched_timeout_properties_t* pConfig ///< [in,out] Will contain the current parameters for this mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetTimeoutModeProperties = dditable->Scheduler->pfnGetTimeoutModeProperties; + if( nullptr == pfnGetTimeoutModeProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetTimeoutModeProperties( hScheduler, getDefaults, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerGetTimesliceModeProperties + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerGetTimesliceModeProperties( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t getDefaults, ///< [in] If TRUE, the driver will return the system default properties for + ///< this mode, otherwise it will return the current properties. + zes_sched_timeslice_properties_t* pConfig ///< [in,out] Will contain the current parameters for this mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetTimesliceModeProperties = dditable->Scheduler->pfnGetTimesliceModeProperties; + if( nullptr == pfnGetTimesliceModeProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetTimesliceModeProperties( hScheduler, getDefaults, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerSetTimeoutMode + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetTimeoutMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_timeout_properties_t* pProperties, ///< [in] The properties to use when configurating this mode. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetTimeoutMode = dditable->Scheduler->pfnSetTimeoutMode; + if( nullptr == pfnSetTimeoutMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetTimeoutMode( hScheduler, pProperties, pNeedReload ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerSetTimesliceMode + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetTimesliceMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + zes_sched_timeslice_properties_t* pProperties, ///< [in] The properties to use when configurating this mode. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetTimesliceMode = dditable->Scheduler->pfnSetTimesliceMode; + if( nullptr == pfnSetTimesliceMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetTimesliceMode( hScheduler, pProperties, pNeedReload ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerSetExclusiveMode + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetExclusiveMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetExclusiveMode = dditable->Scheduler->pfnSetExclusiveMode; + if( nullptr == pfnSetExclusiveMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetExclusiveMode( hScheduler, pNeedReload ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesSchedulerSetComputeUnitDebugMode + __zedlllocal ze_result_t ZE_APICALL + zesSchedulerSetComputeUnitDebugMode( + zes_sched_handle_t hScheduler, ///< [in] Sysman handle for the component. + ze_bool_t* pNeedReload ///< [in,out] Will be set to TRUE if a device driver reload is needed to + ///< apply the new scheduler mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hScheduler )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetComputeUnitDebugMode = dditable->Scheduler->pfnSetComputeUnitDebugMode; + if( nullptr == pfnSetComputeUnitDebugMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetComputeUnitDebugMode( hScheduler, pNeedReload ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumStandbyDomains + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumStandbyDomains( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_standby_handle_t* phStandby ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumStandbyDomains = dditable->Device->pfnEnumStandbyDomains; + if( nullptr == pfnEnumStandbyDomains ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumStandbyDomains( hDevice, pCount, phStandby ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesStandbyGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesStandbyGetProperties( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_properties_t* pProperties ///< [in,out] Will contain the standby hardware properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hStandby )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Standby->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hStandby, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesStandbyGetMode + __zedlllocal ze_result_t ZE_APICALL + zesStandbyGetMode( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_promo_mode_t* pMode ///< [in,out] Will contain the current standby mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hStandby )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetMode = dditable->Standby->pfnGetMode; + if( nullptr == pfnGetMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetMode( hStandby, pMode ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesStandbySetMode + __zedlllocal ze_result_t ZE_APICALL + zesStandbySetMode( + zes_standby_handle_t hStandby, ///< [in] Handle for the component. + zes_standby_promo_mode_t mode ///< [in] New standby mode. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hStandby )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetMode = dditable->Standby->pfnSetMode; + if( nullptr == pfnSetMode ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetMode( hStandby, mode ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumTemperatureSensors + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumTemperatureSensors( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_temp_handle_t* phTemperature ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumTemperatureSensors = dditable->Device->pfnEnumTemperatureSensors; + if( nullptr == pfnEnumTemperatureSensors ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumTemperatureSensors( hDevice, pCount, phTemperature ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesTemperatureGetProperties + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetProperties( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + zes_temp_properties_t* pProperties ///< [in,out] Will contain the temperature sensor properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTemperature )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Temperature->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hTemperature, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesTemperatureGetConfig + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetConfig( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + zes_temp_config_t* pConfig ///< [in,out] Returns current configuration. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTemperature )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConfig = dditable->Temperature->pfnGetConfig; + if( nullptr == pfnGetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConfig( hTemperature, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesTemperatureSetConfig + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureSetConfig( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + const zes_temp_config_t* pConfig ///< [in] New configuration. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTemperature )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetConfig = dditable->Temperature->pfnSetConfig; + if( nullptr == pfnSetConfig ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetConfig( hTemperature, pConfig ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesTemperatureGetState + __zedlllocal ze_result_t ZE_APICALL + zesTemperatureGetState( + zes_temp_handle_t hTemperature, ///< [in] Handle for the component. + double* pTemperature ///< [in,out] Will contain the temperature read from the specified sensor + ///< in degrees Celsius. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTemperature )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetState = dditable->Temperature->pfnGetState; + if( nullptr == pfnGetState ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetState( hTemperature, pTemperature ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerGetLimitsExt + __zedlllocal ze_result_t ZE_APICALL + zesPowerGetLimitsExt( + zes_pwr_handle_t hPower, ///< [in] Power domain handle instance. + uint32_t* pCount, ///< [in,out] Pointer to the number of power limit descriptors. If count is + ///< zero, then the driver shall update the value with the total number of + ///< components of this type that are available. If count is greater than + ///< the number of components of this type that are available, then the + ///< driver shall update the value with the correct number of components. + zes_power_limit_ext_desc_t* pSustained ///< [in,out][optional][range(0, *pCount)] Array of query results for power + ///< limit descriptors. If count is less than the number of components of + ///< this type that are available, then the driver shall only retrieve that + ///< number of components. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetLimitsExt = dditable->Power->pfnGetLimitsExt; + if( nullptr == pfnGetLimitsExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetLimitsExt( hPower, pCount, pSustained ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesPowerSetLimitsExt + __zedlllocal ze_result_t ZE_APICALL + zesPowerSetLimitsExt( + zes_pwr_handle_t hPower, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in] Pointer to the number of power limit descriptors. + zes_power_limit_ext_desc_t* pSustained ///< [in][optional][range(0, *pCount)] Array of power limit descriptors. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hPower )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetLimitsExt = dditable->Power->pfnSetLimitsExt; + if( nullptr == pfnSetLimitsExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetLimitsExt( hPower, pCount, pSustained ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesEngineGetActivityExt + __zedlllocal ze_result_t ZE_APICALL + zesEngineGetActivityExt( + zes_engine_handle_t hEngine, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_engine_stats_t* pStats ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector with engine stat for + ///< PF at index 0 of the vector followed by user provided pCount-1 number + ///< of VF engine stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hEngine )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_7) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetActivityExt = dditable->Engine->pfnGetActivityExt; + if( nullptr == pfnGetActivityExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetActivityExt( hEngine, pCount, pStats ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasGetStateExp + __zedlllocal ze_result_t ZE_APICALL + zesRasGetStateExp( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + uint32_t* pCount, ///< [in,out] pointer to the number of RAS state structures that can be retrieved. + ///< if count is zero, then the driver shall update the value with the + ///< total number of error categories for which state can be retrieved. + ///< if count is greater than the number of RAS states available, then the + ///< driver shall update the value with the correct number of RAS states available. + zes_ras_state_exp_t* pState ///< [in,out][optional][range(0, *pCount)] array of query results for RAS + ///< error states for different categories. + ///< if count is less than the number of RAS states available, then driver + ///< shall only retrieve that number of RAS states. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetStateExp = dditable->RasExp->pfnGetStateExp; + if( nullptr == pfnGetStateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetStateExp( hRas, pCount, pState ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesRasClearStateExp + __zedlllocal ze_result_t ZE_APICALL + zesRasClearStateExp( + zes_ras_handle_t hRas, ///< [in] Handle for the component. + zes_ras_error_category_exp_t category ///< [in] category for which error counter is to be cleared. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hRas )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnClearStateExp = dditable->RasExp->pfnClearStateExp; + if( nullptr == pfnClearStateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnClearStateExp( hRas, category ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareGetSecurityVersionExp + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareGetSecurityVersionExp( + zes_firmware_handle_t hFirmware, ///< [in] Handle for the component. + char* pVersion ///< [in,out] NULL terminated string value. The string "unknown" will be + ///< returned if this property cannot be determined. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSecurityVersionExp = dditable->FirmwareExp->pfnGetSecurityVersionExp; + if( nullptr == pfnGetSecurityVersionExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSecurityVersionExp( hFirmware, pVersion ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesFirmwareSetSecurityVersionExp + __zedlllocal ze_result_t ZE_APICALL + zesFirmwareSetSecurityVersionExp( + zes_firmware_handle_t hFirmware ///< [in] Handle for the component. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hFirmware )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetSecurityVersionExp = dditable->FirmwareExp->pfnSetSecurityVersionExp; + if( nullptr == pfnSetSecurityVersionExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetSecurityVersionExp( hFirmware ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceGetSubDevicePropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceGetSubDevicePropertiesExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of sub devices. + ///< if count is zero, then the driver shall update the value with the + ///< total number of sub devices currently attached to the device. + ///< if count is greater than the number of sub devices currently attached + ///< to the device, then the driver shall update the value with the correct + ///< number of sub devices. + zes_subdevice_exp_properties_t* pSubdeviceProps ///< [in,out][optional][range(0, *pCount)] array of sub device property structures. + ///< if count is less than the number of sysman sub devices available, then + ///< the driver shall only retrieve that number of sub device property structures. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetSubDevicePropertiesExp = dditable->DeviceExp->pfnGetSubDevicePropertiesExp; + if( nullptr == pfnGetSubDevicePropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetSubDevicePropertiesExp( hDevice, pCount, pSubdeviceProps ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDriverGetDeviceByUuidExp + __zedlllocal ze_result_t ZE_APICALL + zesDriverGetDeviceByUuidExp( + zes_driver_handle_t hDriver, ///< [in] handle of the sysman driver instance + zes_uuid_t uuid, ///< [in] universal unique identifier. + zes_device_handle_t* phDevice, ///< [out] Sysman handle of the device. + ze_bool_t* onSubdevice, ///< [out] True if the UUID belongs to the sub-device; false means that + ///< UUID belongs to the root device. + uint32_t* subdeviceId ///< [out] If onSubdevice is true, this gives the ID of the sub-device + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDeviceByUuidExp = dditable->DriverExp->pfnGetDeviceByUuidExp; + if( nullptr == pfnGetDeviceByUuidExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDeviceByUuidExp( hDriver, uuid, phDevice, onSubdevice, subdeviceId ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumActiveVFExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumActiveVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumActiveVFExp = dditable->DeviceExp->pfnEnumActiveVFExp; + if( nullptr == pfnEnumActiveVFExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumActiveVFExp( hDevice, pCount, phVFhandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFPropertiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFPropertiesExp = dditable->VFManagementExp->pfnGetVFPropertiesExp; + if( nullptr == pfnGetVFPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFPropertiesExp( hVFhandle, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFMemoryUtilizationExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_vf_util_mem_exp_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFMemoryUtilizationExp = dditable->VFManagementExp->pfnGetVFMemoryUtilizationExp; + if( nullptr == pfnGetVFMemoryUtilizationExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFMemoryUtilizationExp( hVFhandle, pCount, pMemUtil ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFEngineUtilizationExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + ///< - The count returned is the sum of number of VF instances currently + ///< available and the PF instance. + zes_vf_util_engine_exp_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFEngineUtilizationExp = dditable->VFManagementExp->pfnGetVFEngineUtilizationExp; + if( nullptr == pfnGetVFEngineUtilizationExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFEngineUtilizationExp( hVFhandle, pCount, pEngineUtil ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementSetVFTelemetryModeExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementSetVFTelemetryModeExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid + ///< combination of ::zes_vf_info_util_exp_flag_t. + ze_bool_t enable ///< [in] Enable utilization telemetry. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetVFTelemetryModeExp = dditable->VFManagementExp->pfnSetVFTelemetryModeExp; + if( nullptr == pfnSetVFTelemetryModeExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetVFTelemetryModeExp( hVFhandle, flags, enable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementSetVFTelemetrySamplingIntervalExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementSetVFTelemetrySamplingIntervalExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid + ///< combination of ::zes_vf_info_util_exp_flag_t. + uint64_t samplingInterval ///< [in] Sampling interval value. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetVFTelemetrySamplingIntervalExp = dditable->VFManagementExp->pfnSetVFTelemetrySamplingIntervalExp; + if( nullptr == pfnSetVFTelemetrySamplingIntervalExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumEnabledVFExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnumEnabledVFExp = dditable->DeviceExp->pfnEnumEnabledVFExp; + if( nullptr == pfnEnumEnabledVFExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFCapabilitiesExp = dditable->VFManagementExp->pfnGetVFCapabilitiesExp; + if( nullptr == pfnGetVFCapabilitiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFMemoryUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFMemoryUtilizationExp2 = dditable->VFManagementExp->pfnGetVFMemoryUtilizationExp2; + if( nullptr == pfnGetVFMemoryUtilizationExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFMemoryUtilizationExp2( hVFhandle, pCount, pMemUtil ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFEngineUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFEngineUtilizationExp2 = dditable->VFManagementExp->pfnGetVFEngineUtilizationExp2; + if( nullptr == pfnGetVFEngineUtilizationExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->pSysman; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_12) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetVFCapabilitiesExp2 = dditable->VFManagementExp->pfnGetVFCapabilitiesExp2; + if( nullptr == pfnGetVFCapabilitiesExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetVFCapabilitiesExp2( hVFhandle, pCapability ); + return result; + } + + + /////////////////////////////////////////////////////////////////////////////// + /// @brief function for removing the ddi driver tables for zes + __zedlllocal void ZE_APICALL + zesDestroyDDiDriverTables(zes_dditable_driver_t* pDdiTable) + { + // Delete ddi tables + delete pDdiTable->Global; + delete pDdiTable->Device; + delete pDdiTable->DeviceExp; + delete pDdiTable->Driver; + delete pDdiTable->DriverExp; + delete pDdiTable->Diagnostics; + delete pDdiTable->Engine; + delete pDdiTable->FabricPort; + delete pDdiTable->Fan; + delete pDdiTable->Firmware; + delete pDdiTable->FirmwareExp; + delete pDdiTable->Frequency; + delete pDdiTable->Led; + delete pDdiTable->Memory; + delete pDdiTable->Overclock; + delete pDdiTable->PerformanceFactor; + delete pDdiTable->Power; + delete pDdiTable->Psu; + delete pDdiTable->Ras; + delete pDdiTable->RasExp; + delete pDdiTable->Scheduler; + delete pDdiTable->Standby; + delete pDdiTable->Temperature; + delete pDdiTable->VFManagementExp; + delete pDdiTable; + } + +} // namespace loader_driver_ddi \ No newline at end of file diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index 3077950e..35dd7fd8 100644 --- a/source/loader/zet_ldrddi.cpp +++ b/source/loader/zet_ldrddi.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -9,6 +9,8 @@ */ #include "ze_loader_internal.h" +using namespace loader_driver_ddi; + namespace loader { /////////////////////////////////////////////////////////////////////////////// @@ -2377,6 +2379,228 @@ namespace loader extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricDecoderExp table +__zedlllocal void ZE_APICALL +zetGetMetricDecoderExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricDecoderExp->pfnCreateExp = loader::zetMetricDecoderCreateExp; + loader::loaderDispatch->pTools->MetricDecoderExp->pfnDestroyExp = loader::zetMetricDecoderDestroyExp; + loader::loaderDispatch->pTools->MetricDecoderExp->pfnGetDecodableMetricsExp = loader::zetMetricDecoderGetDecodableMetricsExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricProgrammableExp table +__zedlllocal void ZE_APICALL +zetGetMetricProgrammableExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricProgrammableExp->pfnGetExp = loader::zetMetricProgrammableGetExp; + loader::loaderDispatch->pTools->MetricProgrammableExp->pfnGetPropertiesExp = loader::zetMetricProgrammableGetPropertiesExp; + loader::loaderDispatch->pTools->MetricProgrammableExp->pfnGetParamInfoExp = loader::zetMetricProgrammableGetParamInfoExp; + loader::loaderDispatch->pTools->MetricProgrammableExp->pfnGetParamValueInfoExp = loader::zetMetricProgrammableGetParamValueInfoExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricTracerExp table +__zedlllocal void ZE_APICALL +zetGetMetricTracerExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricTracerExp->pfnCreateExp = loader::zetMetricTracerCreateExp; + loader::loaderDispatch->pTools->MetricTracerExp->pfnDestroyExp = loader::zetMetricTracerDestroyExp; + loader::loaderDispatch->pTools->MetricTracerExp->pfnEnableExp = loader::zetMetricTracerEnableExp; + loader::loaderDispatch->pTools->MetricTracerExp->pfnDisableExp = loader::zetMetricTracerDisableExp; + loader::loaderDispatch->pTools->MetricTracerExp->pfnReadDataExp = loader::zetMetricTracerReadDataExp; + loader::loaderDispatch->pTools->MetricTracerExp->pfnDecodeExp = loader::zetMetricTracerDecodeExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Device table +__zedlllocal void ZE_APICALL +zetGetDeviceProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Device->pfnGetDebugProperties = loader::zetDeviceGetDebugProperties; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for DeviceExp table +__zedlllocal void ZE_APICALL +zetGetDeviceExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->DeviceExp->pfnGetConcurrentMetricGroupsExp = loader::zetDeviceGetConcurrentMetricGroupsExp; + loader::loaderDispatch->pTools->DeviceExp->pfnCreateMetricGroupsFromMetricsExp = loader::zetDeviceCreateMetricGroupsFromMetricsExp; + loader::loaderDispatch->pTools->DeviceExp->pfnEnableMetricsExp = loader::zetDeviceEnableMetricsExp; + loader::loaderDispatch->pTools->DeviceExp->pfnDisableMetricsExp = loader::zetDeviceDisableMetricsExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Context table +__zedlllocal void ZE_APICALL +zetGetContextProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Context->pfnActivateMetricGroups = loader::zetContextActivateMetricGroups; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for CommandList table +__zedlllocal void ZE_APICALL +zetGetCommandListProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->CommandList->pfnAppendMetricStreamerMarker = loader::zetCommandListAppendMetricStreamerMarker; + loader::loaderDispatch->pTools->CommandList->pfnAppendMetricQueryBegin = loader::zetCommandListAppendMetricQueryBegin; + loader::loaderDispatch->pTools->CommandList->pfnAppendMetricQueryEnd = loader::zetCommandListAppendMetricQueryEnd; + loader::loaderDispatch->pTools->CommandList->pfnAppendMetricMemoryBarrier = loader::zetCommandListAppendMetricMemoryBarrier; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for CommandListExp table +__zedlllocal void ZE_APICALL +zetGetCommandListExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->CommandListExp->pfnAppendMarkerExp = loader::zetCommandListAppendMarkerExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Kernel table +__zedlllocal void ZE_APICALL +zetGetKernelProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Kernel->pfnGetProfileInfo = loader::zetKernelGetProfileInfo; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Module table +__zedlllocal void ZE_APICALL +zetGetModuleProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Module->pfnGetDebugInfo = loader::zetModuleGetDebugInfo; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Debug table +__zedlllocal void ZE_APICALL +zetGetDebugProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Debug->pfnAttach = loader::zetDebugAttach; + loader::loaderDispatch->pTools->Debug->pfnDetach = loader::zetDebugDetach; + loader::loaderDispatch->pTools->Debug->pfnReadEvent = loader::zetDebugReadEvent; + loader::loaderDispatch->pTools->Debug->pfnAcknowledgeEvent = loader::zetDebugAcknowledgeEvent; + loader::loaderDispatch->pTools->Debug->pfnInterrupt = loader::zetDebugInterrupt; + loader::loaderDispatch->pTools->Debug->pfnResume = loader::zetDebugResume; + loader::loaderDispatch->pTools->Debug->pfnReadMemory = loader::zetDebugReadMemory; + loader::loaderDispatch->pTools->Debug->pfnWriteMemory = loader::zetDebugWriteMemory; + loader::loaderDispatch->pTools->Debug->pfnGetRegisterSetProperties = loader::zetDebugGetRegisterSetProperties; + loader::loaderDispatch->pTools->Debug->pfnReadRegisters = loader::zetDebugReadRegisters; + loader::loaderDispatch->pTools->Debug->pfnWriteRegisters = loader::zetDebugWriteRegisters; + loader::loaderDispatch->pTools->Debug->pfnGetThreadRegisterSetProperties = loader::zetDebugGetThreadRegisterSetProperties; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for Metric table +__zedlllocal void ZE_APICALL +zetGetMetricProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->Metric->pfnGet = loader::zetMetricGet; + loader::loaderDispatch->pTools->Metric->pfnGetProperties = loader::zetMetricGetProperties; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricExp table +__zedlllocal void ZE_APICALL +zetGetMetricExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricExp->pfnCreateFromProgrammableExp2 = loader::zetMetricCreateFromProgrammableExp2; + loader::loaderDispatch->pTools->MetricExp->pfnCreateFromProgrammableExp = loader::zetMetricCreateFromProgrammableExp; + loader::loaderDispatch->pTools->MetricExp->pfnDestroyExp = loader::zetMetricDestroyExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricGroup table +__zedlllocal void ZE_APICALL +zetGetMetricGroupProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricGroup->pfnGet = loader::zetMetricGroupGet; + loader::loaderDispatch->pTools->MetricGroup->pfnGetProperties = loader::zetMetricGroupGetProperties; + loader::loaderDispatch->pTools->MetricGroup->pfnCalculateMetricValues = loader::zetMetricGroupCalculateMetricValues; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricGroupExp table +__zedlllocal void ZE_APICALL +zetGetMetricGroupExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricGroupExp->pfnCalculateMultipleMetricValuesExp = loader::zetMetricGroupCalculateMultipleMetricValuesExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnGetGlobalTimestampsExp = loader::zetMetricGroupGetGlobalTimestampsExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnGetExportDataExp = loader::zetMetricGroupGetExportDataExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnCalculateMetricExportDataExp = loader::zetMetricGroupCalculateMetricExportDataExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnCreateExp = loader::zetMetricGroupCreateExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnAddMetricExp = loader::zetMetricGroupAddMetricExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnRemoveMetricExp = loader::zetMetricGroupRemoveMetricExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnCloseExp = loader::zetMetricGroupCloseExp; + loader::loaderDispatch->pTools->MetricGroupExp->pfnDestroyExp = loader::zetMetricGroupDestroyExp; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricQuery table +__zedlllocal void ZE_APICALL +zetGetMetricQueryProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricQuery->pfnCreate = loader::zetMetricQueryCreate; + loader::loaderDispatch->pTools->MetricQuery->pfnDestroy = loader::zetMetricQueryDestroy; + loader::loaderDispatch->pTools->MetricQuery->pfnReset = loader::zetMetricQueryReset; + loader::loaderDispatch->pTools->MetricQuery->pfnGetData = loader::zetMetricQueryGetData; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricQueryPool table +__zedlllocal void ZE_APICALL +zetGetMetricQueryPoolProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricQueryPool->pfnCreate = loader::zetMetricQueryPoolCreate; + loader::loaderDispatch->pTools->MetricQueryPool->pfnDestroy = loader::zetMetricQueryPoolDestroy; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for MetricStreamer table +__zedlllocal void ZE_APICALL +zetGetMetricStreamerProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->MetricStreamer->pfnOpen = loader::zetMetricStreamerOpen; + loader::loaderDispatch->pTools->MetricStreamer->pfnClose = loader::zetMetricStreamerClose; + loader::loaderDispatch->pTools->MetricStreamer->pfnReadData = loader::zetMetricStreamerReadData; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief function for filling the legacy api pointers for TracerExp table +__zedlllocal void ZE_APICALL +zetGetTracerExpProcAddrTableLegacy() +{ + // return pointers to the Loader's Functions. + loader::loaderDispatch->pTools->TracerExp->pfnCreate = loader::zetTracerExpCreate; + loader::loaderDispatch->pTools->TracerExp->pfnDestroy = loader::zetTracerExpDestroy; + loader::loaderDispatch->pTools->TracerExp->pfnSetPrologues = loader::zetTracerExpSetPrologues; + loader::loaderDispatch->pTools->TracerExp->pfnSetEpilogues = loader::zetTracerExpSetEpilogues; + loader::loaderDispatch->pTools->TracerExp->pfnSetEnabled = loader::zetTracerExpSetEnabled; +} + + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's MetricDecoderExp table /// with current process' addresses @@ -2422,15 +2646,29 @@ zetGetMetricDecoderExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricDecoderExp = new zet_metric_decoder_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExp = loader_driver_ddi::zetMetricDecoderCreateExp; + } else { pDdiTable->pfnCreateExp = loader::zetMetricDecoderCreateExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zetMetricDecoderDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zetMetricDecoderDestroyExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDecodableMetricsExp = loader_driver_ddi::zetMetricDecoderGetDecodableMetricsExp; + } else { pDdiTable->pfnGetDecodableMetricsExp = loader::zetMetricDecoderGetDecodableMetricsExp; } + } + zetGetMetricDecoderExpProcAddrTableLegacy(); } else { @@ -2497,18 +2735,36 @@ zetGetMetricProgrammableExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricProgrammableExp = new zet_metric_programmable_exp_dditable_t; if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExp = loader_driver_ddi::zetMetricProgrammableGetExp; + } else { pDdiTable->pfnGetExp = loader::zetMetricProgrammableGetExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetPropertiesExp = loader_driver_ddi::zetMetricProgrammableGetPropertiesExp; + } else { pDdiTable->pfnGetPropertiesExp = loader::zetMetricProgrammableGetPropertiesExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetParamInfoExp = loader_driver_ddi::zetMetricProgrammableGetParamInfoExp; + } else { pDdiTable->pfnGetParamInfoExp = loader::zetMetricProgrammableGetParamInfoExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetParamValueInfoExp = loader_driver_ddi::zetMetricProgrammableGetParamValueInfoExp; + } else { pDdiTable->pfnGetParamValueInfoExp = loader::zetMetricProgrammableGetParamValueInfoExp; } + } + zetGetMetricProgrammableExpProcAddrTableLegacy(); } else { @@ -2575,24 +2831,50 @@ zetGetMetricTracerExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricTracerExp = new zet_metric_tracer_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExp = loader_driver_ddi::zetMetricTracerCreateExp; + } else { pDdiTable->pfnCreateExp = loader::zetMetricTracerCreateExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zetMetricTracerDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zetMetricTracerDestroyExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnableExp = loader_driver_ddi::zetMetricTracerEnableExp; + } else { pDdiTable->pfnEnableExp = loader::zetMetricTracerEnableExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDisableExp = loader_driver_ddi::zetMetricTracerDisableExp; + } else { pDdiTable->pfnDisableExp = loader::zetMetricTracerDisableExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadDataExp = loader_driver_ddi::zetMetricTracerReadDataExp; + } else { pDdiTable->pfnReadDataExp = loader::zetMetricTracerReadDataExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDecodeExp = loader_driver_ddi::zetMetricTracerDecodeExp; + } else { pDdiTable->pfnDecodeExp = loader::zetMetricTracerDecodeExp; } + } + zetGetMetricTracerExpProcAddrTableLegacy(); } else { @@ -2669,9 +2951,15 @@ zetGetDeviceProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Device = new zet_device_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDebugProperties = loader_driver_ddi::zetDeviceGetDebugProperties; + } else { pDdiTable->pfnGetDebugProperties = loader::zetDeviceGetDebugProperties; } + } + zetGetDeviceProcAddrTableLegacy(); } else { @@ -2738,18 +3026,36 @@ zetGetDeviceExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->DeviceExp = new zet_device_exp_dditable_t; if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetConcurrentMetricGroupsExp = loader_driver_ddi::zetDeviceGetConcurrentMetricGroupsExp; + } else { pDdiTable->pfnGetConcurrentMetricGroupsExp = loader::zetDeviceGetConcurrentMetricGroupsExp; } + } if (version >= ZE_API_VERSION_1_10) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateMetricGroupsFromMetricsExp = loader_driver_ddi::zetDeviceCreateMetricGroupsFromMetricsExp; + } else { pDdiTable->pfnCreateMetricGroupsFromMetricsExp = loader::zetDeviceCreateMetricGroupsFromMetricsExp; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnEnableMetricsExp = loader_driver_ddi::zetDeviceEnableMetricsExp; + } else { pDdiTable->pfnEnableMetricsExp = loader::zetDeviceEnableMetricsExp; } + } if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDisableMetricsExp = loader_driver_ddi::zetDeviceDisableMetricsExp; + } else { pDdiTable->pfnDisableMetricsExp = loader::zetDeviceDisableMetricsExp; } + } + zetGetDeviceExpProcAddrTableLegacy(); } else { @@ -2826,9 +3132,15 @@ zetGetContextProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Context = new zet_context_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnActivateMetricGroups = loader_driver_ddi::zetContextActivateMetricGroups; + } else { pDdiTable->pfnActivateMetricGroups = loader::zetContextActivateMetricGroups; } + } + zetGetContextProcAddrTableLegacy(); } else { @@ -2905,18 +3217,36 @@ zetGetCommandListProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->CommandList = new zet_command_list_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMetricStreamerMarker = loader_driver_ddi::zetCommandListAppendMetricStreamerMarker; + } else { pDdiTable->pfnAppendMetricStreamerMarker = loader::zetCommandListAppendMetricStreamerMarker; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMetricQueryBegin = loader_driver_ddi::zetCommandListAppendMetricQueryBegin; + } else { pDdiTable->pfnAppendMetricQueryBegin = loader::zetCommandListAppendMetricQueryBegin; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMetricQueryEnd = loader_driver_ddi::zetCommandListAppendMetricQueryEnd; + } else { pDdiTable->pfnAppendMetricQueryEnd = loader::zetCommandListAppendMetricQueryEnd; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMetricMemoryBarrier = loader_driver_ddi::zetCommandListAppendMetricMemoryBarrier; + } else { pDdiTable->pfnAppendMetricMemoryBarrier = loader::zetCommandListAppendMetricMemoryBarrier; } + } + zetGetCommandListProcAddrTableLegacy(); } else { @@ -2983,9 +3313,15 @@ zetGetCommandListExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->CommandListExp = new zet_command_list_exp_dditable_t; if (version >= ZE_API_VERSION_1_13) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAppendMarkerExp = loader_driver_ddi::zetCommandListAppendMarkerExp; + } else { pDdiTable->pfnAppendMarkerExp = loader::zetCommandListAppendMarkerExp; } + } + zetGetCommandListExpProcAddrTableLegacy(); } else { @@ -3062,9 +3398,15 @@ zetGetKernelProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Kernel = new zet_kernel_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProfileInfo = loader_driver_ddi::zetKernelGetProfileInfo; + } else { pDdiTable->pfnGetProfileInfo = loader::zetKernelGetProfileInfo; } + } + zetGetKernelProcAddrTableLegacy(); } else { @@ -3141,9 +3483,15 @@ zetGetModuleProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Module = new zet_module_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetDebugInfo = loader_driver_ddi::zetModuleGetDebugInfo; + } else { pDdiTable->pfnGetDebugInfo = loader::zetModuleGetDebugInfo; } + } + zetGetModuleProcAddrTableLegacy(); } else { @@ -3220,42 +3568,92 @@ zetGetDebugProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Debug = new zet_debug_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAttach = loader_driver_ddi::zetDebugAttach; + } else { pDdiTable->pfnAttach = loader::zetDebugAttach; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDetach = loader_driver_ddi::zetDebugDetach; + } else { pDdiTable->pfnDetach = loader::zetDebugDetach; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadEvent = loader_driver_ddi::zetDebugReadEvent; + } else { pDdiTable->pfnReadEvent = loader::zetDebugReadEvent; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAcknowledgeEvent = loader_driver_ddi::zetDebugAcknowledgeEvent; + } else { pDdiTable->pfnAcknowledgeEvent = loader::zetDebugAcknowledgeEvent; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnInterrupt = loader_driver_ddi::zetDebugInterrupt; + } else { pDdiTable->pfnInterrupt = loader::zetDebugInterrupt; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnResume = loader_driver_ddi::zetDebugResume; + } else { pDdiTable->pfnResume = loader::zetDebugResume; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadMemory = loader_driver_ddi::zetDebugReadMemory; + } else { pDdiTable->pfnReadMemory = loader::zetDebugReadMemory; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnWriteMemory = loader_driver_ddi::zetDebugWriteMemory; + } else { pDdiTable->pfnWriteMemory = loader::zetDebugWriteMemory; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetRegisterSetProperties = loader_driver_ddi::zetDebugGetRegisterSetProperties; + } else { pDdiTable->pfnGetRegisterSetProperties = loader::zetDebugGetRegisterSetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadRegisters = loader_driver_ddi::zetDebugReadRegisters; + } else { pDdiTable->pfnReadRegisters = loader::zetDebugReadRegisters; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnWriteRegisters = loader_driver_ddi::zetDebugWriteRegisters; + } else { pDdiTable->pfnWriteRegisters = loader::zetDebugWriteRegisters; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetThreadRegisterSetProperties = loader_driver_ddi::zetDebugGetThreadRegisterSetProperties; + } else { pDdiTable->pfnGetThreadRegisterSetProperties = loader::zetDebugGetThreadRegisterSetProperties; } + } + zetGetDebugProcAddrTableLegacy(); } else { @@ -3332,12 +3730,22 @@ zetGetMetricProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->Metric = new zet_metric_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGet = loader_driver_ddi::zetMetricGet; + } else { pDdiTable->pfnGet = loader::zetMetricGet; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zetMetricGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zetMetricGetProperties; } + } + zetGetMetricProcAddrTableLegacy(); } else { @@ -3404,15 +3812,29 @@ zetGetMetricExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricExp = new zet_metric_exp_dditable_t; if (version >= ZE_API_VERSION_1_11) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateFromProgrammableExp2 = loader_driver_ddi::zetMetricCreateFromProgrammableExp2; + } else { pDdiTable->pfnCreateFromProgrammableExp2 = loader::zetMetricCreateFromProgrammableExp2; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateFromProgrammableExp = loader_driver_ddi::zetMetricCreateFromProgrammableExp; + } else { pDdiTable->pfnCreateFromProgrammableExp = loader::zetMetricCreateFromProgrammableExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zetMetricDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zetMetricDestroyExp; } + } + zetGetMetricExpProcAddrTableLegacy(); } else { @@ -3489,15 +3911,29 @@ zetGetMetricGroupProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricGroup = new zet_metric_group_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGet = loader_driver_ddi::zetMetricGroupGet; + } else { pDdiTable->pfnGet = loader::zetMetricGroupGet; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetProperties = loader_driver_ddi::zetMetricGroupGetProperties; + } else { pDdiTable->pfnGetProperties = loader::zetMetricGroupGetProperties; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCalculateMetricValues = loader_driver_ddi::zetMetricGroupCalculateMetricValues; + } else { pDdiTable->pfnCalculateMetricValues = loader::zetMetricGroupCalculateMetricValues; } + } + zetGetMetricGroupProcAddrTableLegacy(); } else { @@ -3564,33 +4000,71 @@ zetGetMetricGroupExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricGroupExp = new zet_metric_group_exp_dditable_t; if (version >= ZE_API_VERSION_1_2) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCalculateMultipleMetricValuesExp = loader_driver_ddi::zetMetricGroupCalculateMultipleMetricValuesExp; + } else { pDdiTable->pfnCalculateMultipleMetricValuesExp = loader::zetMetricGroupCalculateMultipleMetricValuesExp; } + } if (version >= ZE_API_VERSION_1_5) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetGlobalTimestampsExp = loader_driver_ddi::zetMetricGroupGetGlobalTimestampsExp; + } else { pDdiTable->pfnGetGlobalTimestampsExp = loader::zetMetricGroupGetGlobalTimestampsExp; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetExportDataExp = loader_driver_ddi::zetMetricGroupGetExportDataExp; + } else { pDdiTable->pfnGetExportDataExp = loader::zetMetricGroupGetExportDataExp; } + } if (version >= ZE_API_VERSION_1_6) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCalculateMetricExportDataExp = loader_driver_ddi::zetMetricGroupCalculateMetricExportDataExp; + } else { pDdiTable->pfnCalculateMetricExportDataExp = loader::zetMetricGroupCalculateMetricExportDataExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreateExp = loader_driver_ddi::zetMetricGroupCreateExp; + } else { pDdiTable->pfnCreateExp = loader::zetMetricGroupCreateExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnAddMetricExp = loader_driver_ddi::zetMetricGroupAddMetricExp; + } else { pDdiTable->pfnAddMetricExp = loader::zetMetricGroupAddMetricExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnRemoveMetricExp = loader_driver_ddi::zetMetricGroupRemoveMetricExp; + } else { pDdiTable->pfnRemoveMetricExp = loader::zetMetricGroupRemoveMetricExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCloseExp = loader_driver_ddi::zetMetricGroupCloseExp; + } else { pDdiTable->pfnCloseExp = loader::zetMetricGroupCloseExp; } + } if (version >= ZE_API_VERSION_1_9) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroyExp = loader_driver_ddi::zetMetricGroupDestroyExp; + } else { pDdiTable->pfnDestroyExp = loader::zetMetricGroupDestroyExp; } + } + zetGetMetricGroupExpProcAddrTableLegacy(); } else { @@ -3667,18 +4141,36 @@ zetGetMetricQueryProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricQuery = new zet_metric_query_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zetMetricQueryCreate; + } else { pDdiTable->pfnCreate = loader::zetMetricQueryCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zetMetricQueryDestroy; + } else { pDdiTable->pfnDestroy = loader::zetMetricQueryDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReset = loader_driver_ddi::zetMetricQueryReset; + } else { pDdiTable->pfnReset = loader::zetMetricQueryReset; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnGetData = loader_driver_ddi::zetMetricQueryGetData; + } else { pDdiTable->pfnGetData = loader::zetMetricQueryGetData; } + } + zetGetMetricQueryProcAddrTableLegacy(); } else { @@ -3755,12 +4247,22 @@ zetGetMetricQueryPoolProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricQueryPool = new zet_metric_query_pool_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zetMetricQueryPoolCreate; + } else { pDdiTable->pfnCreate = loader::zetMetricQueryPoolCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zetMetricQueryPoolDestroy; + } else { pDdiTable->pfnDestroy = loader::zetMetricQueryPoolDestroy; } + } + zetGetMetricQueryPoolProcAddrTableLegacy(); } else { @@ -3837,15 +4339,29 @@ zetGetMetricStreamerProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->MetricStreamer = new zet_metric_streamer_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnOpen = loader_driver_ddi::zetMetricStreamerOpen; + } else { pDdiTable->pfnOpen = loader::zetMetricStreamerOpen; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnClose = loader_driver_ddi::zetMetricStreamerClose; + } else { pDdiTable->pfnClose = loader::zetMetricStreamerClose; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnReadData = loader_driver_ddi::zetMetricStreamerReadData; + } else { pDdiTable->pfnReadData = loader::zetMetricStreamerReadData; } + } + zetGetMetricStreamerProcAddrTableLegacy(); } else { @@ -3922,21 +4438,43 @@ zetGetTracerExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + loader::loaderDispatch->pTools->TracerExp = new zet_tracer_exp_dditable_t; if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnCreate = loader_driver_ddi::zetTracerExpCreate; + } else { pDdiTable->pfnCreate = loader::zetTracerExpCreate; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnDestroy = loader_driver_ddi::zetTracerExpDestroy; + } else { pDdiTable->pfnDestroy = loader::zetTracerExpDestroy; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetPrologues = loader_driver_ddi::zetTracerExpSetPrologues; + } else { pDdiTable->pfnSetPrologues = loader::zetTracerExpSetPrologues; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetEpilogues = loader_driver_ddi::zetTracerExpSetEpilogues; + } else { pDdiTable->pfnSetEpilogues = loader::zetTracerExpSetEpilogues; } + } if (version >= ZE_API_VERSION_1_0) { + if (loader::context->driverDDIPathDefault) { + pDdiTable->pfnSetEnabled = loader_driver_ddi::zetTracerExpSetEnabled; + } else { pDdiTable->pfnSetEnabled = loader::zetTracerExpSetEnabled; } + } + zetGetTracerExpProcAddrTableLegacy(); } else { @@ -3961,4 +4499,4 @@ zetGetTracerExpProcAddrTable( #if defined(__cplusplus) }; -#endif +#endif \ No newline at end of file diff --git a/source/loader/zet_ldrddi.h b/source/loader/zet_ldrddi.h index 548dfbc9..c65bc97f 100644 --- a/source/loader/zet_ldrddi.h +++ b/source/loader/zet_ldrddi.h @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -61,3 +61,720 @@ namespace loader using zet_metric_programmable_exp_factory_t = singleton_factory_t < zet_metric_programmable_exp_object_t, zet_metric_programmable_exp_handle_t >; } + +namespace loader_driver_ddi +{ + __zedlllocal void ZE_APICALL + zetDestroyDDiDriverTables(zet_dditable_driver_t* pDdiTable); + __zedlllocal ze_result_t ZE_APICALL + zetModuleGetDebugInfo( + zet_module_handle_t hModule, ///< [in] handle of the module + zet_module_debug_info_format_t format, ///< [in] debug info format requested + size_t* pSize, ///< [in,out] size of debug info in bytes + uint8_t* pDebugInfo ///< [in,out][optional] byte pointer to debug info + ); + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetDebugProperties( + zet_device_handle_t hDevice, ///< [in] device handle + zet_device_debug_properties_t* pDebugProperties ///< [in,out] query result for debug properties + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugAttach( + zet_device_handle_t hDevice, ///< [in] device handle + const zet_debug_config_t* config, ///< [in] the debug configuration + zet_debug_session_handle_t* phDebug ///< [out] debug session handle + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugDetach( + zet_debug_session_handle_t hDebug ///< [in][release] debug session handle + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadEvent( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + uint64_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the event; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + zet_debug_event_t* event ///< [in,out] a pointer to a ::zet_debug_event_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugAcknowledgeEvent( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + const zet_debug_event_t* event ///< [in] a pointer to a ::zet_debug_event_t. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugInterrupt( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread ///< [in] the thread to interrupt + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugResume( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread ///< [in] the thread to resume + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadMemory( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier. + const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor + size_t size, ///< [in] the number of bytes to read + void* buffer ///< [in,out] a buffer to hold a copy of the memory + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugWriteMemory( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier. + const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor + size_t size, ///< [in] the number of bytes to write + const void* buffer ///< [in] a buffer holding the pattern to write + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugGetRegisterSetProperties( + zet_device_handle_t hDevice, ///< [in] device handle + uint32_t* pCount, ///< [in,out] pointer to the number of register set properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of register set properties available. + ///< if count is greater than the number of register set properties + ///< available, then the driver shall update the value with the correct + ///< number of registry set properties available. + zet_debug_regset_properties_t* pRegisterSetProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< register set properties. + ///< if count is less than the number of register set properties available, + ///< then driver shall only retrieve that number of register set properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugGetThreadRegisterSetProperties( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier specifying a single stopped thread + uint32_t* pCount, ///< [in,out] pointer to the number of register set properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of register set properties available. + ///< if count is greater than the number of register set properties + ///< available, then the driver shall update the value with the correct + ///< number of registry set properties available. + zet_debug_regset_properties_t* pRegisterSetProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< register set properties. + ///< if count is less than the number of register set properties available, + ///< then driver shall only retrieve that number of register set properties. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadRegisters( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier + uint32_t type, ///< [in] register set type + uint32_t start, ///< [in] the starting offset into the register state area; must be less + ///< than the `count` member of ::zet_debug_regset_properties_t for the + ///< type + uint32_t count, ///< [in] the number of registers to read; start+count must be less than or + ///< equal to the `count` member of ::zet_debug_regset_properties_t for the + ///< type + void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values + ); + __zedlllocal ze_result_t ZE_APICALL + zetDebugWriteRegisters( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier + uint32_t type, ///< [in] register set type + uint32_t start, ///< [in] the starting offset into the register state area; must be less + ///< than the `count` member of ::zet_debug_regset_properties_t for the + ///< type + uint32_t count, ///< [in] the number of registers to write; start+count must be less than + ///< or equal to the `count` member of ::zet_debug_regset_properties_t for + ///< the type + void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGet( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of metric groups. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric groups available. + ///< if count is greater than the number of metric groups available, then + ///< the driver shall update the value with the correct number of metric + ///< groups available. + zet_metric_group_handle_t* phMetricGroups ///< [in,out][optional][range(0, *pCount)] array of handle of metric groups. + ///< if count is less than the number of metric groups available, then + ///< driver shall only retrieve that number of metric groups. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetProperties( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_properties_t* pProperties ///< [in,out] metric group properties + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMetricValues( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate + uint32_t* pMetricValueCount, ///< [in,out] pointer to number of metric values calculated. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pMetricValueCount)] buffer of calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGet( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + uint32_t* pCount, ///< [in,out] pointer to the number of metrics. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metrics available. + ///< if count is greater than the number of metrics available, then the + ///< driver shall update the value with the correct number of metrics available. + zet_metric_handle_t* phMetrics ///< [in,out][optional][range(0, *pCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metrics. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGetProperties( + zet_metric_handle_t hMetric, ///< [in] handle of the metric + zet_metric_properties_t* pProperties ///< [in,out] metric properties + ); + __zedlllocal ze_result_t ZE_APICALL + zetContextActivateMetricGroups( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t count, ///< [in] metric group count to activate; must be 0 if `nullptr == + ///< phMetricGroups` + zet_metric_group_handle_t* phMetricGroups ///< [in][optional][range(0, count)] handles of the metric groups to activate. + ///< nullptr deactivates all previously used metric groups. + ///< all metrics groups must come from a different domains. + ///< metric query and metric stream must use activated metric groups. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerOpen( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_streamer_desc_t* desc, ///< [in,out] metric streamer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification + zet_metric_streamer_handle_t* phMetricStreamer ///< [out] handle of metric streamer + ); + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricStreamerMarker( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer + uint32_t value ///< [in] streamer marker value + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerClose( + zet_metric_streamer_handle_t hMetricStreamer ///< [in][release] handle of the metric streamer + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerReadData( + zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer + uint32_t maxReportCount, ///< [in] the maximum number of reports the application wants to receive. + ///< if `UINT32_MAX`, then function will retrieve all reports available + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all reports available. + ///< if size is non-zero, then driver will only retrieve the number of + ///< reports that fit into the buffer. + ///< if size is larger than size needed for all reports, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing streamer + ///< reports in raw format + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryPoolCreate( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + zet_metric_group_handle_t hMetricGroup, ///< [in] metric group associated with the query object. + const zet_metric_query_pool_desc_t* desc, ///< [in] metric query pool descriptor + zet_metric_query_pool_handle_t* phMetricQueryPool ///< [out] handle of metric query pool + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryPoolDestroy( + zet_metric_query_pool_handle_t hMetricQueryPool ///< [in][release] handle of the metric query pool + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryCreate( + zet_metric_query_pool_handle_t hMetricQueryPool,///< [in] handle of the metric query pool + uint32_t index, ///< [in] index of the query within the pool + zet_metric_query_handle_t* phMetricQuery ///< [out] handle of metric query + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryDestroy( + zet_metric_query_handle_t hMetricQuery ///< [in][release] handle of metric query + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryReset( + zet_metric_query_handle_t hMetricQuery ///< [in] handle of metric query + ); + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricQueryBegin( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_query_handle_t hMetricQuery ///< [in] handle of the metric query + ); + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricQueryEnd( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in] must be zero + ze_event_handle_t* phWaitEvents ///< [in][mbz] must be nullptr + ); + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricMemoryBarrier( + zet_command_list_handle_t hCommandList ///< [in] handle of the command list + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryGetData( + zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all reports available. + ///< if size is non-zero, then driver will only retrieve the number of + ///< reports that fit into the buffer. + ///< if size is larger than size needed for all reports, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing query + ///< reports in raw format + ); + __zedlllocal ze_result_t ZE_APICALL + zetKernelGetProfileInfo( + zet_kernel_handle_t hKernel, ///< [in] handle to kernel + zet_profile_properties_t* pProfileProperties ///< [out] pointer to profile properties + ); + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpCreate( + zet_context_handle_t hContext, ///< [in] handle of the context object + const zet_tracer_exp_desc_t* desc, ///< [in] pointer to tracer descriptor + zet_tracer_exp_handle_t* phTracer ///< [out] pointer to handle of tracer object created + ); + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpDestroy( + zet_tracer_exp_handle_t hTracer ///< [in][release] handle of tracer object to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetPrologues( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers + ); + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetEpilogues( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers + ); + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetEnabled( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + ze_bool_t enable ///< [in] enable the tracer if true; disable if false + ); + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetricsExp() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ); + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMarkerExp( + zet_command_list_handle_t hCommandList, ///< [in] handle to the command list + zet_metric_group_handle_t hMetricGroup, ///< [in] handle to the marker metric group. + ///< ::zet_metric_group_type_exp_flags_t could be used to check whether + ///< marker is supoported by the metric group. + uint32_t value ///< [in] marker value + ); + __zedlllocal ze_result_t ZE_APICALL + zetDeviceEnableMetricsExp( + zet_device_handle_t hDevice ///< [in] handle of the device where metrics collection has to be enabled. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDeviceDisableMetricsExp( + zet_device_handle_t hDevice ///< [in] handle of the device where metrics collection has to be disabled + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMultipleMetricValuesExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric sets to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric sets to be calculated. + uint32_t* pTotalMetricValueCount, ///< [in,out] pointer to number of the total number of metric values + ///< calculated, for all metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + uint32_t* pMetricCounts, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric counts per + ///< metric set. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pTotalMetricValueCount)] buffer of + ///< calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetExportDataExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + const uint8_t* pRawData, ///< [in] buffer of raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + size_t* pExportDataSize, ///< [in,out] size in bytes of export data buffer + ///< if size is zero, then the driver shall update the value with the + ///< number of bytes necessary to store the exported data. + ///< if size is greater than required, then the driver shall update the + ///< value with the actual number of bytes necessary to store the exported data. + uint8_t * pExportData ///< [in,out][optional][range(0, *pExportDataSize)] buffer of exported data. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMetricExportDataExp( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t exportDataSize, ///< [in] size in bytes of exported data buffer + const uint8_t* pExportData, ///< [in][range(0, exportDataSize)] buffer of exported data to calculate + zet_metric_calculate_exp_desc_t* pCalculateDescriptor, ///< [in] descriptor specifying calculation specific parameters + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric sets to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric sets to be calculated. + uint32_t* pTotalMetricValueCount, ///< [in,out] pointer to number of the total number of metric values + ///< calculated, for all metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + uint32_t* pMetricCounts, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric counts per + ///< metric set. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pTotalMetricValueCount)] buffer of + ///< calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of metric programmable handles. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric programmable handles available. + ///< if count is greater than the number of metric programmable handles + ///< available, then the driver shall update the value with the correct + ///< number of metric programmable handles available. + zet_metric_programmable_exp_handle_t* phMetricProgrammables ///< [in,out][optional][range(0, *pCount)] array of handle of metric programmables. + ///< if count is less than the number of metric programmables available, + ///< then driver shall only retrieve that number of metric programmables. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetPropertiesExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + zet_metric_programmable_exp_properties_t* pProperties ///< [in,out] properties of the metric programmable + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetParamInfoExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t* pParameterCount, ///< [in,out] count of the parameters to retrieve parameter info. + ///< if value pParameterCount is greater than count of parameters + ///< available, then pParameterCount will be updated with count of + ///< parameters available. + ///< The count of parameters available can be queried using ::zetMetricProgrammableGetPropertiesExp. + zet_metric_programmable_param_info_exp_t* pParameterInfo///< [in,out][range(1, *pParameterCount)] array of parameter info. + ///< if parameterCount is less than the number of parameters available, + ///< then driver shall only retrieve that number of parameter info. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetParamValueInfoExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterOrdinal, ///< [in] ordinal of the parameter in the metric programmable + uint32_t* pValueInfoCount, ///< [in,out] count of parameter value information to retrieve. + ///< if value at pValueInfoCount is greater than count of value info + ///< available, then pValueInfoCount will be updated with count of value + ///< info available. + ///< The count of parameter value info available can be queried using ::zetMetricProgrammableGetParamInfoExp. + zet_metric_programmable_param_value_info_exp_t* pValueInfo ///< [in,out][range(1, *pValueInfoCount)] array of parameter value info. + ///< if pValueInfoCount is less than the number of value info available, + ///< then driver shall only retrieve that number of value info. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + uint32_t parameterCount, ///< [in] Count of parameters to set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_NAME_PREFIX_EXP. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCreateExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + const char* pName, ///< [in] pointer to metric group name. Must point to a null-terminated + ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. + const char* pDescription, ///< [in] pointer to metric group description. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. + zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupAddMetricExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] Handle of the metric group + zet_metric_handle_t hMetric, ///< [in] Metric to be added to the group. + size_t * pErrorStringSize, ///< [in,out][optional] Size of the error string to query, if an error was + ///< reported during adding the metric handle. + ///< if *pErrorStringSize is zero, then the driver shall update the value + ///< with the size of the error string in bytes. + char* pErrorString ///< [in,out][optional][range(0, *pErrorStringSize)] Error string. + ///< if *pErrorStringSize is less than the length of the error string + ///< available, then driver shall only retrieve that length of error string. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupRemoveMetricExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] Handle of the metric group + zet_metric_handle_t hMetric ///< [in] Metric handle to be removed from the metric group. + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCloseExp( + zet_metric_group_handle_t hMetricGroup ///< [in] Handle of the metric group + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupDestroyExp( + zet_metric_group_handle_t hMetricGroup ///< [in] Handle of the metric group to destroy + ); + __zedlllocal ze_result_t ZE_APICALL + zetMetricDestroyExp( + zet_metric_handle_t hMetric ///< [in] Handle of the metric to destroy + ); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +__zedlllocal void ZE_APICALL +zetGetMetricDecoderExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricProgrammableExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricTracerExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetDeviceProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetDeviceExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetContextProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetCommandListProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetCommandListExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetKernelProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetModuleProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetDebugProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricGroupProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricGroupExpProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricQueryProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricQueryPoolProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetMetricStreamerProcAddrTableLegacy(); +__zedlllocal void ZE_APICALL +zetGetTracerExpProcAddrTableLegacy(); + +#if defined(__cplusplus) +}; +#endif diff --git a/source/loader/zet_ldrddi_driver_ddi.cpp b/source/loader/zet_ldrddi_driver_ddi.cpp new file mode 100644 index 00000000..65c57b78 --- /dev/null +++ b/source/loader/zet_ldrddi_driver_ddi.cpp @@ -0,0 +1,2156 @@ +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file zet_ldrddi_driver_ddi.cpp + * + */ +#include "ze_loader_internal.h" + +namespace loader_driver_ddi +{ + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetModuleGetDebugInfo + __zedlllocal ze_result_t ZE_APICALL + zetModuleGetDebugInfo( + zet_module_handle_t hModule, ///< [in] handle of the module + zet_module_debug_info_format_t format, ///< [in] debug info format requested + size_t* pSize, ///< [in,out] size of debug info in bytes + uint8_t* pDebugInfo ///< [in,out][optional] byte pointer to debug info + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hModule )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDebugInfo = dditable->Module->pfnGetDebugInfo; + if( nullptr == pfnGetDebugInfo ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDebugInfo( hModule, format, pSize, pDebugInfo ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceGetDebugProperties + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetDebugProperties( + zet_device_handle_t hDevice, ///< [in] device handle + zet_device_debug_properties_t* pDebugProperties ///< [in,out] query result for debug properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDebugProperties = dditable->Device->pfnGetDebugProperties; + if( nullptr == pfnGetDebugProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDebugProperties( hDevice, pDebugProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugAttach + __zedlllocal ze_result_t ZE_APICALL + zetDebugAttach( + zet_device_handle_t hDevice, ///< [in] device handle + const zet_debug_config_t* config, ///< [in] the debug configuration + zet_debug_session_handle_t* phDebug ///< [out] debug session handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAttach = dditable->Debug->pfnAttach; + if( nullptr == pfnAttach ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAttach( hDevice, config, phDebug ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugDetach + __zedlllocal ze_result_t ZE_APICALL + zetDebugDetach( + zet_debug_session_handle_t hDebug ///< [in][release] debug session handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDetach = dditable->Debug->pfnDetach; + if( nullptr == pfnDetach ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDetach( hDebug ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugReadEvent + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadEvent( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + uint64_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the event; + ///< if `UINT64_MAX`, then function will not return until complete or + ///< device is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + zet_debug_event_t* event ///< [in,out] a pointer to a ::zet_debug_event_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadEvent = dditable->Debug->pfnReadEvent; + if( nullptr == pfnReadEvent ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadEvent( hDebug, timeout, event ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugAcknowledgeEvent + __zedlllocal ze_result_t ZE_APICALL + zetDebugAcknowledgeEvent( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + const zet_debug_event_t* event ///< [in] a pointer to a ::zet_debug_event_t. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAcknowledgeEvent = dditable->Debug->pfnAcknowledgeEvent; + if( nullptr == pfnAcknowledgeEvent ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAcknowledgeEvent( hDebug, event ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugInterrupt + __zedlllocal ze_result_t ZE_APICALL + zetDebugInterrupt( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread ///< [in] the thread to interrupt + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnInterrupt = dditable->Debug->pfnInterrupt; + if( nullptr == pfnInterrupt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnInterrupt( hDebug, thread ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugResume + __zedlllocal ze_result_t ZE_APICALL + zetDebugResume( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread ///< [in] the thread to resume + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnResume = dditable->Debug->pfnResume; + if( nullptr == pfnResume ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnResume( hDebug, thread ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugReadMemory + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadMemory( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier. + const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor + size_t size, ///< [in] the number of bytes to read + void* buffer ///< [in,out] a buffer to hold a copy of the memory + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadMemory = dditable->Debug->pfnReadMemory; + if( nullptr == pfnReadMemory ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadMemory( hDebug, thread, desc, size, buffer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugWriteMemory + __zedlllocal ze_result_t ZE_APICALL + zetDebugWriteMemory( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier. + const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor + size_t size, ///< [in] the number of bytes to write + const void* buffer ///< [in] a buffer holding the pattern to write + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnWriteMemory = dditable->Debug->pfnWriteMemory; + if( nullptr == pfnWriteMemory ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnWriteMemory( hDebug, thread, desc, size, buffer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugGetRegisterSetProperties + __zedlllocal ze_result_t ZE_APICALL + zetDebugGetRegisterSetProperties( + zet_device_handle_t hDevice, ///< [in] device handle + uint32_t* pCount, ///< [in,out] pointer to the number of register set properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of register set properties available. + ///< if count is greater than the number of register set properties + ///< available, then the driver shall update the value with the correct + ///< number of registry set properties available. + zet_debug_regset_properties_t* pRegisterSetProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< register set properties. + ///< if count is less than the number of register set properties available, + ///< then driver shall only retrieve that number of register set properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetRegisterSetProperties = dditable->Debug->pfnGetRegisterSetProperties; + if( nullptr == pfnGetRegisterSetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetRegisterSetProperties( hDevice, pCount, pRegisterSetProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugGetThreadRegisterSetProperties + __zedlllocal ze_result_t ZE_APICALL + zetDebugGetThreadRegisterSetProperties( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier specifying a single stopped thread + uint32_t* pCount, ///< [in,out] pointer to the number of register set properties. + ///< if count is zero, then the driver shall update the value with the + ///< total number of register set properties available. + ///< if count is greater than the number of register set properties + ///< available, then the driver shall update the value with the correct + ///< number of registry set properties available. + zet_debug_regset_properties_t* pRegisterSetProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< register set properties. + ///< if count is less than the number of register set properties available, + ///< then driver shall only retrieve that number of register set properties. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetThreadRegisterSetProperties = dditable->Debug->pfnGetThreadRegisterSetProperties; + if( nullptr == pfnGetThreadRegisterSetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetThreadRegisterSetProperties( hDebug, thread, pCount, pRegisterSetProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugReadRegisters + __zedlllocal ze_result_t ZE_APICALL + zetDebugReadRegisters( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier + uint32_t type, ///< [in] register set type + uint32_t start, ///< [in] the starting offset into the register state area; must be less + ///< than the `count` member of ::zet_debug_regset_properties_t for the + ///< type + uint32_t count, ///< [in] the number of registers to read; start+count must be less than or + ///< equal to the `count` member of ::zet_debug_regset_properties_t for the + ///< type + void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadRegisters = dditable->Debug->pfnReadRegisters; + if( nullptr == pfnReadRegisters ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadRegisters( hDebug, thread, type, start, count, pRegisterValues ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDebugWriteRegisters + __zedlllocal ze_result_t ZE_APICALL + zetDebugWriteRegisters( + zet_debug_session_handle_t hDebug, ///< [in] debug session handle + ze_device_thread_t thread, ///< [in] the thread identifier + uint32_t type, ///< [in] register set type + uint32_t start, ///< [in] the starting offset into the register state area; must be less + ///< than the `count` member of ::zet_debug_regset_properties_t for the + ///< type + uint32_t count, ///< [in] the number of registers to write; start+count must be less than + ///< or equal to the `count` member of ::zet_debug_regset_properties_t for + ///< the type + void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDebug )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnWriteRegisters = dditable->Debug->pfnWriteRegisters; + if( nullptr == pfnWriteRegisters ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnWriteRegisters( hDebug, thread, type, start, count, pRegisterValues ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGet + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGet( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of metric groups. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric groups available. + ///< if count is greater than the number of metric groups available, then + ///< the driver shall update the value with the correct number of metric + ///< groups available. + zet_metric_group_handle_t* phMetricGroups ///< [in,out][optional][range(0, *pCount)] array of handle of metric groups. + ///< if count is less than the number of metric groups available, then + ///< driver shall only retrieve that number of metric groups. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGet = dditable->MetricGroup->pfnGet; + if( nullptr == pfnGet ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGet( hDevice, pCount, phMetricGroups ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetProperties + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetProperties( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_properties_t* pProperties ///< [in,out] metric group properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->MetricGroup->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hMetricGroup, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupCalculateMetricValues + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMetricValues( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate + uint32_t* pMetricValueCount, ///< [in,out] pointer to number of metric values calculated. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pMetricValueCount)] buffer of calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCalculateMetricValues = dditable->MetricGroup->pfnCalculateMetricValues; + if( nullptr == pfnCalculateMetricValues ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCalculateMetricValues( hMetricGroup, type, rawDataSize, pRawData, pMetricValueCount, pMetricValues ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGet + __zedlllocal ze_result_t ZE_APICALL + zetMetricGet( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + uint32_t* pCount, ///< [in,out] pointer to the number of metrics. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metrics available. + ///< if count is greater than the number of metrics available, then the + ///< driver shall update the value with the correct number of metrics available. + zet_metric_handle_t* phMetrics ///< [in,out][optional][range(0, *pCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metrics. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGet = dditable->Metric->pfnGet; + if( nullptr == pfnGet ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGet( hMetricGroup, pCount, phMetrics ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGetProperties + __zedlllocal ze_result_t ZE_APICALL + zetMetricGetProperties( + zet_metric_handle_t hMetric, ///< [in] handle of the metric + zet_metric_properties_t* pProperties ///< [in,out] metric properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetric )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProperties = dditable->Metric->pfnGetProperties; + if( nullptr == pfnGetProperties ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProperties( hMetric, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetContextActivateMetricGroups + __zedlllocal ze_result_t ZE_APICALL + zetContextActivateMetricGroups( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t count, ///< [in] metric group count to activate; must be 0 if `nullptr == + ///< phMetricGroups` + zet_metric_group_handle_t* phMetricGroups ///< [in][optional][range(0, count)] handles of the metric groups to activate. + ///< nullptr deactivates all previously used metric groups. + ///< all metrics groups must come from a different domains. + ///< metric query and metric stream must use activated metric groups. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnActivateMetricGroups = dditable->Context->pfnActivateMetricGroups; + if( nullptr == pfnActivateMetricGroups ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnActivateMetricGroups( hContext, hDevice, count, phMetricGroups ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricStreamerOpen + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerOpen( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_streamer_desc_t* desc, ///< [in,out] metric streamer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification + zet_metric_streamer_handle_t* phMetricStreamer ///< [out] handle of metric streamer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnOpen = dditable->MetricStreamer->pfnOpen; + if( nullptr == pfnOpen ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnOpen( hContext, hDevice, hMetricGroup, desc, hNotificationEvent, phMetricStreamer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetCommandListAppendMetricStreamerMarker + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricStreamerMarker( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer + uint32_t value ///< [in] streamer marker value + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMetricStreamerMarker = dditable->CommandList->pfnAppendMetricStreamerMarker; + if( nullptr == pfnAppendMetricStreamerMarker ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMetricStreamerMarker( hCommandList, hMetricStreamer, value ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricStreamerClose + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerClose( + zet_metric_streamer_handle_t hMetricStreamer ///< [in][release] handle of the metric streamer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricStreamer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnClose = dditable->MetricStreamer->pfnClose; + if( nullptr == pfnClose ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnClose( hMetricStreamer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricStreamerReadData + __zedlllocal ze_result_t ZE_APICALL + zetMetricStreamerReadData( + zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer + uint32_t maxReportCount, ///< [in] the maximum number of reports the application wants to receive. + ///< if `UINT32_MAX`, then function will retrieve all reports available + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all reports available. + ///< if size is non-zero, then driver will only retrieve the number of + ///< reports that fit into the buffer. + ///< if size is larger than size needed for all reports, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing streamer + ///< reports in raw format + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricStreamer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadData = dditable->MetricStreamer->pfnReadData; + if( nullptr == pfnReadData ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadData( hMetricStreamer, maxReportCount, pRawDataSize, pRawData ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryPoolCreate + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryPoolCreate( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + zet_metric_group_handle_t hMetricGroup, ///< [in] metric group associated with the query object. + const zet_metric_query_pool_desc_t* desc, ///< [in] metric query pool descriptor + zet_metric_query_pool_handle_t* phMetricQueryPool ///< [out] handle of metric query pool + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->MetricQueryPool->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, hDevice, hMetricGroup, desc, phMetricQueryPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryPoolDestroy + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryPoolDestroy( + zet_metric_query_pool_handle_t hMetricQueryPool ///< [in][release] handle of the metric query pool + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricQueryPool )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->MetricQueryPool->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hMetricQueryPool ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryCreate + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryCreate( + zet_metric_query_pool_handle_t hMetricQueryPool,///< [in] handle of the metric query pool + uint32_t index, ///< [in] index of the query within the pool + zet_metric_query_handle_t* phMetricQuery ///< [out] handle of metric query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricQueryPool )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->MetricQuery->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hMetricQueryPool, index, phMetricQuery ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryDestroy + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryDestroy( + zet_metric_query_handle_t hMetricQuery ///< [in][release] handle of metric query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricQuery )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->MetricQuery->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hMetricQuery ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryReset + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryReset( + zet_metric_query_handle_t hMetricQuery ///< [in] handle of metric query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricQuery )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReset = dditable->MetricQuery->pfnReset; + if( nullptr == pfnReset ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReset( hMetricQuery ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetCommandListAppendMetricQueryBegin + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricQueryBegin( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_query_handle_t hMetricQuery ///< [in] handle of the metric query + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMetricQueryBegin = dditable->CommandList->pfnAppendMetricQueryBegin; + if( nullptr == pfnAppendMetricQueryBegin ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMetricQueryBegin( hCommandList, hMetricQuery ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetCommandListAppendMetricQueryEnd + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricQueryEnd( + zet_command_list_handle_t hCommandList, ///< [in] handle of the command list + zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in] must be zero + ze_event_handle_t* phWaitEvents ///< [in][mbz] must be nullptr + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMetricQueryEnd = dditable->CommandList->pfnAppendMetricQueryEnd; + if( nullptr == pfnAppendMetricQueryEnd ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMetricQueryEnd( hCommandList, hMetricQuery, hSignalEvent, numWaitEvents, phWaitEvents ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetCommandListAppendMetricMemoryBarrier + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMetricMemoryBarrier( + zet_command_list_handle_t hCommandList ///< [in] handle of the command list + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMetricMemoryBarrier = dditable->CommandList->pfnAppendMetricMemoryBarrier; + if( nullptr == pfnAppendMetricMemoryBarrier ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMetricMemoryBarrier( hCommandList ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricQueryGetData + __zedlllocal ze_result_t ZE_APICALL + zetMetricQueryGetData( + zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all reports available. + ///< if size is non-zero, then driver will only retrieve the number of + ///< reports that fit into the buffer. + ///< if size is larger than size needed for all reports, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing query + ///< reports in raw format + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricQuery )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetData = dditable->MetricQuery->pfnGetData; + if( nullptr == pfnGetData ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetData( hMetricQuery, pRawDataSize, pRawData ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetKernelGetProfileInfo + __zedlllocal ze_result_t ZE_APICALL + zetKernelGetProfileInfo( + zet_kernel_handle_t hKernel, ///< [in] handle to kernel + zet_profile_properties_t* pProfileProperties ///< [out] pointer to profile properties + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hKernel )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetProfileInfo = dditable->Kernel->pfnGetProfileInfo; + if( nullptr == pfnGetProfileInfo ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetProfileInfo( hKernel, pProfileProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetTracerExpCreate + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpCreate( + zet_context_handle_t hContext, ///< [in] handle of the context object + const zet_tracer_exp_desc_t* desc, ///< [in] pointer to tracer descriptor + zet_tracer_exp_handle_t* phTracer ///< [out] pointer to handle of tracer object created + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreate = dditable->TracerExp->pfnCreate; + if( nullptr == pfnCreate ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreate( hContext, desc, phTracer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetTracerExpDestroy + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpDestroy( + zet_tracer_exp_handle_t hTracer ///< [in][release] handle of tracer object to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroy = dditable->TracerExp->pfnDestroy; + if( nullptr == pfnDestroy ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroy( hTracer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetTracerExpSetPrologues + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetPrologues( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetPrologues = dditable->TracerExp->pfnSetPrologues; + if( nullptr == pfnSetPrologues ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetPrologues( hTracer, pCoreCbs ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetTracerExpSetEpilogues + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetEpilogues( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetEpilogues = dditable->TracerExp->pfnSetEpilogues; + if( nullptr == pfnSetEpilogues ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetEpilogues( hTracer, pCoreCbs ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetTracerExpSetEnabled + __zedlllocal ze_result_t ZE_APICALL + zetTracerExpSetEnabled( + zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer + ze_bool_t enable ///< [in] enable the tracer if true; disable if false + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_0) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnSetEnabled = dditable->TracerExp->pfnSetEnabled; + if( nullptr == pfnSetEnabled ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnSetEnabled( hTracer, enable ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceGetConcurrentMetricGroupsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetConcurrentMetricGroupsExp = dditable->DeviceExp->pfnGetConcurrentMetricGroupsExp; + if( nullptr == pfnGetConcurrentMetricGroupsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetConcurrentMetricGroupsExp( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hContext )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExp = dditable->MetricTracerExp->pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExp( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->MetricTracerExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( hMetricTracer ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerEnableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnableExp = dditable->MetricTracerExp->pfnEnableExp; + if( nullptr == pfnEnableExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnableExp( hMetricTracer, synchronous ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDisableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDisableExp = dditable->MetricTracerExp->pfnDisableExp; + if( nullptr == pfnDisableExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDisableExp( hMetricTracer, synchronous ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerReadDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnReadDataExp = dditable->MetricTracerExp->pfnReadDataExp; + if( nullptr == pfnReadDataExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnReadDataExp( hMetricTracer, pRawDataSize, pRawData ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExp = dditable->MetricDecoderExp->pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExp( hMetricTracer, phMetricDecoder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( phMetricDecoder )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->MetricDecoderExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( phMetricDecoder ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderGetDecodableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricDecoder )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetDecodableMetricsExp = dditable->MetricDecoderExp->pfnGetDecodableMetricsExp; + if( nullptr == pfnGetDecodableMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetDecodableMetricsExp( hMetricDecoder, pCount, phMetrics ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDecodeExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetricsExp() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( phMetricDecoder )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDecodeExp = dditable->MetricTracerExp->pfnDecodeExp; + if( nullptr == pfnDecodeExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDecodeExp( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetCommandListAppendMarkerExp + __zedlllocal ze_result_t ZE_APICALL + zetCommandListAppendMarkerExp( + zet_command_list_handle_t hCommandList, ///< [in] handle to the command list + zet_metric_group_handle_t hMetricGroup, ///< [in] handle to the marker metric group. + ///< ::zet_metric_group_type_exp_flags_t could be used to check whether + ///< marker is supoported by the metric group. + uint32_t value ///< [in] marker value + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hCommandList )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAppendMarkerExp = dditable->CommandListExp->pfnAppendMarkerExp; + if( nullptr == pfnAppendMarkerExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAppendMarkerExp( hCommandList, hMetricGroup, value ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceEnableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceEnableMetricsExp( + zet_device_handle_t hDevice ///< [in] handle of the device where metrics collection has to be enabled. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnEnableMetricsExp = dditable->DeviceExp->pfnEnableMetricsExp; + if( nullptr == pfnEnableMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnEnableMetricsExp( hDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceDisableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceDisableMetricsExp( + zet_device_handle_t hDevice ///< [in] handle of the device where metrics collection has to be disabled + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_13) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDisableMetricsExp = dditable->DeviceExp->pfnDisableMetricsExp; + if( nullptr == pfnDisableMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDisableMetricsExp( hDevice ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupCalculateMultipleMetricValuesExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMultipleMetricValuesExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric sets to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric sets to be calculated. + uint32_t* pTotalMetricValueCount, ///< [in,out] pointer to number of the total number of metric values + ///< calculated, for all metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + uint32_t* pMetricCounts, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric counts per + ///< metric set. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pTotalMetricValueCount)] buffer of + ///< calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_2) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCalculateMultipleMetricValuesExp = dditable->MetricGroupExp->pfnCalculateMultipleMetricValuesExp; + if( nullptr == pfnCalculateMultipleMetricValuesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCalculateMultipleMetricValuesExp( hMetricGroup, type, rawDataSize, pRawData, pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetGlobalTimestampsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_5) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetGlobalTimestampsExp = dditable->MetricGroupExp->pfnGetGlobalTimestampsExp; + if( nullptr == pfnGetGlobalTimestampsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetExportDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetExportDataExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + const uint8_t* pRawData, ///< [in] buffer of raw data + size_t rawDataSize, ///< [in] size in bytes of raw data buffer + size_t* pExportDataSize, ///< [in,out] size in bytes of export data buffer + ///< if size is zero, then the driver shall update the value with the + ///< number of bytes necessary to store the exported data. + ///< if size is greater than required, then the driver shall update the + ///< value with the actual number of bytes necessary to store the exported data. + uint8_t * pExportData ///< [in,out][optional][range(0, *pExportDataSize)] buffer of exported data. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExportDataExp = dditable->MetricGroupExp->pfnGetExportDataExp; + if( nullptr == pfnGetExportDataExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExportDataExp( hMetricGroup, pRawData, rawDataSize, pExportDataSize, pExportData ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupCalculateMetricExportDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCalculateMetricExportDataExp( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data + size_t exportDataSize, ///< [in] size in bytes of exported data buffer + const uint8_t* pExportData, ///< [in][range(0, exportDataSize)] buffer of exported data to calculate + zet_metric_calculate_exp_desc_t* pCalculateDescriptor, ///< [in] descriptor specifying calculation specific parameters + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric sets to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric sets to be calculated. + uint32_t* pTotalMetricValueCount, ///< [in,out] pointer to number of the total number of metric values + ///< calculated, for all metric sets. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric values to be calculated. + ///< if count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with the actual number of + ///< metric values to be calculated. + uint32_t* pMetricCounts, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric counts per + ///< metric set. + zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pTotalMetricValueCount)] buffer of + ///< calculated metrics. + ///< if count is less than the number available in the raw data buffer, + ///< then driver shall only calculate that number of metric values. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDriver )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_6) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCalculateMetricExportDataExp = dditable->MetricGroupExp->pfnCalculateMetricExportDataExp; + if( nullptr == pfnCalculateMetricExportDataExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCalculateMetricExportDataExp( hDriver, type, exportDataSize, pExportData, pCalculateDescriptor, pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricProgrammableGetExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t* pCount, ///< [in,out] pointer to the number of metric programmable handles. + ///< if count is zero, then the driver shall update the value with the + ///< total number of metric programmable handles available. + ///< if count is greater than the number of metric programmable handles + ///< available, then the driver shall update the value with the correct + ///< number of metric programmable handles available. + zet_metric_programmable_exp_handle_t* phMetricProgrammables ///< [in,out][optional][range(0, *pCount)] array of handle of metric programmables. + ///< if count is less than the number of metric programmables available, + ///< then driver shall only retrieve that number of metric programmables. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetExp = dditable->MetricProgrammableExp->pfnGetExp; + if( nullptr == pfnGetExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetExp( hDevice, pCount, phMetricProgrammables ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricProgrammableGetPropertiesExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetPropertiesExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + zet_metric_programmable_exp_properties_t* pProperties ///< [in,out] properties of the metric programmable + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetPropertiesExp = dditable->MetricProgrammableExp->pfnGetPropertiesExp; + if( nullptr == pfnGetPropertiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetPropertiesExp( hMetricProgrammable, pProperties ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricProgrammableGetParamInfoExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetParamInfoExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t* pParameterCount, ///< [in,out] count of the parameters to retrieve parameter info. + ///< if value pParameterCount is greater than count of parameters + ///< available, then pParameterCount will be updated with count of + ///< parameters available. + ///< The count of parameters available can be queried using ::zetMetricProgrammableGetPropertiesExp. + zet_metric_programmable_param_info_exp_t* pParameterInfo///< [in,out][range(1, *pParameterCount)] array of parameter info. + ///< if parameterCount is less than the number of parameters available, + ///< then driver shall only retrieve that number of parameter info. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetParamInfoExp = dditable->MetricProgrammableExp->pfnGetParamInfoExp; + if( nullptr == pfnGetParamInfoExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetParamInfoExp( hMetricProgrammable, pParameterCount, pParameterInfo ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricProgrammableGetParamValueInfoExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricProgrammableGetParamValueInfoExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterOrdinal, ///< [in] ordinal of the parameter in the metric programmable + uint32_t* pValueInfoCount, ///< [in,out] count of parameter value information to retrieve. + ///< if value at pValueInfoCount is greater than count of value info + ///< available, then pValueInfoCount will be updated with count of value + ///< info available. + ///< The count of parameter value info available can be queried using ::zetMetricProgrammableGetParamInfoExp. + zet_metric_programmable_param_value_info_exp_t* pValueInfo ///< [in,out][range(1, *pValueInfoCount)] array of parameter value info. + ///< if pValueInfoCount is less than the number of value info available, + ///< then driver shall only retrieve that number of value info. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnGetParamValueInfoExp = dditable->MetricProgrammableExp->pfnGetParamValueInfoExp; + if( nullptr == pfnGetParamValueInfoExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnGetParamValueInfoExp( hMetricProgrammable, parameterOrdinal, pValueInfoCount, pValueInfo ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricCreateFromProgrammableExp2 + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_11) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateFromProgrammableExp2 = dditable->MetricExp->pfnCreateFromProgrammableExp2; + if( nullptr == pfnCreateFromProgrammableExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateFromProgrammableExp2( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricCreateFromProgrammableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + uint32_t parameterCount, ///< [in] Count of parameters to set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateFromProgrammableExp = dditable->MetricExp->pfnCreateFromProgrammableExp; + if( nullptr == pfnCreateFromProgrammableExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_NAME_PREFIX_EXP. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_10) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateMetricGroupsFromMetricsExp = dditable->DeviceExp->pfnCreateMetricGroupsFromMetricsExp; + if( nullptr == pfnCreateMetricGroupsFromMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCreateExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + const char* pName, ///< [in] pointer to metric group name. Must point to a null-terminated + ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. + const char* pDescription, ///< [in] pointer to metric group description. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. + zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hDevice )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCreateExp = dditable->MetricGroupExp->pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCreateExp( hDevice, pName, pDescription, samplingType, phMetricGroup ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupAddMetricExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupAddMetricExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] Handle of the metric group + zet_metric_handle_t hMetric, ///< [in] Metric to be added to the group. + size_t * pErrorStringSize, ///< [in,out][optional] Size of the error string to query, if an error was + ///< reported during adding the metric handle. + ///< if *pErrorStringSize is zero, then the driver shall update the value + ///< with the size of the error string in bytes. + char* pErrorString ///< [in,out][optional][range(0, *pErrorStringSize)] Error string. + ///< if *pErrorStringSize is less than the length of the error string + ///< available, then driver shall only retrieve that length of error string. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnAddMetricExp = dditable->MetricGroupExp->pfnAddMetricExp; + if( nullptr == pfnAddMetricExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnAddMetricExp( hMetricGroup, hMetric, pErrorStringSize, pErrorString ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupRemoveMetricExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupRemoveMetricExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] Handle of the metric group + zet_metric_handle_t hMetric ///< [in] Metric handle to be removed from the metric group. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnRemoveMetricExp = dditable->MetricGroupExp->pfnRemoveMetricExp; + if( nullptr == pfnRemoveMetricExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnRemoveMetricExp( hMetricGroup, hMetric ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupCloseExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupCloseExp( + zet_metric_group_handle_t hMetricGroup ///< [in] Handle of the metric group + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnCloseExp = dditable->MetricGroupExp->pfnCloseExp; + if( nullptr == pfnCloseExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnCloseExp( hMetricGroup ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupDestroyExp( + zet_metric_group_handle_t hMetricGroup ///< [in] Handle of the metric group to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->MetricGroupExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( hMetricGroup ); + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDestroyExp( + zet_metric_handle_t hMetric ///< [in] Handle of the metric to destroy + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract handle's function pointer table + auto dditable = reinterpret_cast( hMetric )->pTools; + if (dditable->isValidFlag == 0) + return ZE_RESULT_ERROR_UNINITIALIZED; + // Check that api version in the driver is supported by this version of the API + if (dditable->version < ZE_API_VERSION_1_9) { + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + } + auto pfnDestroyExp = dditable->MetricExp->pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + // forward to device-driver + result = pfnDestroyExp( hMetric ); + return result; + } + + + /////////////////////////////////////////////////////////////////////////////// + /// @brief function for removing the ddi driver tables for zet + __zedlllocal void ZE_APICALL + zetDestroyDDiDriverTables(zet_dditable_driver_t* pDdiTable) + { + // Delete ddi tables + delete pDdiTable->MetricDecoderExp; + delete pDdiTable->MetricProgrammableExp; + delete pDdiTable->MetricTracerExp; + delete pDdiTable->Device; + delete pDdiTable->DeviceExp; + delete pDdiTable->Context; + delete pDdiTable->CommandList; + delete pDdiTable->CommandListExp; + delete pDdiTable->Kernel; + delete pDdiTable->Module; + delete pDdiTable->Debug; + delete pDdiTable->Metric; + delete pDdiTable->MetricExp; + delete pDdiTable->MetricGroup; + delete pDdiTable->MetricGroupExp; + delete pDdiTable->MetricQuery; + delete pDdiTable->MetricQueryPool; + delete pDdiTable->MetricStreamer; + delete pDdiTable->TracerExp; + delete pDdiTable; + } + +} // namespace loader_driver_ddi \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3238a24d..73c9fb93 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # SPDX-License-Identifier: MIT add_executable( @@ -128,6 +128,208 @@ endif() add_test(NAME tests_sigle_driver_stdout COMMAND tests --gtest_filter=*GivenZeInitDriverWhenCalledThenNoOutputIsPrintedToStdout) set_property(TEST tests_sigle_driver_stdout PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_multi_driver_drivergetproperties_sort COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingDriverGetPropertiesThenExpectSuccess) +if (MSVC) + set_property(TEST tests_multi_driver_drivergetproperties_sort APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_drivergetproperties_sort APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +# Run with multiple drivers with one driver using legacy mode +add_test(NAME tests_multi_driver_missing_initDrivers_onelegacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversMissingInitDriversWhenCallingZeInitDriversThenExpectSuccessForZeInit) +if (MSVC) + set_property(TEST tests_multi_driver_missing_initDrivers_onelegacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_missing_initDrivers_onelegacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_missing_initDrivers_sort_after_error_onelegacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversMissingInitDriversWhenCallingZeInitDriversThenExpectSuccessForZeInitWithDriverGetAfterInitDrivers) +if (MSVC) + set_property(TEST tests_multi_driver_missing_initDrivers_sort_after_error_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_missing_initDrivers_sort_after_error_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_sort_onelegacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingZeInitDriversThenExpectSuccessForZeInit) +if (MSVC) + set_property(TEST tests_multi_driver_sort_onelegacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_sort_onelegacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_driverget_sort_onelegacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingZeInitThenZeInitDriversThenExpectSuccessForZeInitWithDriverGetAfterInitDrivers) +if (MSVC) + set_property(TEST tests_multi_driver_driverget_sort_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_driverget_sort_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_drivergetproperties_sort_onelegacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingDriverGetPropertiesThenExpectSuccess) +if (MSVC) + set_property(TEST tests_multi_driver_drivergetproperties_sort_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_drivergetproperties_sort_onelegacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +# Run with multiple drivers with both drivers using legacy mode +add_test(NAME tests_multi_driver_missing_initDrivers_legacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversMissingInitDriversWhenCallingZeInitDriversThenExpectSuccessForZeInit) +if (MSVC) + set_property(TEST tests_multi_driver_missing_initDrivers_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_missing_initDrivers_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_missing_initDrivers_sort_after_error_legacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversMissingInitDriversWhenCallingZeInitDriversThenExpectSuccessForZeInitWithDriverGetAfterInitDrivers) +if (MSVC) + set_property(TEST tests_multi_driver_missing_initDrivers_sort_after_error_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_missing_initDrivers_sort_after_error_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_sort_legacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingZeInitDriversThenExpectSuccessForZeInit) +if (MSVC) + set_property(TEST tests_multi_driver_sort_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_sort_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_driverget_sort_legacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingZeInitThenZeInitDriversThenExpectSuccessForZeInitWithDriverGetAfterInitDrivers) +if (MSVC) + set_property(TEST tests_multi_driver_driverget_sort_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_driverget_sort_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_multi_driver_drivergetproperties_sort_legacy COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingDriverGetPropertiesThenExpectSuccess) +if (MSVC) + set_property(TEST tests_multi_driver_drivergetproperties_sort_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set_property(TEST tests_multi_driver_drivergetproperties_sort_legacy APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=3;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +add_test(NAME tests_loader_translate_handles_module COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModule) +set_property(TEST tests_loader_translate_handles_module PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_module_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModule) +set_property(TEST tests_loader_translate_handles_module_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_module_build_log COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModuleBuildLog) +set_property(TEST tests_loader_translate_handles_module_build_log PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_module_build_log_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModuleBuildLog) +set_property(TEST tests_loader_translate_handles_module_build_log_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_kernel COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForKernel) +set_property(TEST tests_loader_translate_handles_kernel PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_kernel_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForKernel) +set_property(TEST tests_loader_translate_handles_kernel_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_sampler COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForSampler) +set_property(TEST tests_loader_translate_handles_sampler PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_sampler_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForSampler) +set_property(TEST tests_loader_translate_handles_sampler_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_physical_mem COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForPhysicalMem) +set_property(TEST tests_loader_translate_handles_physical_mem PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_physical_mem_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForPhysicalMem) +set_property(TEST tests_loader_translate_handles_physical_mem_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_fence COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForFence) +set_property(TEST tests_loader_translate_handles_fence PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_fence_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForFence) +set_property(TEST tests_loader_translate_handles_fence_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_event_pool COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEventPool) +set_property(TEST tests_loader_translate_handles_event_pool PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_event_pool_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEventPool) +set_property(TEST tests_loader_translate_handles_event_pool_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_image COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForImage) +set_property(TEST tests_loader_translate_handles_image PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_image_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForImage) +set_property(TEST tests_loader_translate_handles_image_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_context COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForContext) +set_property(TEST tests_loader_translate_handles_context PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_context_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForContext) +set_property(TEST tests_loader_translate_handles_context_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_command_queue COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandQueue) +set_property(TEST tests_loader_translate_handles_command_queue PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_command_queue_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandQueue) +set_property(TEST tests_loader_translate_handles_command_queue_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_command_list COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandList) +set_property(TEST tests_loader_translate_handles_command_list PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_command_list_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandList) +set_property(TEST tests_loader_translate_handles_command_list_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_event COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEvent) +set_property(TEST tests_loader_translate_handles_event PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_event_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEvent) +set_property(TEST tests_loader_translate_handles_event_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_driver COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDriver) +set_property(TEST tests_loader_translate_handles_driver PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_driver_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDriver) +set_property(TEST tests_loader_translate_handles_driver_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_device COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDevice) +set_property(TEST tests_loader_translate_handles_device PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +add_test(NAME tests_loader_translate_handles_device_ddi_enabled COMMAND tests --gtest_filter=*LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDevice) +set_property(TEST tests_loader_translate_handles_device_ddi_enabled PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") + +# Add new versions of the tests with ZE_ENABLE_ALT_DRIVERS for Linux and Windows with both null drivers +if (MSVC) + set(ALT_DRIVERS_ENV "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/bin/$/ze_null_test1.dll,${CMAKE_BINARY_DIR}/bin/$/ze_null_test2.dll") +else() + set(ALT_DRIVERS_ENV "ZE_ENABLE_LOADER_DRIVER_DDI_PATH=1;ZE_ENABLE_ALT_DRIVERS=${CMAKE_BINARY_DIR}/lib/libze_null_test1.so,${CMAKE_BINARY_DIR}/lib/libze_null_test2.so") +endif() + +foreach(test_name IN ITEMS + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModule + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModule + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModuleBuildLog + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModuleBuildLog + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForKernel + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForKernel + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForSampler + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForSampler + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForPhysicalMem + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForPhysicalMem + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForFence + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForFence + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEventPool + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEventPool + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForImage + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForImage + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForContext + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForContext + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandQueue + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandQueue + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandList + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandList + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEvent + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEvent + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDriver + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDriver + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDevice + LoaderTranslateHandles.GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDevice) + add_test(NAME ${test_name}_alt_drivers COMMAND tests --gtest_filter=*${test_name}) + set_property(TEST ${test_name}_alt_drivers APPEND PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1;${ALT_DRIVERS_ENV}") +endforeach() # These tests are currently not supported on Windows. The reason is that the std::cerr is not being redirected to a pipe in Windows to be then checked against the expected output. if(NOT MSVC) add_test(NAME tests_event_deadlock COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeCommandListAppendMemoryCopyWithCircularDependencyOnEventsThenValidationLayerPrintsWarningOfDeadlock*) diff --git a/test/loader_api.cpp b/test/loader_api.cpp index 5ed18f0f..fe9835f5 100644 --- a/test/loader_api.cpp +++ b/test/loader_api.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -443,4 +443,1140 @@ TEST( EXPECT_TRUE(output.empty()); } +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWithMultipleDriversWhenCallingDriverGetPropertiesThenExpectSuccess) { + + uint32_t pInitDriversCount = 0; + uint32_t pDriverGetCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); + EXPECT_GT(pInitDriversCount, 0); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&pDriverGetCount, nullptr)); + EXPECT_GT(pDriverGetCount, 0); + std::vector drivers(pInitDriversCount); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); + for (uint32_t i = 0; i < pDriverGetCount; ++i) { + ze_driver_properties_t driverProperties = {ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES}; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[i], &driverProperties)); + std::cout << "Driver " << i << " properties:" << std::endl; + std::cout << " Driver version: " << driverProperties.driverVersion << std::endl; + std::cout << " UUID: "; + for (auto byte : driverProperties.uuid.id) { + std::cout << std::hex << static_cast(byte); + } + std::cout << std::dec << std::endl; + } +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModule) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +EXPECT_GT(pInitDriversCount, 0); +std::vector drivers(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, nullptr)); +ze_module_handle_t translatedHandle = module; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_MODULE, module, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, module); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModule) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, nullptr)); +ze_module_handle_t translatedHandle = module; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_MODULE, module, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, module); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForModuleBuildLog) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +ze_module_build_log_handle_t buildLog; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, &buildLog)); +ze_module_build_log_handle_t translatedHandle = buildLog; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_MODULE_BUILD_LOG, buildLog, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, buildLog); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleBuildLogDestroy(buildLog)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForModuleBuildLog) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +ze_module_build_log_handle_t buildLog; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, &buildLog)); +ze_module_build_log_handle_t translatedHandle = buildLog; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_MODULE_BUILD_LOG, buildLog, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, buildLog); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleBuildLogDestroy(buildLog)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForKernel) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, nullptr)); +ze_kernel_handle_t kernel; +ze_kernel_desc_t kernelDesc = {ZE_STRUCTURE_TYPE_KERNEL_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeKernelCreate(module, &kernelDesc, &kernel)); +ze_kernel_handle_t translatedHandle = kernel; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_KERNEL, kernel, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, kernel); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeKernelDestroy(kernel)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForKernel) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_module_handle_t module; +ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleCreate(context, devices[0], &moduleDesc, &module, nullptr)); +ze_kernel_handle_t kernel; +ze_kernel_desc_t kernelDesc = {ZE_STRUCTURE_TYPE_KERNEL_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeKernelCreate(module, &kernelDesc, &kernel)); +ze_kernel_handle_t translatedHandle = kernel; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_KERNEL, kernel, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, kernel); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeKernelDestroy(kernel)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeModuleDestroy(module)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForSampler) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_sampler_handle_t sampler; +ze_sampler_desc_t samplerDesc = {ZE_STRUCTURE_TYPE_SAMPLER_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeSamplerCreate(context, devices[0], &samplerDesc, &sampler)); +ze_sampler_handle_t translatedHandle = sampler; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_SAMPLER, sampler, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, sampler); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeSamplerDestroy(sampler)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForSampler) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_sampler_handle_t sampler; +ze_sampler_desc_t samplerDesc = {ZE_STRUCTURE_TYPE_SAMPLER_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeSamplerCreate(context, devices[0], &samplerDesc, &sampler)); +ze_sampler_handle_t translatedHandle = sampler; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_SAMPLER, sampler, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, sampler); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeSamplerDestroy(sampler)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForPhysicalMem) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_physical_mem_handle_t physicalMem; +ze_physical_mem_desc_t physicalMemDesc = {ZE_STRUCTURE_TYPE_PHYSICAL_MEM_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zePhysicalMemCreate(context, devices[0], &physicalMemDesc, &physicalMem)); +ze_physical_mem_handle_t translatedHandle = physicalMem; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_PHYSICAL_MEM, physicalMem, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, physicalMem); +EXPECT_EQ(ZE_RESULT_SUCCESS, zePhysicalMemDestroy(context, physicalMem)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForPhysicalMem) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_physical_mem_handle_t physicalMem; +ze_physical_mem_desc_t physicalMemDesc = {ZE_STRUCTURE_TYPE_PHYSICAL_MEM_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zePhysicalMemCreate(context, devices[0], &physicalMemDesc, &physicalMem)); +ze_physical_mem_handle_t translatedHandle = physicalMem; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_PHYSICAL_MEM, physicalMem, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, physicalMem); +EXPECT_EQ(ZE_RESULT_SUCCESS, zePhysicalMemDestroy(context, physicalMem)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForFence) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_queue_handle_t commandQueue; +ze_command_queue_desc_t commandQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueCreate(context, devices[0], &commandQueueDesc, &commandQueue)); +ze_fence_handle_t fence; +ze_fence_desc_t fenceDesc = {ZE_STRUCTURE_TYPE_FENCE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceCreate(commandQueue, &fenceDesc, &fence)); +ze_fence_handle_t translatedHandle = fence; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_FENCE, fence, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, fence); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceDestroy(fence)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueDestroy(commandQueue)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForFence) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_queue_handle_t commandQueue; +ze_command_queue_desc_t commandQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueCreate(context, devices[0], &commandQueueDesc, &commandQueue)); +ze_fence_handle_t fence; +ze_fence_desc_t fenceDesc = {ZE_STRUCTURE_TYPE_FENCE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceCreate(commandQueue, &fenceDesc, &fence)); +ze_fence_handle_t translatedHandle = fence; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_FENCE, fence, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, fence); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceDestroy(fence)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueDestroy(commandQueue)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEventPool) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_event_pool_handle_t eventPool; +ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC}; +eventPoolDesc.count = 1; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolCreate(context, &eventPoolDesc, 0, nullptr, &eventPool)); +ze_event_pool_handle_t translatedHandle = eventPool; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_EVENT_POOL, eventPool, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, eventPool); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolDestroy(eventPool)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEventPool) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_event_pool_handle_t eventPool; +ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC}; +eventPoolDesc.count = 1; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolCreate(context, &eventPoolDesc, 0, nullptr, &eventPool)); +ze_event_pool_handle_t translatedHandle = eventPool; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_EVENT_POOL, eventPool, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, eventPool); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolDestroy(eventPool)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForImage) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_image_handle_t image; +ze_image_desc_t imageDesc = {ZE_STRUCTURE_TYPE_IMAGE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeImageCreate(context, devices[0], &imageDesc, &image)); +ze_image_handle_t translatedHandle = image; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_IMAGE, image, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, image); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeImageDestroy(image)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForImage) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_image_handle_t image; +ze_image_desc_t imageDesc = {ZE_STRUCTURE_TYPE_IMAGE_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeImageCreate(context, devices[0], &imageDesc, &image)); +ze_image_handle_t translatedHandle = image; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_IMAGE, image, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, image); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeImageDestroy(image)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForContext) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_context_handle_t translatedHandle = context; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_CONTEXT, context, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, context); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForContext) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_context_handle_t translatedHandle = context; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_CONTEXT, context, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, context); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandQueue) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_queue_handle_t commandQueue; +ze_command_queue_desc_t commandQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueCreate(context, devices[0], &commandQueueDesc, &commandQueue)); +ze_command_queue_handle_t translatedHandle = commandQueue; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_COMMAND_QUEUE, commandQueue, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, commandQueue); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueDestroy(commandQueue)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandQueue) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_queue_handle_t commandQueue; +ze_command_queue_desc_t commandQueueDesc = {ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueCreate(context, devices[0], &commandQueueDesc, &commandQueue)); +ze_command_queue_handle_t translatedHandle = commandQueue; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_COMMAND_QUEUE, commandQueue, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, commandQueue); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandQueueDestroy(commandQueue)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForCommandList) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_list_handle_t commandList; +ze_command_list_desc_t commandListDesc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListCreate(context, devices[0], &commandListDesc, &commandList)); +ze_command_list_handle_t translatedHandle = commandList; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_COMMAND_LIST, commandList, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, commandList); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListDestroy(commandList)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForCommandList) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_command_list_handle_t commandList; +ze_command_list_desc_t commandListDesc = {ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC}; +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListCreate(context, devices[0], &commandListDesc, &commandList)); +ze_command_list_handle_t translatedHandle = commandList; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_COMMAND_LIST, commandList, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, commandList); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListDestroy(commandList)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForEvent) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_event_pool_handle_t eventPool; +ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC}; +eventPoolDesc.count = 1; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolCreate(context, &eventPoolDesc, 0, nullptr, &eventPool)); +ze_event_handle_t event; +ze_event_desc_t eventDesc = {ZE_STRUCTURE_TYPE_EVENT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventCreate(eventPool, &eventDesc, &event)); +ze_event_handle_t translatedHandle = event; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_EVENT, event, reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, event); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventDestroy(event)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolDestroy(eventPool)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForEvent) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_context_handle_t context; +ze_context_desc_t contextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextCreate(drivers[0], &contextDesc, &context)); +ze_event_pool_handle_t eventPool; +ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC}; +eventPoolDesc.count = 1; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolCreate(context, &eventPoolDesc, 0, nullptr, &eventPool)); +ze_event_handle_t event; +ze_event_desc_t eventDesc = {ZE_STRUCTURE_TYPE_EVENT_DESC}; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventCreate(eventPool, &eventDesc, &event)); +ze_event_handle_t translatedHandle = event; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_EVENT, event, reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, event); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventDestroy(event)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeEventPoolDestroy(eventPool)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeContextDestroy(context)); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDriver) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_driver_handle_t translatedHandle = drivers[0]; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_DRIVER, drivers[0], reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, drivers[0]); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDriver) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +ze_driver_handle_t translatedHandle = drivers[0]; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_DRIVER, drivers[0], reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, drivers[0]); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportDisabledThenExpectHandleTranslationForDevice) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=1" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_device_handle_t translatedHandle = devices[0]; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_DEVICE, devices[0], reinterpret_cast(&translatedHandle))); +EXPECT_NE(translatedHandle, devices[0]); + +} + +TEST( + LoaderTranslateHandles, + GivenLevelZeroLoaderPresentWhenCallingZelLoaderTranslateHandleInternalWithInterceptEnabledAndDDiSupportEnabledThenExpectNoHandleTranslationForDevice) { + +uint32_t pInitDriversCount = 0; +ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; +desc.flags = UINT32_MAX; +desc.pNext = nullptr; +putenv_safe( const_cast( "ZE_ENABLE_LOADER_INTERCEPT=1" ) ); +putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_DISABLE_DDI_EXT=0" ) ); +std::vector drivers; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, nullptr, &desc)); +drivers.resize(pInitDriversCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +EXPECT_GT(pInitDriversCount, 0); +ze_driver_ddi_handles_ext_properties_t driverDdiHandlesExtProperties = {}; +driverDdiHandlesExtProperties.stype = ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES; +driverDdiHandlesExtProperties.pNext = nullptr; +ze_driver_properties_t properties = {}; +properties.stype = ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES; +properties.pNext = &driverDdiHandlesExtProperties; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetProperties(drivers[0], &properties)); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pInitDriversCount, drivers.data(), &desc)); +uint32_t deviceCount = 0; +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, nullptr)); +std::vector devices(deviceCount); +EXPECT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &deviceCount, devices.data())); +ze_device_handle_t translatedHandle = devices[0]; +EXPECT_EQ(ZE_RESULT_SUCCESS, zelLoaderTranslateHandle(ZEL_HANDLE_DEVICE, devices[0], reinterpret_cast(&translatedHandle))); +EXPECT_EQ(translatedHandle, devices[0]); + +} + } // namespace