Skip to content

Commit

Permalink
Add conformance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanC committed Dec 21, 2023
1 parent ee4c23d commit 3f5d484
Show file tree
Hide file tree
Showing 31 changed files with 1,378 additions and 99 deletions.
48 changes: 30 additions & 18 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ typedef enum ur_structure_type_t {
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC = 0x1001, ///< ::ur_exp_command_buffer_update_kernel_launch_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC = 0x1002, ///< ::ur_exp_command_buffer_update_memobj_arg_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC = 0x1003, ///< ::ur_exp_command_buffer_update_pointer_arg_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC = 0x1004, ///< ::ur_exp_command_buffer_update_exec_info_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC = 0x1004, ///< ::ur_exp_command_buffer_update_value_arg_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC = 0x1005, ///< ::ur_exp_command_buffer_update_exec_info_desc_t
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t
UR_STRUCTURE_TYPE_EXP_INTEROP_SEMAPHORE_DESC = 0x2002, ///< ::ur_exp_interop_semaphore_desc_t
Expand Down Expand Up @@ -7798,6 +7799,19 @@ typedef struct ur_exp_command_buffer_update_pointer_arg_desc_t {

} ur_exp_command_buffer_update_pointer_arg_desc_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Descriptor type for updating a kernel command value argument.
typedef struct ur_exp_command_buffer_update_value_arg_desc_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC
const void *pNext; ///< [in][optional] pointer to extension-specific structure
uint32_t argIndex; ///< [in] Argument index.
uint32_t argSize; ///< [in] Argument size.
const ur_kernel_arg_value_properties_t *pProperties; ///< [in][optinal] Pointer to memory object properties.
const void *pArgValue; ///< [in][optional] Argument value representing kernel arg type.

} ur_exp_command_buffer_update_value_arg_desc_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Descriptor type for updating kernel command execution info.
typedef struct ur_exp_command_buffer_update_exec_info_desc_t {
Expand All @@ -7819,20 +7833,24 @@ typedef struct ur_exp_command_buffer_update_kernel_launch_desc_t {
const void *pNext; ///< [in][optional] pointer to extension-specific structure
uint32_t numMemobjArgs; ///< [in] Length of pArgMemobjList.
uint32_t numPointerArgs; ///< [in] Length of pArgPointerList.
uint32_t numValueArgs; ///< [in] Length of pArgValueList.
uint32_t numExecInfos; ///< [in] Length of pExecInfoList.
uint32_t workDim; ///< [in] Number of work dimensions in the kernel ND-range, from 1-3.
const ur_exp_command_buffer_update_memobj_arg_desc_t *pArgMemobjList; ///< [in] An array describing the new kernel mem obj arguments for the
///< command.
const ur_exp_command_buffer_update_pointer_arg_desc_t *pArgPointerList; ///< [in] An array describing the new kernel pointer arguments for the
const ur_exp_command_buffer_update_memobj_arg_desc_t *pArgMemobjList; ///< [in][optional][range(0, numMemobjArgs)] An array describing the new
///< kernel mem obj arguments for the command.
const ur_exp_command_buffer_update_pointer_arg_desc_t *pArgPointerList; ///< [in][optional][range(0, numPointerArgs)] An array describing the new
///< kernel pointer arguments for the command.
const ur_exp_command_buffer_update_value_arg_desc_t *pArgValueList; ///< [in][optional][range(0, numValueArgs)]An array describing the new
///< kernel value arguments for the command.
const ur_exp_command_buffer_update_exec_info_desc_t *pArgExecInfoList; ///< [in][optional] An array describing the execution info objects for the
///< command.
const ur_exp_command_buffer_update_exec_info_desc_t *pArgExecInfoList; ///< [in] An array describing the execution info objects for the command.
size_t *pGlobalWorkOffset; ///< [in] Array of workDim unsigned values that describe the offset used to
///< calculate the global ID.
size_t *pGlobalWorkSize; ///< [in] Array of workDim unsigned values that describe the number of
///< global work-items.
size_t *pLocalWorkSize; ///< [in] Array of workDim unsigned values that describe the number of
///< work-items that make up a work-group. If nullptr, the runtime
///< implementation will choose the work-group size.
size_t *pGlobalWorkOffset; ///< [in][optional][range(0, workDim)] Array of workDim unsigned values
///< that describe the offset used to calculate the global ID.
size_t *pGlobalWorkSize; ///< [in][optional][range(0, workDim)] Array of workDim unsigned values
///< that describe the number of global work-items.
size_t *pLocalWorkSize; ///< [in][optional][range(0, workDim)] Array of workDim unsigned values
///< that describe the number of work-items that make up a work-group. If
///< nullptr, the runtime implementation will choose the work-group size.

} ur_exp_command_buffer_update_kernel_launch_desc_t;

Expand Down Expand Up @@ -8426,12 +8444,6 @@ urCommandBufferEnqueueExp(
/// + `NULL == hCommand`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pUpdateKernelLaunch`
/// + `NULL == pUpdateKernelLaunch->pArgMemobjList`
/// + `NULL == pUpdateKernelLaunch->pArgPointerList`
/// + `NULL == pUpdateKernelLaunch->pArgExecInfoList`
/// + `NULL == pUpdateKernelLaunch->pGlobalWorkOffset`
/// + `NULL == pUpdateKernelLaunch->pGlobalWorkSize`
/// + `NULL == pUpdateKernelLaunch->pLocalWorkSize`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If update functionality is not supported by the device.
/// - ::UR_RESULT_ERROR_INVALID_OPERATION
Expand Down
120 changes: 105 additions & 15 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_memobj_arg_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_pointer_arg_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_value_arg_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_exec_info_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_command_buffer_update_kernel_launch_desc_t params);
inline std::ostream &operator<<(std::ostream &os, ur_exp_peer_info_t value);
Expand Down Expand Up @@ -1017,6 +1018,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_structure_type_t value) {
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC:
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_POINTER_ARG_DESC";
break;
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC:
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC";
break;
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC:
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC";
break;
Expand Down Expand Up @@ -1250,6 +1254,11 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
printPtr(os, pstruct);
} break;

case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC: {
const ur_exp_command_buffer_update_value_arg_desc_t *pstruct = (const ur_exp_command_buffer_update_value_arg_desc_t *)ptr;
printPtr(os, pstruct);
} break;

case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_EXEC_INFO_DESC: {
const ur_exp_command_buffer_update_exec_info_desc_t *pstruct = (const ur_exp_command_buffer_update_exec_info_desc_t *)ptr;
printPtr(os, pstruct);
Expand Down Expand Up @@ -9291,6 +9300,46 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_exp_command_buffer_update_value_arg_desc_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_buffer_update_value_arg_desc_t params) {
os << "(struct ur_exp_command_buffer_update_value_arg_desc_t){";

os << ".stype = ";

os << (params.stype);

os << ", ";
os << ".pNext = ";

ur::details::printStruct(os,
(params.pNext));

os << ", ";
os << ".argIndex = ";

os << (params.argIndex);

os << ", ";
os << ".argSize = ";

os << (params.argSize);

os << ", ";
os << ".pProperties = ";

os << (params.pProperties);

os << ", ";
os << ".pArgValue = ";

os << (params.pArgValue);

os << "}";
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_exp_command_buffer_update_exec_info_desc_t type
/// @returns
/// std::ostream &
Expand Down Expand Up @@ -9357,6 +9406,11 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu

os << (params.numPointerArgs);

os << ", ";
os << ".numValueArgs = ";

os << (params.numValueArgs);

os << ", ";
os << ".numExecInfos = ";

Expand All @@ -9368,16 +9422,37 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
os << (params.workDim);

os << ", ";
os << ".pArgMemobjList = ";
os << ".pArgMemobjList = {";
for (size_t i = 0; (params.pArgMemobjList) != NULL && i < params.numMemobjArgs; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os,
(params.pArgMemobjList));
os << ((params.pArgMemobjList))[i];
}
os << "}";

os << ", ";
os << ".pArgPointerList = ";
os << ".pArgPointerList = {";
for (size_t i = 0; (params.pArgPointerList) != NULL && i < params.numPointerArgs; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os,
(params.pArgPointerList));
os << ((params.pArgPointerList))[i];
}
os << "}";

os << ", ";
os << ".pArgValueList = {";
for (size_t i = 0; (params.pArgValueList) != NULL && i < params.numValueArgs; ++i) {
if (i != 0) {
os << ", ";
}

os << ((params.pArgValueList))[i];
}
os << "}";

os << ", ";
os << ".pArgExecInfoList = ";
Expand All @@ -9386,22 +9461,37 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
(params.pArgExecInfoList));

os << ", ";
os << ".pGlobalWorkOffset = ";
os << ".pGlobalWorkOffset = {";
for (size_t i = 0; (params.pGlobalWorkOffset) != NULL && i < params.workDim; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os,
(params.pGlobalWorkOffset));
os << ((params.pGlobalWorkOffset))[i];
}
os << "}";

os << ", ";
os << ".pGlobalWorkSize = ";
os << ".pGlobalWorkSize = {";
for (size_t i = 0; (params.pGlobalWorkSize) != NULL && i < params.workDim; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os,
(params.pGlobalWorkSize));
os << ((params.pGlobalWorkSize))[i];
}
os << "}";

os << ", ";
os << ".pLocalWorkSize = ";
os << ".pLocalWorkSize = {";
for (size_t i = 0; (params.pLocalWorkSize) != NULL && i < params.workDim; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os,
(params.pLocalWorkSize));
os << ((params.pLocalWorkSize))[i];
}
os << "}";

os << "}";
return os;
Expand Down
12 changes: 8 additions & 4 deletions scripts/core/EXP-COMMAND-BUFFER.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ support updating the configuration of kernel commands recorded to a
command-buffer. Support of this is reported by returning true in the
${X}_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP query.

Updating a kernel commands is done by passing the new kernel configuration
Updating kernel commands is done by passing the new kernel configuration
to ${x}CommandBufferUpdateKernelLaunchExp along with the command handle of
the kernel command to update. Configurations that can be changed are the
kernels ND-Range and parameters.
Expand All @@ -178,11 +178,12 @@ kernels ND-Range and parameters.
nullptr,
true
};
${x}_exp_command_buffer_command_handle_t handle;
${x}_exp_command_buffer_handle_t hCommandBuffer;
${x}CommandBufferCreateExp(hContext, hDevice, &desc, &handle);
// Append a kernel command which has two buffer parameters, an input
// and an output.
${x}_exp_command_buffer_command_handle_t handle;
${x}CommandBufferAppendKernelLaunchExp(hCommandBuffer, hKernel, workDim,
pGlobalWorkOffset, pGlobalWorkSize,
pLocalWorkSize, 0, nullptr,
Expand All @@ -193,7 +194,7 @@ kernels ND-Range and parameters.
// Define kernel argument at index 0 to be a new input buffer object
${x}_exp_command_buffer_update_memobj_arg_desc_t newInputArg {
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG, // stype
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC, // stype
nullptr, // pNext,
0, // argIndex,
nullptr, // pProperties
Expand All @@ -202,7 +203,7 @@ kernels ND-Range and parameters.
// Define kernel argument at index 1 to be a new output buffer object
${x}_exp_command_buffer_update_memobj_arg_desc_t newOutputArg {
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG, // stype
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_MEMOBJ_ARG_DESC, // stype
nullptr, // pNext,
1, // argIndex,
nullptr, // pProperties
Expand All @@ -216,10 +217,12 @@ kernels ND-Range and parameters.
nullptr, // pNext
2, // numMemobjArgs
0, // numPointerArgs
0, // numValueArgs
0, // numExecInfos
0, // workDim;
new_args, // pArgMemobjList
nullptr, // pArgPointerList
nullptr, // pArgValueList
nullptr, // pArgExecInfoList
nullptr, // pGlobalWorkOffset
nullptr, // pGlobalWorkSize
Expand Down Expand Up @@ -331,3 +334,4 @@ Contributors
* Ben Tracy `ben.tracy@codeplay.com <ben.tracy@codeplay.com>`_
* Ewan Crawford `ewan@codeplay.com <ewan@codeplay.com>`_
* Maxime France-Pillois `maxime.francepillois@codeplay.com <maxime.francepillois@codeplay.com>`_
* Aaron Greig `aaron.greig@codeplay.com <aaron.greig@codeplay.com>`_
Loading

0 comments on commit 3f5d484

Please sign in to comment.