Skip to content

Commit

Permalink
Add extensibility to the rest of kernelSet* entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
omarahmed1111 committed Jun 22, 2023
1 parent 24f5e01 commit 0af3f18
Show file tree
Hide file tree
Showing 15 changed files with 307 additions and 55 deletions.
42 changes: 36 additions & 6 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ class ur_structure_type_v(IntEnum):
DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t
KERNEL_ARG_MEM_OBJ_PROPERTIES = 27 ## ::ur_kernel_arg_mem_obj_properties_t
PHYSICAL_MEM_PROPERTIES = 28 ## ::ur_physical_mem_properties_t
KERNEL_ARG_POINTER_PROPERTIES = 29 ## ::ur_kernel_arg_pointer_properties_t
KERNEL_ARG_SAMPLER_PROPERTIES = 30 ## ::ur_kernel_arg_sampler_properties_t
KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t
EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t
EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t

Expand Down Expand Up @@ -1574,6 +1577,33 @@ def __str__(self):
return str(ur_kernel_exec_info_v(self.value))


###############################################################################
## @brief Properties for for ::urKernelSetArgPointer.
class ur_kernel_arg_pointer_properties_t(Structure):
_fields_ = [
("stype", ur_structure_type_t), ## [in] type of this structure, must be
## ::UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES
("pNext", c_void_p) ## [in,out][optional] pointer to extension-specific structure
]

###############################################################################
## @brief Properties for for ::urKernelSetExecInfo.
class ur_kernel_exec_info_properties_t(Structure):
_fields_ = [
("stype", ur_structure_type_t), ## [in] type of this structure, must be
## ::UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES
("pNext", c_void_p) ## [in,out][optional] pointer to extension-specific structure
]

###############################################################################
## @brief Properties for for ::urKernelSetArgSampler.
class ur_kernel_arg_sampler_properties_t(Structure):
_fields_ = [
("stype", ur_structure_type_t), ## [in] type of this structure, must be
## ::UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES
("pNext", c_void_p) ## [in,out][optional] pointer to extension-specific structure
]

###############################################################################
## @brief Properties for for ::urKernelSetArgMemObj.
class ur_kernel_arg_mem_obj_properties_t(Structure):
Expand Down Expand Up @@ -2466,23 +2496,23 @@ class ur_program_dditable_t(Structure):
###############################################################################
## @brief Function-pointer for urKernelSetArgPointer
if __use_win_types:
_urKernelSetArgPointer_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_void_p )
_urKernelSetArgPointer_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, POINTER(ur_kernel_arg_pointer_properties_t), c_void_p )
else:
_urKernelSetArgPointer_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_void_p )
_urKernelSetArgPointer_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, POINTER(ur_kernel_arg_pointer_properties_t), c_void_p )

###############################################################################
## @brief Function-pointer for urKernelSetExecInfo
if __use_win_types:
_urKernelSetExecInfo_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, ur_kernel_exec_info_t, c_size_t, c_void_p )
_urKernelSetExecInfo_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, ur_kernel_exec_info_t, c_size_t, POINTER(ur_kernel_exec_info_properties_t), c_void_p )
else:
_urKernelSetExecInfo_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, ur_kernel_exec_info_t, c_size_t, c_void_p )
_urKernelSetExecInfo_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, ur_kernel_exec_info_t, c_size_t, POINTER(ur_kernel_exec_info_properties_t), c_void_p )

###############################################################################
## @brief Function-pointer for urKernelSetArgSampler
if __use_win_types:
_urKernelSetArgSampler_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, ur_sampler_handle_t )
_urKernelSetArgSampler_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, POINTER(ur_kernel_arg_sampler_properties_t), ur_sampler_handle_t )
else:
_urKernelSetArgSampler_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, ur_sampler_handle_t )
_urKernelSetArgSampler_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, POINTER(ur_kernel_arg_sampler_properties_t), ur_sampler_handle_t )

###############################################################################
## @brief Function-pointer for urKernelSetArgMemObj
Expand Down
60 changes: 48 additions & 12 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ typedef enum ur_structure_type_t {
UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES = 26, ///< ::ur_device_partition_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_MEM_OBJ_PROPERTIES = 27, ///< ::ur_kernel_arg_mem_obj_properties_t
UR_STRUCTURE_TYPE_PHYSICAL_MEM_PROPERTIES = 28, ///< ::ur_physical_mem_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES = 29, ///< ::ur_kernel_arg_pointer_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES = 30, ///< ::ur_kernel_arg_sampler_properties_t
UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
/// @cond
Expand Down Expand Up @@ -4094,6 +4097,15 @@ urKernelRelease(
ur_kernel_handle_t hKernel ///< [in] handle for the Kernel to release
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Properties for for ::urKernelSetArgPointer.
typedef struct ur_kernel_arg_pointer_properties_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be
///< ::UR_STRUCTURE_TYPE_KERNEL_ARG_POINTER_PROPERTIES
void *pNext; ///< [in,out][optional] pointer to extension-specific structure

} ur_kernel_arg_pointer_properties_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Set a USM pointer as the argument value of a Kernel.
///
Expand All @@ -4116,12 +4128,22 @@ urKernelRelease(
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgPointer(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
const void *pArgValue ///< [in][optional] USM pointer to memory location holding the argument
///< value. If null then argument value is considered null.
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
const ur_kernel_arg_pointer_properties_t *pProperties, ///< [in][optional] pointer to USM pointer properties.
const void *pArgValue ///< [in][optional] USM pointer to memory location holding the argument
///< value. If null then argument value is considered null.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Properties for for ::urKernelSetExecInfo.
typedef struct ur_kernel_exec_info_properties_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be
///< ::UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES
void *pNext; ///< [in,out][optional] pointer to extension-specific structure

} ur_kernel_exec_info_properties_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Set additional Kernel execution attributes.
///
Expand All @@ -4146,13 +4168,23 @@ urKernelSetArgPointer(
/// + `NULL == pPropValue`
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetExecInfo(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
ur_kernel_exec_info_t propName, ///< [in] name of the execution attribute
size_t propSize, ///< [in] size in byte the attribute value
const void *pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding
///< the property value.
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
ur_kernel_exec_info_t propName, ///< [in] name of the execution attribute
size_t propSize, ///< [in] size in byte the attribute value
const ur_kernel_exec_info_properties_t *pProperties, ///< [in][optional] pointer to execution info properties.
const void *pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding
///< the property value.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Properties for for ::urKernelSetArgSampler.
typedef struct ur_kernel_arg_sampler_properties_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be
///< ::UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES
void *pNext; ///< [in,out][optional] pointer to extension-specific structure

} ur_kernel_arg_sampler_properties_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Set a Sampler object as the argument value of a Kernel.
///
Expand All @@ -4171,9 +4203,10 @@ urKernelSetExecInfo(
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgSampler(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object.
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
const ur_kernel_arg_sampler_properties_t *pProperties, ///< [in][optional] pointer to sampler properties.
ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object.
);

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -7763,6 +7796,7 @@ typedef struct ur_kernel_set_arg_local_params_t {
typedef struct ur_kernel_set_arg_pointer_params_t {
ur_kernel_handle_t *phKernel;
uint32_t *pargIndex;
const ur_kernel_arg_pointer_properties_t **ppProperties;
const void **ppArgValue;
} ur_kernel_set_arg_pointer_params_t;

Expand All @@ -7774,6 +7808,7 @@ typedef struct ur_kernel_set_exec_info_params_t {
ur_kernel_handle_t *phKernel;
ur_kernel_exec_info_t *ppropName;
size_t *ppropSize;
const ur_kernel_exec_info_properties_t **ppProperties;
const void **ppPropValue;
} ur_kernel_set_exec_info_params_t;

Expand All @@ -7784,6 +7819,7 @@ typedef struct ur_kernel_set_exec_info_params_t {
typedef struct ur_kernel_set_arg_sampler_params_t {
ur_kernel_handle_t *phKernel;
uint32_t *pargIndex;
const ur_kernel_arg_sampler_properties_t **ppProperties;
ur_sampler_handle_t *phArgValue;
} ur_kernel_set_arg_sampler_params_t;

Expand Down
3 changes: 3 additions & 0 deletions include/ur_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnKernelSetArgLocal_t)(
typedef ur_result_t(UR_APICALL *ur_pfnKernelSetArgPointer_t)(
ur_kernel_handle_t,
uint32_t,
const ur_kernel_arg_pointer_properties_t *,
const void *);

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -503,13 +504,15 @@ typedef ur_result_t(UR_APICALL *ur_pfnKernelSetExecInfo_t)(
ur_kernel_handle_t,
ur_kernel_exec_info_t,
size_t,
const ur_kernel_exec_info_properties_t *,
const void *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urKernelSetArgSampler
typedef ur_result_t(UR_APICALL *ur_pfnKernelSetArgSampler_t)(
ur_kernel_handle_t,
uint32_t,
const ur_kernel_arg_sampler_properties_t *,
ur_sampler_handle_t);

///////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ etors:
desc: $x_kernel_arg_mem_obj_properties_t
- name: PHYSICAL_MEM_PROPERTIES
desc: $x_physical_mem_properties_t
- name: KERNEL_ARG_POINTER_PROPERTIES
desc: $x_kernel_arg_pointer_properties_t
- name: KERNEL_ARG_SAMPLER_PROPERTIES
desc: $x_kernel_arg_sampler_properties_t
- name: KERNEL_EXEC_INFO_PROPERTIES
desc: $x_kernel_exec_info_properties_t
--- #--------------------------------------------------------------------------
type: struct
desc: "Base for all properties types"
Expand Down
30 changes: 30 additions & 0 deletions scripts/core/kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ params:
name: hKernel
desc: "[in] handle for the Kernel to release"
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xKernelSetArgPointer."
class: $xKernel
name: $x_kernel_arg_pointer_properties_t
base: $x_base_properties_t
members: []
--- #--------------------------------------------------------------------------
type: function
desc: "Set a USM pointer as the argument value of a Kernel."
class: $xKernel
Expand All @@ -308,13 +315,23 @@ params:
- type: "uint32_t"
name: argIndex
desc: "[in] argument index in range [0, num args - 1]"
- type: "const $x_kernel_arg_pointer_properties_t*"
name: pProperties
desc: "[in][optional] pointer to USM pointer properties."
- type: "const void*"
name: pArgValue
desc: "[in][optional] USM pointer to memory location holding the argument value. If null then argument value is considered null."
returns:
- $X_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX
- $X_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xKernelSetExecInfo."
class: $xKernel
name: $x_kernel_exec_info_properties_t
base: $x_base_properties_t
members: []
--- #--------------------------------------------------------------------------
type: function
desc: "Set additional Kernel execution attributes."
class: $xKernel
Expand All @@ -334,10 +351,20 @@ params:
- type: "size_t"
name: propSize
desc: "[in] size in byte the attribute value"
- type: "const $x_kernel_exec_info_properties_t*"
name: pProperties
desc: "[in][optional] pointer to execution info properties."
- type: "const void*"
name: pPropValue
desc: "[in][typename(propName, propSize)] pointer to memory location holding the property value."
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xKernelSetArgSampler."
class: $xKernel
name: $x_kernel_arg_sampler_properties_t
base: $x_base_properties_t
members: []
--- #--------------------------------------------------------------------------
type: function
desc: "Set a Sampler object as the argument value of a Kernel."
class: $xKernel
Expand All @@ -352,6 +379,9 @@ params:
- type: "uint32_t"
name: argIndex
desc: "[in] argument index in range [0, num args - 1]"
- type: "const $x_kernel_arg_sampler_properties_t*"
name: pProperties
desc: "[in][optional] pointer to sampler properties."
- type: "$x_sampler_handle_t"
name: hArgValue
desc: "[in] handle of Sampler object."
Expand Down
13 changes: 10 additions & 3 deletions source/adapters/null/ur_nullddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelRelease(
__urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
const ur_kernel_arg_pointer_properties_t
*pProperties, ///< [in][optional] pointer to USM pointer properties.
const void *
pArgValue ///< [in][optional] USM pointer to memory location holding the argument
///< value. If null then argument value is considered null.
Expand All @@ -2164,7 +2166,7 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetArgPointer(
// if the driver has created a custom function, then call it instead of using the generic path
auto pfnSetArgPointer = d_context.urDdiTable.Kernel.pfnSetArgPointer;
if (nullptr != pfnSetArgPointer) {
result = pfnSetArgPointer(hKernel, argIndex, pArgValue);
result = pfnSetArgPointer(hKernel, argIndex, pProperties, pArgValue);
} else {
// generic implementation
}
Expand All @@ -2180,6 +2182,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
ur_kernel_exec_info_t propName, ///< [in] name of the execution attribute
size_t propSize, ///< [in] size in byte the attribute value
const ur_kernel_exec_info_properties_t
*pProperties, ///< [in][optional] pointer to execution info properties.
const void *
pPropValue ///< [in][typename(propName, propSize)] pointer to memory location holding
///< the property value.
Expand All @@ -2189,7 +2193,8 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo(
// if the driver has created a custom function, then call it instead of using the generic path
auto pfnSetExecInfo = d_context.urDdiTable.Kernel.pfnSetExecInfo;
if (nullptr != pfnSetExecInfo) {
result = pfnSetExecInfo(hKernel, propName, propSize, pPropValue);
result = pfnSetExecInfo(hKernel, propName, propSize, pProperties,
pPropValue);
} else {
// generic implementation
}
Expand All @@ -2204,14 +2209,16 @@ __urdlllocal ur_result_t UR_APICALL urKernelSetExecInfo(
__urdlllocal ur_result_t UR_APICALL urKernelSetArgSampler(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object
uint32_t argIndex, ///< [in] argument index in range [0, num args - 1]
const ur_kernel_arg_sampler_properties_t
*pProperties, ///< [in][optional] pointer to sampler properties.
ur_sampler_handle_t hArgValue ///< [in] handle of Sampler object.
) try {
ur_result_t result = UR_RESULT_SUCCESS;

// if the driver has created a custom function, then call it instead of using the generic path
auto pfnSetArgSampler = d_context.urDdiTable.Kernel.pfnSetArgSampler;
if (nullptr != pfnSetArgSampler) {
result = pfnSetArgSampler(hKernel, argIndex, hArgValue);
result = pfnSetArgSampler(hKernel, argIndex, pProperties, hArgValue);
} else {
// generic implementation
}
Expand Down
Loading

0 comments on commit 0af3f18

Please sign in to comment.