Skip to content

Commit

Permalink
[EXP][Command-Buffer] Optimize L0 command buffer submission
Browse files Browse the repository at this point in the history
- Adds command buffer property to explicitly enable profiling
- Add ability to enforce use of in-order command lists
  • Loading branch information
mfrancepillois authored and Bensuo committed Apr 2, 2024
1 parent 3a7d00f commit 3cce4c0
Show file tree
Hide file tree
Showing 15 changed files with 494 additions and 242 deletions.
39 changes: 27 additions & 12 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7948,6 +7948,9 @@ typedef struct ur_exp_command_buffer_desc_t {
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC
const void *pNext; ///< [in][optional] pointer to extension-specific structure
ur_bool_t isUpdatable; ///< [in] Commands in a finalized command-buffer can be updated.
ur_bool_t isInOrder; ///< [in] Commands in a command-buffer may be executed in-order without
///< explicit dependencies.
ur_bool_t enableProfiling; ///< [in] Command-buffer profiling is enabled.

} ur_exp_command_buffer_desc_t;

Expand Down Expand Up @@ -8165,7 +8168,8 @@ urCommandBufferAppendKernelLaunchExp(
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
const size_t *pLocalWorkSize, ///< [in] Local work size to use when executing kernel.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint, ///< [out][optional] Sync point associated with this command.
ur_exp_command_buffer_command_handle_t *phCommand ///< [out][optional] Handle to this command.
);
Expand Down Expand Up @@ -8201,7 +8205,8 @@ urCommandBufferAppendUSMMemcpyExp(
const void *pSrc, ///< [in] The data to be copied.
size_t size, ///< [in] The number of bytes to copy.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8240,7 +8245,8 @@ urCommandBufferAppendUSMFillExp(
size_t patternSize, ///< [in] size in bytes of the pattern.
size_t size, ///< [in] fill size in bytes, must be a multiple of patternSize.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
);

Expand Down Expand Up @@ -8273,7 +8279,8 @@ urCommandBufferAppendMemBufferCopyExp(
size_t dstOffset, ///< [in] Offset into the destination memory
size_t size, ///< [in] The number of bytes to be copied.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8306,7 +8313,8 @@ urCommandBufferAppendMemBufferWriteExp(
size_t size, ///< [in] Size in bytes of data being written.
const void *pSrc, ///< [in] Pointer to host memory where data is to be written from.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8339,7 +8347,8 @@ urCommandBufferAppendMemBufferReadExp(
size_t size, ///< [in] Size in bytes of data being written.
void *pDst, ///< [in] Pointer to host memory where data is to be written to.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8376,7 +8385,8 @@ urCommandBufferAppendMemBufferCopyRectExp(
size_t dstRowPitch, ///< [in] Row pitch of the destination memory.
size_t dstSlicePitch, ///< [in] Slice pitch of the destination memory.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8417,7 +8427,8 @@ urCommandBufferAppendMemBufferWriteRectExp(
///< pointed to by pSrc.
void *pSrc, ///< [in] Pointer to host memory where data is to be written from.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8457,7 +8468,8 @@ urCommandBufferAppendMemBufferReadRectExp(
///< pointed to by pDst.
void *pDst, ///< [in] Pointer to host memory where data is to be read into.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
);

Expand Down Expand Up @@ -8493,7 +8505,8 @@ urCommandBufferAppendMemBufferFillExp(
size_t offset, ///< [in] offset into the buffer.
size_t size, ///< [in] fill size in bytes, must be a multiple of patternSize.
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
);

Expand Down Expand Up @@ -8534,7 +8547,8 @@ urCommandBufferAppendUSMPrefetchExp(
size_t size, ///< [in] size in bytes to be fetched.
ur_usm_migration_flags_t flags, ///< [in] USM prefetch flags
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
);

Expand Down Expand Up @@ -8575,7 +8589,8 @@ urCommandBufferAppendUSMAdviseExp(
size_t size, ///< [in] size in bytes to be advised.
ur_usm_advice_flags_t advice, ///< [in] USM memory advice
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
///< be ignored if command-buffer is in-order.
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
);

Expand Down
10 changes: 10 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9410,6 +9410,16 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu

os << (params.isUpdatable);

os << ", ";
os << ".isInOrder = ";

os << (params.isInOrder);

os << ", ";
os << ".enableProfiling = ";

os << (params.enableProfiling);

os << "}";
return os;
}
Expand Down
11 changes: 8 additions & 3 deletions scripts/core/EXP-COMMAND-BUFFER.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ Command-Buffer Creation
Command-Buffers are tied to a specific ${x}_context_handle_t and
${x}_device_handle_t. ${x}CommandBufferCreateExp optionally takes a descriptor
to provide additional properties for how the command-buffer should be
constructed. The only unique member defined in ${x}_exp_command_buffer_desc_t
is ``isUpdatable``, which should be set to ``true`` to support :ref:`updating
constructed. The members defined in ${x}_exp_command_buffer_desc_t are:
* ``isUpdatable``, which should be set to ``true`` to support :ref:`updating
command-buffer commands`.
* ``isInOrder``, which should be set to ``true`` to enable commands enqueued to
a command-buffer to be executed in an in-order fashion where possible.
* ``enableProfiling``, which should be set to ``true`` to enable profiling of
the command-buffer.

Command-buffers are reference counted and can be retained and released by
calling ${x}CommandBufferRetainExp and ${x}CommandBufferReleaseExp respectively.
Expand Down Expand Up @@ -123,7 +127,8 @@ Sync-Points
A sync-point is a value which represents a command inside of a command-buffer
which is returned from command-buffer append function calls. These can be
optionally passed to these functions to define execution dependencies on other
commands within the command-buffer.
commands within the command-buffer. Sync-points passed to functions may be
ignored if the command-buffer was created in-order.

Sync-points are unique and valid for use only within the command-buffer they
were obtained from.
Expand Down
Loading

0 comments on commit 3cce4c0

Please sign in to comment.