Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UR] Add extensibility to the rest of kernelSet* entrypoints #645

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ 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
KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t
KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_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 @@ -1499,6 +1504,24 @@ class ur_program_native_properties_t(Structure):
## transfer the ownership to the unified-runtime.
]

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

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

###############################################################################
## @brief Get Kernel object information
class ur_kernel_info_v(IntEnum):
Expand Down Expand Up @@ -1574,6 +1597,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 @@ -2452,37 +2502,37 @@ class ur_program_dditable_t(Structure):
###############################################################################
## @brief Function-pointer for urKernelSetArgValue
if __use_win_types:
_urKernelSetArgValue_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, c_void_p )
_urKernelSetArgValue_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, POINTER(ur_kernel_arg_value_properties_t), c_void_p )
else:
_urKernelSetArgValue_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, c_void_p )
_urKernelSetArgValue_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, POINTER(ur_kernel_arg_value_properties_t), c_void_p )

###############################################################################
## @brief Function-pointer for urKernelSetArgLocal
if __use_win_types:
_urKernelSetArgLocal_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t )
_urKernelSetArgLocal_t = WINFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, POINTER(ur_kernel_arg_local_properties_t) )
else:
_urKernelSetArgLocal_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t )
_urKernelSetArgLocal_t = CFUNCTYPE( ur_result_t, ur_kernel_handle_t, c_ulong, c_size_t, POINTER(ur_kernel_arg_local_properties_t) )

###############################################################################
## @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
98 changes: 79 additions & 19 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ 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_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_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 @@ -3829,6 +3834,15 @@ urKernelCreate(
ur_kernel_handle_t *phKernel ///< [out] pointer to handle of kernel object created.
);

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

} ur_kernel_arg_value_properties_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Set kernel argument to a value.
///
Expand All @@ -3849,12 +3863,22 @@ urKernelCreate(
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgValue(
ur_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] argument value represented as matching arg type.
ur_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 ur_kernel_arg_value_properties_t *pProperties, ///< [in][optional] pointer to value properties.
const void *pArgValue ///< [in] argument value represented as matching arg type.
);

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

} ur_kernel_arg_local_properties_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Set kernel argument to a local buffer.
///
Expand All @@ -3873,9 +3897,10 @@ urKernelSetArgValue(
/// - ::UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgLocal(
ur_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 the local buffer to be allocated by the runtime
ur_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 the local buffer to be allocated by the runtime
const ur_kernel_arg_local_properties_t *pProperties ///< [in][optional] pointer to local buffer properties.
);

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4094,6 +4119,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 +4150,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 +4190,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 +4225,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 @@ -7743,6 +7798,7 @@ typedef struct ur_kernel_set_arg_value_params_t {
ur_kernel_handle_t *phKernel;
uint32_t *pargIndex;
size_t *pargSize;
const ur_kernel_arg_value_properties_t **ppProperties;
const void **ppArgValue;
} ur_kernel_set_arg_value_params_t;

Expand All @@ -7754,6 +7810,7 @@ typedef struct ur_kernel_set_arg_local_params_t {
ur_kernel_handle_t *phKernel;
uint32_t *pargIndex;
size_t *pargSize;
const ur_kernel_arg_local_properties_t **ppProperties;
} ur_kernel_set_arg_local_params_t;

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -7763,6 +7820,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 +7832,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 +7843,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
Loading