Skip to content

Commit 5f9d031

Browse files
committed
Fix to add missing zeKernelGetExp API and header updates
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 0a681d7 commit 5f9d031

23 files changed

+390
-34
lines changed

include/layers/zel_tracing_register_cb.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,33 @@ typedef void (ZE_APICALL *ze_pfnKernelSetGlobalOffsetExpCb_t)(
14101410
void** ppTracerInstanceUserData
14111411
);
14121412

1413+
///////////////////////////////////////////////////////////////////////////////
1414+
/// @brief Callback function parameters for zeKernelGetBinaryExp
1415+
/// @details Each entry is a pointer to the parameter passed to the function;
1416+
/// allowing the callback the ability to modify the parameter's value
1417+
1418+
typedef struct _ze_kernel_get_binary_exp_params_t
1419+
{
1420+
ze_kernel_handle_t* phKernel;
1421+
size_t** ppSize;
1422+
uint8_t** ppKernelBinary;
1423+
} ze_kernel_get_binary_exp_params_t;
1424+
1425+
1426+
///////////////////////////////////////////////////////////////////////////////
1427+
/// @brief Callback function-pointer for zeKernelGetBinaryExp
1428+
/// @param[in] params Parameters passed to this instance
1429+
/// @param[in] result Return value
1430+
/// @param[in] pTracerUserData Per-Tracer user data
1431+
/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data
1432+
1433+
typedef void (ZE_APICALL *ze_pfnKernelGetBinaryExpCb_t)(
1434+
ze_kernel_get_binary_exp_params_t* params,
1435+
ze_result_t result,
1436+
void* pTracerUserData,
1437+
void** ppTracerInstanceUserData
1438+
);
1439+
14131440
///////////////////////////////////////////////////////////////////////////////
14141441
/// @brief Callback function parameters for zeKernelSchedulingHintExp
14151442
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -3023,6 +3050,14 @@ zelTracerKernelSetGlobalOffsetExpRegisterCallback(
30233050
);
30243051

30253052

3053+
ZE_APIEXPORT ze_result_t ZE_APICALL
3054+
zelTracerKernelGetBinaryExpRegisterCallback(
3055+
zel_tracer_handle_t hTracer,
3056+
zel_tracer_reg_t callback_type,
3057+
ze_pfnKernelGetBinaryExpCb_t pfnGetBinaryExpCb
3058+
);
3059+
3060+
30263061
ZE_APIEXPORT ze_result_t ZE_APICALL
30273062
zelTracerDeviceReserveCacheExtRegisterCallback(
30283063
zel_tracer_handle_t hTracer,

include/ze.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SPDX-License-Identifier: MIT
55
66
@file ze.py
7-
@version v1.11-r1.11.5
7+
@version v1.11-r1.11.9
88
99
"""
1010
import platform
@@ -5520,13 +5520,21 @@ class _ze_kernel_dditable_t(Structure):
55205520
else:
55215521
_zeKernelSchedulingHintExp_t = CFUNCTYPE( ze_result_t, ze_kernel_handle_t, POINTER(ze_scheduling_hint_exp_desc_t) )
55225522

5523+
###############################################################################
5524+
## @brief Function-pointer for zeKernelGetBinaryExp
5525+
if __use_win_types:
5526+
_zeKernelGetBinaryExp_t = WINFUNCTYPE( ze_result_t, ze_kernel_handle_t, POINTER(c_size_t), POINTER(c_ubyte) )
5527+
else:
5528+
_zeKernelGetBinaryExp_t = CFUNCTYPE( ze_result_t, ze_kernel_handle_t, POINTER(c_size_t), POINTER(c_ubyte) )
5529+
55235530

55245531
###############################################################################
55255532
## @brief Table of KernelExp functions pointers
55265533
class _ze_kernel_exp_dditable_t(Structure):
55275534
_fields_ = [
55285535
("pfnSetGlobalOffsetExp", c_void_p), ## _zeKernelSetGlobalOffsetExp_t
5529-
("pfnSchedulingHintExp", c_void_p) ## _zeKernelSchedulingHintExp_t
5536+
("pfnSchedulingHintExp", c_void_p), ## _zeKernelSchedulingHintExp_t
5537+
("pfnGetBinaryExp", c_void_p) ## _zeKernelGetBinaryExp_t
55305538
]
55315539

55325540
###############################################################################
@@ -6129,6 +6137,7 @@ def __init__(self, version : ze_api_version_t):
61296137
# attach function interface to function address
61306138
self.zeKernelSetGlobalOffsetExp = _zeKernelSetGlobalOffsetExp_t(self.__dditable.KernelExp.pfnSetGlobalOffsetExp)
61316139
self.zeKernelSchedulingHintExp = _zeKernelSchedulingHintExp_t(self.__dditable.KernelExp.pfnSchedulingHintExp)
6140+
self.zeKernelGetBinaryExp = _zeKernelGetBinaryExp_t(self.__dditable.KernelExp.pfnGetBinaryExp)
61326141

61336142
# call driver to get function pointers
61346143
_Sampler = _ze_sampler_dditable_t()

include/ze_api.h

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file ze_api.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZE_API_H
@@ -968,8 +968,9 @@ typedef enum _ze_init_flag_t
968968
/// @brief Initialize the 'oneAPI' driver(s)
969969
///
970970
/// @details
971-
/// - The application must call this function before calling any other
972-
/// function.
971+
/// - @deprecated since 1.10. Please use zeInitDrivers()
972+
/// - The application must call this function or zeInitDrivers before
973+
/// calling any other function.
973974
/// - If this function is not called then all other functions will return
974975
/// ::ZE_RESULT_ERROR_UNINITIALIZED.
975976
/// - Only one instance of each driver will be initialized per process.
@@ -999,6 +1000,10 @@ zeInit(
9991000
/// @brief Retrieves driver instances
10001001
///
10011002
/// @details
1003+
/// - @deprecated since 1.10. Please use zeInitDrivers()
1004+
/// - Usage of zeInitDrivers and zeDriverGet is mutually exclusive and
1005+
/// should not be used together. Usage of them together will result in
1006+
/// undefined behavior.
10021007
/// - A driver represents a collection of physical devices.
10031008
/// - Multiple calls to this function will return identical driver handles,
10041009
/// in the same order.
@@ -1075,20 +1080,20 @@ typedef struct _ze_init_driver_type_desc_t
10751080
///
10761081
/// @details
10771082
/// - The application must call this function or zeInit before calling any
1078-
/// other function.
1079-
/// - The application can call InitDrivers or zeInit to init the drivers on
1080-
/// the system.
1081-
/// - Calls to zeInit or InitDrivers will not alter the drivers retrieved
1082-
/// thru either api.
1083-
/// - Drivers init thru zeInit or InitDrivers will not be reInitialized once
1084-
/// init in an application. The Loader will determine if the already init
1085-
/// driver needs to be delivered to the user thru the init type flags.
1083+
/// other function. (zeInit is [Deprecated] and is replaced by
1084+
/// zeInitDrivers)
1085+
/// - Calls to zeInit[Deprecated] or InitDrivers will not alter the drivers
1086+
/// retrieved thru either api.
1087+
/// - Drivers init thru zeInit[Deprecated] or InitDrivers will not be
1088+
/// reInitialized once init in an application. The Loader will determine
1089+
/// if the already init driver needs to be delivered to the user thru the
1090+
/// init type flags.
10861091
/// - Already init Drivers will not be uninitialized if the call to
10871092
/// InitDrivers does not include that driver's type. Those init drivers
10881093
/// which don't match the init flags will not have their driver handles
10891094
/// returned to the user in that InitDrivers call.
1090-
/// - If this function or zeInit is not called, then all other functions
1091-
/// will return ::ZE_RESULT_ERROR_UNINITIALIZED.
1095+
/// - If this function or zeInit[Deprecated] is not called, then all other
1096+
/// functions will return ::ZE_RESULT_ERROR_UNINITIALIZED.
10921097
/// - Only one instance of each driver will be initialized per process.
10931098
/// - A driver represents a collection of physical devices.
10941099
/// - Multiple calls to this function will return identical driver handles,
@@ -7659,6 +7664,34 @@ typedef struct _ze_relaxed_allocation_limits_exp_desc_t
76597664
#define ZE_GET_KERNEL_BINARY_EXP_NAME "ZE_extension_kernel_binary_exp"
76607665
#endif // ZE_GET_KERNEL_BINARY_EXP_NAME
76617666

7667+
///////////////////////////////////////////////////////////////////////////////
7668+
/// @brief Retrieves kernel binary program data (ISA GEN format).
7669+
///
7670+
/// @details
7671+
/// - A valid kernel handle must be created with ::zeKernelCreate.
7672+
/// - Returns Intel Graphics Assembly (GEN ISA) format binary program data
7673+
/// for kernel handle.
7674+
/// - The application may call this function from simultaneous threads.
7675+
/// - The implementation of this function must be thread-safe.
7676+
///
7677+
/// @returns
7678+
/// - ::ZE_RESULT_SUCCESS
7679+
/// - ::ZE_RESULT_ERROR_UNINITIALIZED
7680+
/// - ::ZE_RESULT_ERROR_DEVICE_LOST
7681+
/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY
7682+
/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY
7683+
/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE
7684+
/// + `nullptr == hKernel`
7685+
/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
7686+
/// + `nullptr == pSize`
7687+
/// + `nullptr == pKernelBinary`
7688+
ZE_APIEXPORT ze_result_t ZE_APICALL
7689+
zeKernelGetBinaryExp(
7690+
ze_kernel_handle_t hKernel, ///< [in] Kernel handle.
7691+
size_t* pSize, ///< [in,out] pointer to variable with size of GEN ISA binary.
7692+
uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function.
7693+
);
7694+
76627695
#if !defined(__GNUC__)
76637696
#pragma endregion
76647697
#endif

include/ze_ddi.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file ze_ddi.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZE_DDI_H
@@ -2196,12 +2196,21 @@ typedef ze_result_t (ZE_APICALL *ze_pfnKernelSchedulingHintExp_t)(
21962196
ze_scheduling_hint_exp_desc_t*
21972197
);
21982198

2199+
///////////////////////////////////////////////////////////////////////////////
2200+
/// @brief Function-pointer for zeKernelGetBinaryExp
2201+
typedef ze_result_t (ZE_APICALL *ze_pfnKernelGetBinaryExp_t)(
2202+
ze_kernel_handle_t,
2203+
size_t*,
2204+
uint8_t*
2205+
);
2206+
21992207
///////////////////////////////////////////////////////////////////////////////
22002208
/// @brief Table of KernelExp functions pointers
22012209
typedef struct _ze_kernel_exp_dditable_t
22022210
{
22032211
ze_pfnKernelSetGlobalOffsetExp_t pfnSetGlobalOffsetExp;
22042212
ze_pfnKernelSchedulingHintExp_t pfnSchedulingHintExp;
2213+
ze_pfnKernelGetBinaryExp_t pfnGetBinaryExp;
22052214
} ze_kernel_exp_dditable_t;
22062215

22072216
///////////////////////////////////////////////////////////////////////////////

include/zes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SPDX-License-Identifier: MIT
55
66
@file zes.py
7-
@version v1.11-r1.11.5
7+
@version v1.11-r1.11.9
88
99
"""
1010
import platform

include/zes_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file zes_api.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZES_API_H

include/zes_ddi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file zes_ddi.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZES_DDI_H

include/zet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SPDX-License-Identifier: MIT
55
66
@file zet.py
7-
@version v1.11-r1.11.5
7+
@version v1.11-r1.11.9
88
99
"""
1010
import platform

include/zet_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file zet_api.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZET_API_H

include/zet_ddi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*
77
* @file zet_ddi.h
8-
* @version v1.11-r1.11.5
8+
* @version v1.11-r1.11.9
99
*
1010
*/
1111
#ifndef _ZET_DDI_H

source/drivers/null/ze_nullddi.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,6 +3969,31 @@ namespace driver
39693969
return result;
39703970
}
39713971

3972+
///////////////////////////////////////////////////////////////////////////////
3973+
/// @brief Intercept function for zeKernelGetBinaryExp
3974+
__zedlllocal ze_result_t ZE_APICALL
3975+
zeKernelGetBinaryExp(
3976+
ze_kernel_handle_t hKernel, ///< [in] Kernel handle.
3977+
size_t* pSize, ///< [in,out] pointer to variable with size of GEN ISA binary.
3978+
uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function.
3979+
)
3980+
{
3981+
ze_result_t result = ZE_RESULT_SUCCESS;
3982+
3983+
// if the driver has created a custom function, then call it instead of using the generic path
3984+
auto pfnGetBinaryExp = context.zeDdiTable.KernelExp.pfnGetBinaryExp;
3985+
if( nullptr != pfnGetBinaryExp )
3986+
{
3987+
result = pfnGetBinaryExp( hKernel, pSize, pKernelBinary );
3988+
}
3989+
else
3990+
{
3991+
// generic implementation
3992+
}
3993+
3994+
return result;
3995+
}
3996+
39723997
///////////////////////////////////////////////////////////////////////////////
39733998
/// @brief Intercept function for zeDeviceReserveCacheExt
39743999
__zedlllocal ze_result_t ZE_APICALL
@@ -5876,6 +5901,8 @@ zeGetKernelExpProcAddrTable(
58765901

58775902
pDdiTable->pfnSetGlobalOffsetExp = driver::zeKernelSetGlobalOffsetExp;
58785903

5904+
pDdiTable->pfnGetBinaryExp = driver::zeKernelGetBinaryExp;
5905+
58795906
pDdiTable->pfnSchedulingHintExp = driver::zeKernelSchedulingHintExp;
58805907

58815908
return result;

source/layers/tracing/ze_tracing_cb_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ typedef struct _zel_kernel_callbacks_t
235235
ze_pfnKernelGetPropertiesCb_t pfnGetPropertiesCb;
236236
ze_pfnKernelGetNameCb_t pfnGetNameCb;
237237
ze_pfnKernelSetGlobalOffsetExpCb_t pfnSetGlobalOffsetExpCb;
238+
ze_pfnKernelGetBinaryExpCb_t pfnGetBinaryExpCb;
238239
ze_pfnKernelSchedulingHintExpCb_t pfnSchedulingHintExpCb;
239240
} zel_kernel_callbacks_t;
240241

source/layers/tracing/ze_tracing_register_cb.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,22 @@ zelTracerKernelSetGlobalOffsetExpRegisterCallback(
23552355
}
23562356

23572357

2358+
ZE_DLLEXPORT ze_result_t ZE_APICALL
2359+
zelTracerKernelGetBinaryExpRegisterCallback(
2360+
zel_tracer_handle_t hTracer,
2361+
zel_tracer_reg_t callback_type,
2362+
ze_pfnKernelGetBinaryExpCb_t pfnGetBinaryExpCb
2363+
) {
2364+
2365+
ze_result_t result;
2366+
auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result);
2367+
if (result == ZE_RESULT_SUCCESS)
2368+
cbs.Kernel.pfnGetBinaryExpCb = pfnGetBinaryExpCb;
2369+
2370+
return result;
2371+
}
2372+
2373+
23582374
ZE_DLLEXPORT ze_result_t ZE_APICALL
23592375
zelTracerDeviceReserveCacheExtRegisterCallback(
23602376
zel_tracer_handle_t hTracer,

source/layers/tracing/ze_trcddi.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5827,6 +5827,44 @@ namespace tracing_layer
58275827
*tracerParams.poffsetZ);
58285828
}
58295829

5830+
///////////////////////////////////////////////////////////////////////////////
5831+
/// @brief Intercept function for zeKernelGetBinaryExp
5832+
__zedlllocal ze_result_t ZE_APICALL
5833+
zeKernelGetBinaryExp(
5834+
ze_kernel_handle_t hKernel, ///< [in] Kernel handle.
5835+
size_t* pSize, ///< [in,out] pointer to variable with size of GEN ISA binary.
5836+
uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function.
5837+
)
5838+
{
5839+
auto pfnGetBinaryExp = context.zeDdiTable.KernelExp.pfnGetBinaryExp;
5840+
5841+
if( nullptr == pfnGetBinaryExp)
5842+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
5843+
5844+
ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.KernelExp.pfnGetBinaryExp, hKernel, pSize, pKernelBinary);
5845+
5846+
// capture parameters
5847+
ze_kernel_get_binary_exp_params_t tracerParams = {
5848+
&hKernel,
5849+
&pSize,
5850+
&pKernelBinary
5851+
};
5852+
5853+
tracing_layer::APITracerCallbackDataImp<ze_pfnKernelGetBinaryExpCb_t> apiCallbackData;
5854+
5855+
ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnKernelGetBinaryExpCb_t, Kernel, pfnGetBinaryExpCb);
5856+
5857+
5858+
return tracing_layer::APITracerWrapperImp(context.zeDdiTable.KernelExp.pfnGetBinaryExp,
5859+
&tracerParams,
5860+
apiCallbackData.apiOrdinal,
5861+
apiCallbackData.prologCallbacks,
5862+
apiCallbackData.epilogCallbacks,
5863+
*tracerParams.phKernel,
5864+
*tracerParams.ppSize,
5865+
*tracerParams.ppKernelBinary);
5866+
}
5867+
58305868
///////////////////////////////////////////////////////////////////////////////
58315869
/// @brief Intercept function for zeDeviceReserveCacheExt
58325870
__zedlllocal ze_result_t ZE_APICALL
@@ -8470,6 +8508,9 @@ zeGetKernelExpProcAddrTable(
84708508
dditable.pfnSetGlobalOffsetExp = pDdiTable->pfnSetGlobalOffsetExp;
84718509
pDdiTable->pfnSetGlobalOffsetExp = tracing_layer::zeKernelSetGlobalOffsetExp;
84728510

8511+
dditable.pfnGetBinaryExp = pDdiTable->pfnGetBinaryExp;
8512+
pDdiTable->pfnGetBinaryExp = tracing_layer::zeKernelGetBinaryExp;
8513+
84738514
dditable.pfnSchedulingHintExp = pDdiTable->pfnSchedulingHintExp;
84748515
pDdiTable->pfnSchedulingHintExp = tracing_layer::zeKernelSchedulingHintExp;
84758516

0 commit comments

Comments
 (0)