Skip to content

Commit 7371150

Browse files
authored
Merge pull request #1442 from Bensuo/ben/optimize-cmdbuffer-submission
[EXP][Command-Buffer] Optimize L0 command buffer submission
2 parents cb44d9a + bb45b7c commit 7371150

File tree

14 files changed

+502
-245
lines changed

14 files changed

+502
-245
lines changed

include/ur_api.h

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7979,6 +7979,9 @@ typedef struct ur_exp_command_buffer_desc_t {
79797979
///< ::UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC
79807980
const void *pNext; ///< [in][optional] pointer to extension-specific structure
79817981
ur_bool_t isUpdatable; ///< [in] Commands in a finalized command-buffer can be updated.
7982+
ur_bool_t isInOrder; ///< [in] Commands in a command-buffer may be executed in-order without
7983+
///< explicit dependencies.
7984+
ur_bool_t enableProfiling; ///< [in] Command-buffer profiling is enabled.
79827985

79837986
} ur_exp_command_buffer_desc_t;
79847987

@@ -8183,7 +8186,8 @@ urCommandBufferAppendKernelLaunchExp(
81838186
const size_t *pGlobalWorkSize, ///< [in] Global work size to use when executing kernel.
81848187
const size_t *pLocalWorkSize, ///< [in][optional] Local work size to use when executing kernel.
81858188
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8186-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8189+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8190+
///< be ignored if command-buffer is in-order.
81878191
ur_exp_command_buffer_sync_point_t *pSyncPoint, ///< [out][optional] Sync point associated with this command.
81888192
ur_exp_command_buffer_command_handle_t *phCommand ///< [out][optional] Handle to this command.
81898193
);
@@ -8219,7 +8223,8 @@ urCommandBufferAppendUSMMemcpyExp(
82198223
const void *pSrc, ///< [in] The data to be copied.
82208224
size_t size, ///< [in] The number of bytes to copy.
82218225
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8222-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8226+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8227+
///< be ignored if command-buffer is in-order.
82238228
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
82248229
);
82258230

@@ -8258,7 +8263,8 @@ urCommandBufferAppendUSMFillExp(
82588263
size_t patternSize, ///< [in] size in bytes of the pattern.
82598264
size_t size, ///< [in] fill size in bytes, must be a multiple of patternSize.
82608265
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8261-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8266+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8267+
///< be ignored if command-buffer is in-order.
82628268
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
82638269
);
82648270

@@ -8291,7 +8297,8 @@ urCommandBufferAppendMemBufferCopyExp(
82918297
size_t dstOffset, ///< [in] Offset into the destination memory
82928298
size_t size, ///< [in] The number of bytes to be copied.
82938299
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8294-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8300+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8301+
///< be ignored if command-buffer is in-order.
82958302
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
82968303
);
82978304

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

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

@@ -8394,7 +8403,8 @@ urCommandBufferAppendMemBufferCopyRectExp(
83948403
size_t dstRowPitch, ///< [in] Row pitch of the destination memory.
83958404
size_t dstSlicePitch, ///< [in] Slice pitch of the destination memory.
83968405
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8397-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8406+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8407+
///< be ignored if command-buffer is in-order.
83988408
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
83998409
);
84008410

@@ -8435,7 +8445,8 @@ urCommandBufferAppendMemBufferWriteRectExp(
84358445
///< pointed to by pSrc.
84368446
void *pSrc, ///< [in] Pointer to host memory where data is to be written from.
84378447
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8438-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8448+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8449+
///< be ignored if command-buffer is in-order.
84398450
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
84408451
);
84418452

@@ -8475,7 +8486,8 @@ urCommandBufferAppendMemBufferReadRectExp(
84758486
///< pointed to by pDst.
84768487
void *pDst, ///< [in] Pointer to host memory where data is to be read into.
84778488
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8478-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8489+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8490+
///< be ignored if command-buffer is in-order.
84798491
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] Sync point associated with this command.
84808492
);
84818493

@@ -8511,7 +8523,8 @@ urCommandBufferAppendMemBufferFillExp(
85118523
size_t offset, ///< [in] offset into the buffer.
85128524
size_t size, ///< [in] fill size in bytes, must be a multiple of patternSize.
85138525
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8514-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8526+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8527+
///< be ignored if command-buffer is in-order.
85158528
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
85168529
);
85178530

@@ -8552,7 +8565,8 @@ urCommandBufferAppendUSMPrefetchExp(
85528565
size_t size, ///< [in] size in bytes to be fetched.
85538566
ur_usm_migration_flags_t flags, ///< [in] USM prefetch flags
85548567
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8555-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8568+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8569+
///< be ignored if command-buffer is in-order.
85568570
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
85578571
);
85588572

@@ -8593,7 +8607,8 @@ urCommandBufferAppendUSMAdviseExp(
85938607
size_t size, ///< [in] size in bytes to be advised.
85948608
ur_usm_advice_flags_t advice, ///< [in] USM memory advice
85958609
uint32_t numSyncPointsInWaitList, ///< [in] The number of sync points in the provided dependency list.
8596-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on.
8610+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList, ///< [in][optional] A list of sync points that this command depends on. May
8611+
///< be ignored if command-buffer is in-order.
85978612
ur_exp_command_buffer_sync_point_t *pSyncPoint ///< [out][optional] sync point associated with this command.
85988613
);
85998614

include/ur_print.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9496,6 +9496,16 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_command_bu
94969496

94979497
os << (params.isUpdatable);
94989498

9499+
os << ", ";
9500+
os << ".isInOrder = ";
9501+
9502+
os << (params.isInOrder);
9503+
9504+
os << ", ";
9505+
os << ".enableProfiling = ";
9506+
9507+
os << (params.enableProfiling);
9508+
94999509
os << "}";
95009510
return os;
95019511
}

scripts/core/EXP-COMMAND-BUFFER.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ Command-Buffer Creation
7777
Command-Buffers are tied to a specific ${x}_context_handle_t and
7878
${x}_device_handle_t. ${x}CommandBufferCreateExp optionally takes a descriptor
7979
to provide additional properties for how the command-buffer should be
80-
constructed. The only unique member defined in ${x}_exp_command_buffer_desc_t
81-
is ``isUpdatable``, which should be set to ``true`` to support :ref:`updating
80+
constructed. The members defined in ${x}_exp_command_buffer_desc_t are:
81+
* ``isUpdatable``, which should be set to ``true`` to support :ref:`updating
8282
command-buffer commands`.
83+
* ``isInOrder``, which should be set to ``true`` to enable commands enqueued to
84+
a command-buffer to be executed in an in-order fashion where possible.
85+
* ``enableProfiling``, which should be set to ``true`` to enable profiling of
86+
the command-buffer.
8387

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

128133
Sync-points are unique and valid for use only within the command-buffer they
129134
were obtained from.

0 commit comments

Comments
 (0)