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 16, 2024
1 parent fe9a05e commit 2c56c47
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 @@ -7980,6 +7980,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 @@ -8197,7 +8200,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 @@ -8233,7 +8237,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 @@ -8272,7 +8277,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 @@ -8305,7 +8311,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 @@ -8338,7 +8345,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 @@ -8371,7 +8379,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 @@ -8408,7 +8417,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 @@ -8449,7 +8459,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 @@ -8489,7 +8500,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 @@ -8525,7 +8537,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 @@ -8566,7 +8579,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 @@ -8607,7 +8621,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 @@ -9496,6 +9496,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 2c56c47

Please sign in to comment.