Skip to content

Commit

Permalink
Add event update to command-buffers
Browse files Browse the repository at this point in the history
Expand the command-buffer experimental feature API so that
it can be used to implement [SYCL-Graph dynamic
events](reble/llvm#372).

This involves extending each command append entry-point to
include the following extra parameters:
  * An output `ur_exp_command_buffer_command_handle_t`.
  * An Input `ur_event_handle_t` event wait-list of dependent events.
  * An output `ur_event_handle_t` event that is signaled when the command
    completes its next execution.

New entry-points are also added to update the wait-list and signal event
parameters of commands:
  * `urCommandBufferUpdateSignalEventExp`
  * `urCommandBufferUpdateWaitEventsExp`

APIs implemented for CUDA adapter with CTS tests.
  • Loading branch information
EwanC committed Aug 29, 2024
1 parent 2f67b38 commit e5b5e72
Show file tree
Hide file tree
Showing 48 changed files with 7,111 additions and 577 deletions.
375 changes: 342 additions & 33 deletions include/ur_api.h

Large diffs are not rendered by default.

84 changes: 73 additions & 11 deletions include/ur_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,10 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendKernelLaunchExp_t)(
const size_t *,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -1945,7 +1948,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendUSMMemcpyExp_t)(
size_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendUSMFillExp
Expand All @@ -1957,7 +1964,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendUSMFillExp_t)(
size_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferCopyExp
Expand All @@ -1970,7 +1981,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferCopyExp_t)(
size_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferWriteExp
Expand All @@ -1982,7 +1997,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferWriteExp_t)(
const void *,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferReadExp
Expand All @@ -1994,7 +2013,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferReadExp_t)(
void *,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferCopyRectExp
Expand All @@ -2011,7 +2034,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferCopyRectExp_t)
size_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferWriteRectExp
Expand All @@ -2028,7 +2055,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferWriteRectExp_t
void *,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferReadRectExp
Expand All @@ -2045,7 +2076,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferReadRectExp_t)
void *,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendMemBufferFillExp
Expand All @@ -2058,7 +2093,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendMemBufferFillExp_t)(
size_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendUSMPrefetchExp
Expand All @@ -2069,7 +2108,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendUSMPrefetchExp_t)(
ur_usm_migration_flags_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferAppendUSMAdviseExp
Expand All @@ -2080,7 +2123,11 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferAppendUSMAdviseExp_t)(
ur_usm_advice_flags_t,
uint32_t,
const ur_exp_command_buffer_sync_point_t *,
ur_exp_command_buffer_sync_point_t *);
uint32_t,
const ur_event_handle_t *,
ur_exp_command_buffer_sync_point_t *,
ur_event_handle_t *,
ur_exp_command_buffer_command_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferEnqueueExp
Expand All @@ -2107,6 +2154,19 @@ typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferUpdateKernelLaunchExp_t)(
ur_exp_command_buffer_command_handle_t,
const ur_exp_command_buffer_update_kernel_launch_desc_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferUpdateSignalEventExp
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferUpdateSignalEventExp_t)(
ur_exp_command_buffer_command_handle_t,
ur_event_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferUpdateWaitEventsExp
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferUpdateWaitEventsExp_t)(
ur_exp_command_buffer_command_handle_t,
uint32_t,
const ur_event_handle_t *);

///////////////////////////////////////////////////////////////////////////////
/// @brief Function-pointer for urCommandBufferGetInfoExp
typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferGetInfoExp_t)(
Expand Down Expand Up @@ -2148,6 +2208,8 @@ typedef struct ur_command_buffer_exp_dditable_t {
ur_pfnCommandBufferRetainCommandExp_t pfnRetainCommandExp;
ur_pfnCommandBufferReleaseCommandExp_t pfnReleaseCommandExp;
ur_pfnCommandBufferUpdateKernelLaunchExp_t pfnUpdateKernelLaunchExp;
ur_pfnCommandBufferUpdateSignalEventExp_t pfnUpdateSignalEventExp;
ur_pfnCommandBufferUpdateWaitEventsExp_t pfnUpdateWaitEventsExp;
ur_pfnCommandBufferGetInfoExp_t pfnGetInfoExp;
ur_pfnCommandBufferCommandGetInfoExp_t pfnCommandGetInfoExp;
} ur_command_buffer_exp_dditable_t;
Expand Down
16 changes: 16 additions & 0 deletions include/ur_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferReleaseCommandExpParams(
/// - `buff_size < out_size`
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);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_command_buffer_update_signal_event_exp_params_t struct
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferUpdateSignalEventExpParams(const struct ur_command_buffer_update_signal_event_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_command_buffer_update_wait_events_exp_params_t struct
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL urPrintCommandBufferUpdateWaitEventsExpParams(const struct ur_command_buffer_update_wait_events_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_command_buffer_get_info_exp_params_t struct
/// @returns
Expand Down
Loading

0 comments on commit e5b5e72

Please sign in to comment.