Skip to content

Commit

Permalink
Merge pull request #1442 from Bensuo/ben/optimize-cmdbuffer-submission
Browse files Browse the repository at this point in the history
[EXP][Command-Buffer] Optimize L0 command buffer submission
  • Loading branch information
kbenzie committed Apr 26, 2024
2 parents cb44d9a + bb45b7c commit 7371150
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 245 deletions.
39 changes: 27 additions & 12 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7979,6 +7979,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 @@ -8183,7 +8186,8 @@ urCommandBufferAppendKernelLaunchExp(
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
const size_t *pLocalWorkSize, ///< [in][optional] 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 @@ -8219,7 +8223,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 @@ -8258,7 +8263,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 @@ -8291,7 +8297,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 @@ -8324,7 +8331,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 @@ -8357,7 +8365,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 @@ -8394,7 +8403,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 @@ -8435,7 +8445,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 @@ -8475,7 +8486,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 @@ -8511,7 +8523,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 @@ -8552,7 +8565,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 @@ -8593,7 +8607,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 7371150

Please sign in to comment.