Skip to content

Commit 8f2cc02

Browse files
committed
Make phEvent optional in urEnqueueNativeCommandExp
When using the valuation layer in the SYCL RT for intel/llvm#14145 it exposed an issue with `phEvent` not being optional in the `urEnqueueNativeCommandExp` entry point, however `nullptr` is passed to the argument in tests. This patch makes `phEvent` optional, in line with other enqueue entry points.
1 parent 9d3bce6 commit 8f2cc02

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

include/ur_api.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9570,7 +9570,6 @@ typedef void (*ur_exp_enqueue_native_command_function_t)(
95709570
/// + `NULL == hQueue`
95719571
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
95729572
/// + `NULL == pfnNativeEnqueue`
9573-
/// + `NULL == phEvent`
95749573
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
95759574
/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK & pProperties->flags`
95769575
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
@@ -9590,7 +9589,7 @@ urEnqueueNativeCommandExp(
95909589
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
95919590
///< events that must be complete before the kernel execution.
95929591
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
9593-
ur_event_handle_t *phEvent ///< [in,out] return an event object that identifies the work that has
9592+
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the work that has
95949593
///< been enqueued in nativeEnqueueFunc.
95959594
);
95969595

scripts/core/EXP-NATIVE-ENQUEUE.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ Functions
6565
Changelog
6666
--------------------------------------------------------------------------------
6767

68-
+-----------+------------------------+
69-
| Revision | Changes |
70-
+===========+========================+
71-
| 1.0 | Initial Draft |
72-
+-----------+------------------------+
68+
+-----------+-------------------------+
69+
| Revision | Changes |
70+
+===========+=========================+
71+
| 1.0 | Initial Draft |
72+
+-----------+-------------------------+
73+
| 1.1 | Make `phEvent` optional |
74+
+-----------+-------------------------+
7375

7476

7577
Support
@@ -83,3 +85,4 @@ Contributors
8385
--------------------------------------------------------------------------------
8486

8587
* Hugh Delaney `hugh.delaney@codeplay.com <hugh.delaney@codeplay.com>`_
88+
* Kenneth Benzie (Benie) `k.benzie@codeplay.com <k.benzie@codeplay.com>`_

scripts/core/enqueue.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,7 @@ class: $xEnqueue
11291129
name: USMPrefetch
11301130
ordinal: "0"
11311131
details:
1132-
- "Prefetching may not be supported for all devices or allocation types. If memory prefetching
1133-
is not supported, the prefetch hint will be ignored."
1132+
- "Prefetching may not be supported for all devices or allocation types. If memory prefetching is not supported, the prefetch hint will be ignored."
11341133
params:
11351134
- type: $x_queue_handle_t
11361135
name: hQueue
@@ -1178,8 +1177,7 @@ class: $xEnqueue
11781177
name: USMAdvise
11791178
ordinal: "0"
11801179
details:
1181-
- "Not all memory advice hints may be supported for all devices or allocation types.
1182-
If a memory advice hint is not supported, it will be ignored."
1180+
- "Not all memory advice hints may be supported for all devices or allocation types. If a memory advice hint is not supported, it will be ignored."
11831181
params:
11841182
- type: $x_queue_handle_t
11851183
name: hQueue

scripts/core/exp-native-enqueue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ params:
111111
- type: $x_event_handle_t*
112112
name: phEvent
113113
desc: |
114-
[in,out] return an event object that identifies the work that has
114+
[out][optional] return an event object that identifies the work that has
115115
been enqueued in nativeEnqueueFunc.
116116
returns:
117117
- $X_RESULT_ERROR_INVALID_NULL_HANDLE

source/adapters/null/ur_nullddi.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5890,8 +5890,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
58905890
///< events that must be complete before the kernel execution.
58915891
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
58925892
ur_event_handle_t *
5893-
phEvent ///< [in,out] return an event object that identifies the work that has
5894-
///< been enqueued in nativeEnqueueFunc.
5893+
phEvent ///< [out][optional] return an event object that identifies the work that has
5894+
///< been enqueued in nativeEnqueueFunc.
58955895
) try {
58965896
ur_result_t result = UR_RESULT_SUCCESS;
58975897

@@ -5904,7 +5904,9 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
59045904
pProperties, numEventsInWaitList, phEventWaitList, phEvent);
59055905
} else {
59065906
// generic implementation
5907-
*phEvent = reinterpret_cast<ur_event_handle_t>(d_context.get());
5907+
if (nullptr != phEvent) {
5908+
*phEvent = reinterpret_cast<ur_event_handle_t>(d_context.get());
5909+
}
59085910
}
59095911

59105912
return result;

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7874,8 +7874,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
78747874
///< events that must be complete before the kernel execution.
78757875
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
78767876
ur_event_handle_t *
7877-
phEvent ///< [in,out] return an event object that identifies the work that has
7878-
///< been enqueued in nativeEnqueueFunc.
7877+
phEvent ///< [out][optional] return an event object that identifies the work that has
7878+
///< been enqueued in nativeEnqueueFunc.
78797879
) {
78807880
auto pfnNativeCommandExp =
78817881
context.urDdiTable.EnqueueExp.pfnNativeCommandExp;

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9557,8 +9557,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
95579557
///< events that must be complete before the kernel execution.
95589558
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
95599559
ur_event_handle_t *
9560-
phEvent ///< [in,out] return an event object that identifies the work that has
9561-
///< been enqueued in nativeEnqueueFunc.
9560+
phEvent ///< [out][optional] return an event object that identifies the work that has
9561+
///< been enqueued in nativeEnqueueFunc.
95629562
) {
95639563
auto pfnNativeCommandExp =
95649564
context.urDdiTable.EnqueueExp.pfnNativeCommandExp;
@@ -9576,10 +9576,6 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
95769576
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
95779577
}
95789578

9579-
if (NULL == phEvent) {
9580-
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
9581-
}
9582-
95839579
if (NULL != pProperties &&
95849580
UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK & pProperties->flags) {
95859581
return UR_RESULT_ERROR_INVALID_ENUMERATION;

source/loader/ur_ldrddi.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8128,8 +8128,8 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
81288128
///< events that must be complete before the kernel execution.
81298129
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
81308130
ur_event_handle_t *
8131-
phEvent ///< [in,out] return an event object that identifies the work that has
8132-
///< been enqueued in nativeEnqueueFunc.
8131+
phEvent ///< [out][optional] return an event object that identifies the work that has
8132+
///< been enqueued in nativeEnqueueFunc.
81338133
) {
81348134
ur_result_t result = UR_RESULT_SUCCESS;
81358135

@@ -8169,8 +8169,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp(
81698169

81708170
try {
81718171
// convert platform handle to loader handle
8172-
*phEvent = reinterpret_cast<ur_event_handle_t>(
8173-
ur_event_factory.getInstance(*phEvent, dditable));
8172+
if (nullptr != phEvent) {
8173+
*phEvent = reinterpret_cast<ur_event_handle_t>(
8174+
ur_event_factory.getInstance(*phEvent, dditable));
8175+
}
81748176
} catch (std::bad_alloc &) {
81758177
result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
81768178
}

source/loader/ur_libapi.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8951,7 +8951,6 @@ ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
89518951
/// + `NULL == hQueue`
89528952
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
89538953
/// + `NULL == pfnNativeEnqueue`
8954-
/// + `NULL == phEvent`
89558954
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
89568955
/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK & pProperties->flags`
89578956
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
@@ -8975,8 +8974,8 @@ ur_result_t UR_APICALL urEnqueueNativeCommandExp(
89758974
///< events that must be complete before the kernel execution.
89768975
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
89778976
ur_event_handle_t *
8978-
phEvent ///< [in,out] return an event object that identifies the work that has
8979-
///< been enqueued in nativeEnqueueFunc.
8977+
phEvent ///< [out][optional] return an event object that identifies the work that has
8978+
///< been enqueued in nativeEnqueueFunc.
89808979
) try {
89818980
auto pfnNativeCommandExp =
89828981
ur_lib::context->urDdiTable.EnqueueExp.pfnNativeCommandExp;

source/ur_api.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7585,7 +7585,6 @@ ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp(
75857585
/// + `NULL == hQueue`
75867586
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
75877587
/// + `NULL == pfnNativeEnqueue`
7588-
/// + `NULL == phEvent`
75897588
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
75907589
/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK & pProperties->flags`
75917590
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
@@ -7609,8 +7608,8 @@ ur_result_t UR_APICALL urEnqueueNativeCommandExp(
76097608
///< events that must be complete before the kernel execution.
76107609
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
76117610
ur_event_handle_t *
7612-
phEvent ///< [in,out] return an event object that identifies the work that has
7613-
///< been enqueued in nativeEnqueueFunc.
7611+
phEvent ///< [out][optional] return an event object that identifies the work that has
7612+
///< been enqueued in nativeEnqueueFunc.
76147613
) {
76157614
ur_result_t result = UR_RESULT_SUCCESS;
76167615
return result;

0 commit comments

Comments
 (0)