Skip to content

Commit ba1006d

Browse files
committed
[EXP][Command-Buffer] Add kernel command update
This change introduces a new API that allows the kernel commands of a command-buffer to be updated with a new configuration. For example, modified arguments or ND-Range. The new API is defined in the following files and then source generated using scripts, so reviewers should look at: * `scripts/core/EXP-COMMAND-BUFFER.rst` * `scripts/core/exp-command-buffer.yml` See [cl_khr_command_buffer_mutable_dispatch](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_command_buffer_mutable_dispatch) as prior art. The differences between the proposed API and the above are: * Only the append kernel entry-point returns a command handle. I imagine this will be changed in future to enable other commands to do update. * USM, buffer, and scalar arguments can be updated, there is not equivalent update struct for `urKernelSetArgLocal` or `urKernelSetArgSampler` * There is no granularity of optional support for update, an implementer must either implement all the ways to update a kernel configuration, or none of them. * Command-handles are reference counted in UR, and extend the lifetime of the parent command-buffer. The CUDA adapter is the only adapter that currently implements this new feature, other adapters don't report support. This is because CUDA is already an adapter supported by UR command-buffers, and the CUDA API for updating nodes already exists as a non-optional feature. Reviewers should review the changes in `source/adapters/cuda/` to evaluate this, CTS tests are written to verify implementation, as there is not yet a DPC++ feature with testing to stress the code path (see reble/llvm#340 for how that feature could look). A new test directory has been created to test the command-buffer experimental feature, `test/conformance/exp_command_buffer`, which contains tests to stress using the feature defined by this extension so that it has code coverage. Reviewers should look at the new tests added here, and new device kernels in `test/conformance/device_code` to evaluate these changes.
1 parent 47102cb commit ba1006d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5891
-627
lines changed

include/ur_api.h

Lines changed: 420 additions & 106 deletions
Large diffs are not rendered by default.

include/ur_ddi.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,8 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendKernelLaunchExp_t)(
18541854
const size_t *,
18551855
uint32_t,
18561856
const ur_exp_command_buffer_sync_point_t *,
1857-
ur_exp_command_buffer_sync_point_t *);
1857+
ur_exp_command_buffer_sync_point_t *,
1858+
ur_exp_command_buffer_command_handle_t *);
18581859

18591860
///////////////////////////////////////////////////////////////////////////////
18601861
/// @brief Function-pointer for urCommandBufferAppendUSMMemcpyExp
@@ -2011,6 +2012,40 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferEnqueueExp_t)(
20112012
const ur_event_handle_t *,
20122013
ur_event_handle_t *);
20132014

2015+
///////////////////////////////////////////////////////////////////////////////
2016+
/// @brief Function-pointer for urCommandBufferRetainCommandExp
2017+
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferRetainCommandExp_t)(
2018+
ur_exp_command_buffer_command_handle_t);
2019+
2020+
///////////////////////////////////////////////////////////////////////////////
2021+
/// @brief Function-pointer for urCommandBufferReleaseCommandExp
2022+
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferReleaseCommandExp_t)(
2023+
ur_exp_command_buffer_command_handle_t);
2024+
2025+
///////////////////////////////////////////////////////////////////////////////
2026+
/// @brief Function-pointer for urCommandBufferUpdateKernelLaunchExp
2027+
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferUpdateKernelLaunchExp_t)(
2028+
ur_exp_command_buffer_command_handle_t,
2029+
const ur_exp_command_buffer_update_kernel_launch_desc_t *);
2030+
2031+
///////////////////////////////////////////////////////////////////////////////
2032+
/// @brief Function-pointer for urCommandBufferGetInfoExp
2033+
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferGetInfoExp_t)(
2034+
ur_exp_command_buffer_handle_t,
2035+
ur_exp_command_buffer_info_t,
2036+
size_t,
2037+
void *,
2038+
size_t *);
2039+
2040+
///////////////////////////////////////////////////////////////////////////////
2041+
/// @brief Function-pointer for urCommandBufferCommandGetInfoExp
2042+
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferCommandGetInfoExp_t)(
2043+
ur_exp_command_buffer_command_handle_t,
2044+
ur_exp_command_buffer_command_info_t,
2045+
size_t,
2046+
void *,
2047+
size_t *);
2048+
20142049
///////////////////////////////////////////////////////////////////////////////
20152050
/// @brief Table of CommandBufferExp functions pointers
20162051
typedef struct ur_command_buffer_exp_dditable_t {
@@ -2031,6 +2066,11 @@ typedef struct ur_command_buffer_exp_dditable_t {
20312066
ur_pfnCommandBufferAppendUSMPrefetchExp_t pfnAppendUSMPrefetchExp;
20322067
ur_pfnCommandBufferAppendUSMAdviseExp_t pfnAppendUSMAdviseExp;
20332068
ur_pfnCommandBufferEnqueueExp_t pfnEnqueueExp;
2069+
ur_pfnCommandBufferRetainCommandExp_t pfnRetainCommandExp;
2070+
ur_pfnCommandBufferReleaseCommandExp_t pfnReleaseCommandExp;
2071+
ur_pfnCommandBufferUpdateKernelLaunchExp_t pfnUpdateKernelLaunchExp;
2072+
ur_pfnCommandBufferGetInfoExp_t pfnGetInfoExp;
2073+
ur_pfnCommandBufferCommandGetInfoExp_t pfnCommandGetInfoExp;
20342074
} ur_command_buffer_exp_dditable_t;
20352075

20362076
///////////////////////////////////////////////////////////////////////////////

include/ur_print.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpInteropMemDesc(const struct ur_exp
930930
/// - `buff_size < out_size`
931931
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpInteropSemaphoreDesc(const struct ur_exp_interop_semaphore_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
932932

933+
///////////////////////////////////////////////////////////////////////////////
934+
/// @brief Print ur_exp_command_buffer_info_t enum
935+
/// @returns
936+
/// - ::UR_RESULT_SUCCESS
937+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
938+
/// - `buff_size < out_size`
939+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferInfo(enum ur_exp_command_buffer_info_t value, char *buffer, const size_t buff_size, size_t *out_size);
940+
941+
///////////////////////////////////////////////////////////////////////////////
942+
/// @brief Print ur_exp_command_buffer_command_info_t enum
943+
/// @returns
944+
/// - ::UR_RESULT_SUCCESS
945+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
946+
/// - `buff_size < out_size`
947+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferCommandInfo(enum ur_exp_command_buffer_command_info_t value, char *buffer, const size_t buff_size, size_t *out_size);
948+
933949
///////////////////////////////////////////////////////////////////////////////
934950
/// @brief Print ur_exp_command_buffer_desc_t struct
935951
/// @returns
@@ -938,6 +954,46 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpInteropSemaphoreDesc(const struct
938954
/// - `buff_size < out_size`
939955
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferDesc(const struct ur_exp_command_buffer_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
940956

957+
///////////////////////////////////////////////////////////////////////////////
958+
/// @brief Print ur_exp_command_buffer_update_memobj_arg_desc_t struct
959+
/// @returns
960+
/// - ::UR_RESULT_SUCCESS
961+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
962+
/// - `buff_size < out_size`
963+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateMemobjArgDesc(const struct ur_exp_command_buffer_update_memobj_arg_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
964+
965+
///////////////////////////////////////////////////////////////////////////////
966+
/// @brief Print ur_exp_command_buffer_update_pointer_arg_desc_t struct
967+
/// @returns
968+
/// - ::UR_RESULT_SUCCESS
969+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
970+
/// - `buff_size < out_size`
971+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdatePointerArgDesc(const struct ur_exp_command_buffer_update_pointer_arg_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
972+
973+
///////////////////////////////////////////////////////////////////////////////
974+
/// @brief Print ur_exp_command_buffer_update_value_arg_desc_t struct
975+
/// @returns
976+
/// - ::UR_RESULT_SUCCESS
977+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
978+
/// - `buff_size < out_size`
979+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateValueArgDesc(const struct ur_exp_command_buffer_update_value_arg_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
980+
981+
///////////////////////////////////////////////////////////////////////////////
982+
/// @brief Print ur_exp_command_buffer_update_exec_info_desc_t struct
983+
/// @returns
984+
/// - ::UR_RESULT_SUCCESS
985+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
986+
/// - `buff_size < out_size`
987+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateExecInfoDesc(const struct ur_exp_command_buffer_update_exec_info_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
988+
989+
///////////////////////////////////////////////////////////////////////////////
990+
/// @brief Print ur_exp_command_buffer_update_kernel_launch_desc_t struct
991+
/// @returns
992+
/// - ::UR_RESULT_SUCCESS
993+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
994+
/// - `buff_size < out_size`
995+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpCommandBufferUpdateKernelLaunchDesc(const struct ur_exp_command_buffer_update_kernel_launch_desc_t params, char *buffer, const size_t buff_size, size_t *out_size);
996+
941997
///////////////////////////////////////////////////////////////////////////////
942998
/// @brief Print ur_exp_peer_info_t enum
943999
/// @returns
@@ -2250,6 +2306,46 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferAppendUsmAdviseExpParams
22502306
/// - `buff_size < out_size`
22512307
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferEnqueueExpParams(const struct ur_command_buffer_enqueue_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
22522308

2309+
///////////////////////////////////////////////////////////////////////////////
2310+
/// @brief Print ur_command_buffer_retain_command_exp_params_t struct
2311+
/// @returns
2312+
/// - ::UR_RESULT_SUCCESS
2313+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2314+
/// - `buff_size < out_size`
2315+
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferRetainCommandExpParams(const struct ur_command_buffer_retain_command_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2316+
2317+
///////////////////////////////////////////////////////////////////////////////
2318+
/// @brief Print ur_command_buffer_release_command_exp_params_t struct
2319+
/// @returns
2320+
/// - ::UR_RESULT_SUCCESS
2321+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2322+
/// - `buff_size < out_size`
2323+
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferReleaseCommandExpParams(const struct ur_command_buffer_release_command_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2324+
2325+
///////////////////////////////////////////////////////////////////////////////
2326+
/// @brief Print ur_command_buffer_update_kernel_launch_exp_params_t struct
2327+
/// @returns
2328+
/// - ::UR_RESULT_SUCCESS
2329+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2330+
/// - `buff_size < out_size`
2331+
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferUpdateKernelLaunchExpParams(const struct ur_command_buffer_update_kernel_launch_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2332+
2333+
///////////////////////////////////////////////////////////////////////////////
2334+
/// @brief Print ur_command_buffer_get_info_exp_params_t struct
2335+
/// @returns
2336+
/// - ::UR_RESULT_SUCCESS
2337+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2338+
/// - `buff_size < out_size`
2339+
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferGetInfoExpParams(const struct ur_command_buffer_get_info_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2340+
2341+
///////////////////////////////////////////////////////////////////////////////
2342+
/// @brief Print ur_command_buffer_command_get_info_exp_params_t struct
2343+
/// @returns
2344+
/// - ::UR_RESULT_SUCCESS
2345+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2346+
/// - `buff_size < out_size`
2347+
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferCommandGetInfoExpParams(const struct ur_command_buffer_command_get_info_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2348+
22532349
///////////////////////////////////////////////////////////////////////////////
22542350
/// @brief Print ur_usm_p2p_enable_peer_access_exp_params_t struct
22552351
/// @returns

0 commit comments

Comments
 (0)