Skip to content

Commit

Permalink
Add ability to query command-buffer updatable property
Browse files Browse the repository at this point in the history
  • Loading branch information
Bensuo committed Sep 26, 2024
1 parent e601a8c commit a007ed8
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -8174,6 +8174,8 @@ typedef enum ur_exp_command_buffer_info_t {
///< The reference count returned should be considered immediately stale.
///< It is unsuitable for general use in applications. This feature is
///< provided for identifying memory leaks.
UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE = 1, ///< [::ur_bool_t] Returns the value of ::ur_exp_command_buffer_desc_t::isUpdatable
///< that the command-buffer was created with.
/// @cond
UR_EXP_COMMAND_BUFFER_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand Down Expand Up @@ -8960,7 +8962,7 @@ urCommandBufferUpdateKernelLaunchExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hCommandBuffer`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
15 changes: 15 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9709,6 +9709,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_exp_command_buffer_inf
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
os << "UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT";
break;
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE:
os << "UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -9737,6 +9740,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_exp_command

os << ")";
} break;
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
default:
os << "unknown enumerator";
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
1 change: 1 addition & 0 deletions scripts/core/EXP-COMMAND-BUFFER.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ Enums
* ${X}_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP
* ${x}_exp_command_buffer_info_t
* ${X}_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT
* ${X}_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE
* ${x}_exp_command_buffer_command_info_t
* ${X}_EXP_COMMAND_BUFFER_COMMAND_INFO_REFERENCE_COUNT

Expand Down
4 changes: 4 additions & 0 deletions scripts/core/exp-command-buffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ etors:
[uint32_t] Reference count of the command-buffer object.
The reference count returned should be considered immediately stale.
It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
- name: IS_UPDATABLE
desc: |
[$x_bool_t] Returns the value of $x_exp_command_buffer_desc_t::isUpdatable
that the command-buffer was created with.
--- #--------------------------------------------------------------------------
type: enum
desc: "Command-buffer command query information type"
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/cuda/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
switch (propName) {
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
return ReturnValue(hCommandBuffer->getExternalReferenceCount());
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE:
return ReturnValue(hCommandBuffer->IsUpdatable);
default:
assert(!"Command-buffer info request not implemented");
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/hip/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
switch (propName) {
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
return ReturnValue(hCommandBuffer->getExternalReferenceCount());
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE:
return ReturnValue(hCommandBuffer->IsUpdatable);
default:
assert(!"Command-buffer info request not implemented");
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/level_zero/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,8 @@ urCommandBufferGetInfoExp(ur_exp_command_buffer_handle_t hCommandBuffer,
switch (propName) {
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
return ReturnValue(uint32_t{hCommandBuffer->RefCount.load()});
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE:
return ReturnValue(hCommandBuffer->IsUpdatable);
default:
assert(!"Command-buffer info request not implemented");
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/opencl/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
switch (propName) {
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
return ReturnValue(hCommandBuffer->getExternalReferenceCount());
case UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE:
return ReturnValue(hCommandBuffer->IsUpdatable);
default:
assert(!"Command-buffer info request not implemented");
}
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8979,7 +8979,7 @@ __urdlllocal ur_result_t UR_APICALL urCommandBufferGetInfoExp(
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
}

if (UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT < propName) {
if (UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE < propName) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

Expand Down
2 changes: 1 addition & 1 deletion source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8346,7 +8346,7 @@ ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hCommandBuffer`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7051,7 +7051,7 @@ ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hCommandBuffer`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_EXP_COMMAND_BUFFER_INFO_IS_UPDATABLE < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down

0 comments on commit a007ed8

Please sign in to comment.