Skip to content

Commit a3f4258

Browse files
author
Fábio
authored
Add more error codes to urEnqueueUSM* entrypoints; Update urUSMMemset test (#299)
* Add UR_RESULT_ERROR_INVALID_SIZE to USM entrypoints * Update USMmemset entrypoint and tests
1 parent 89f6a4a commit a3f4258

File tree

10 files changed

+302
-61
lines changed

10 files changed

+302
-61
lines changed

include/ur.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,9 @@ class ur_mem_dditable_t(Structure):
18361836
###############################################################################
18371837
## @brief Function-pointer for urEnqueueUSMMemset
18381838
if __use_win_types:
1839-
_urEnqueueUSMMemset_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_byte, c_size_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) )
1839+
_urEnqueueUSMMemset_t = WINFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_int, c_size_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) )
18401840
else:
1841-
_urEnqueueUSMMemset_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_byte, c_size_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) )
1841+
_urEnqueueUSMMemset_t = CFUNCTYPE( ur_result_t, ur_queue_handle_t, c_void_p, c_int, c_size_t, c_ulong, POINTER(ur_event_handle_t), POINTER(ur_event_handle_t) )
18421842

18431843
###############################################################################
18441844
## @brief Function-pointer for urEnqueueUSMMemcpy

include/ur_api.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,9 @@ urEnqueueMemUnmap(
12471247
/// + `NULL == ptr`
12481248
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
12491249
/// - ::UR_RESULT_ERROR_INVALID_EVENT
1250+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1251+
/// + `count == 0`
1252+
/// + If `count` is higher than the allocation size of `ptr`
12501253
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
12511254
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
12521255
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
@@ -1258,7 +1261,8 @@ UR_APIEXPORT ur_result_t UR_APICALL
12581261
urEnqueueUSMMemset(
12591262
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
12601263
void *ptr, ///< [in] pointer to USM memory object
1261-
int8_t byteValue, ///< [in] byte value to fill
1264+
int value, ///< [in] value to fill. It is interpreted as an 8-bit value and the upper
1265+
///< 24 bits are ignored
12621266
size_t count, ///< [in] size in bytes to be set
12631267
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
12641268
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
@@ -1283,6 +1287,9 @@ urEnqueueUSMMemset(
12831287
/// + `NULL == pSrc`
12841288
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
12851289
/// - ::UR_RESULT_ERROR_INVALID_EVENT
1290+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1291+
/// + `size == 0`
1292+
/// + If `size` is higher than the allocation size of `pSrc` or `pDst`
12861293
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
12871294
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
12881295
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
@@ -1321,6 +1328,9 @@ urEnqueueUSMMemcpy(
13211328
/// + `0x1 < flags`
13221329
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
13231330
/// - ::UR_RESULT_ERROR_INVALID_EVENT
1331+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1332+
/// + `size == 0`
1333+
/// + If `size` is higher than the allocation size of `pMem`
13241334
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
13251335
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
13261336
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
@@ -1368,6 +1378,9 @@ typedef enum ur_mem_advice_t {
13681378
/// + `::UR_MEM_ADVICE_DEFAULT < advice`
13691379
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
13701380
/// - ::UR_RESULT_ERROR_INVALID_EVENT
1381+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1382+
/// + `size == 0`
1383+
/// + If `size` is higher than the allocation size of `pMem`
13711384
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
13721385
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
13731386
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
@@ -1393,10 +1406,19 @@ urEnqueueUSMMemAdvise(
13931406
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
13941407
/// + `NULL == pMem`
13951408
/// + `NULL == pPattern`
1409+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1410+
/// + `pitch == 0`
1411+
/// + `width == 0`
1412+
/// + `height == 0`
1413+
/// + `pitch < width`
1414+
/// + If `pitch * height` is higher than the allocation size of `pMem`
13961415
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
13971416
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
13981417
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
13991418
/// + If event objects in phEventWaitList are not valid events.
1419+
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
1420+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
1421+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
14001422
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
14011423
UR_APIEXPORT ur_result_t UR_APICALL
14021424
urEnqueueUSMFill2D(
@@ -1437,13 +1459,17 @@ urEnqueueUSMFill2D(
14371459
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
14381460
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
14391461
/// + If event objects in phEventWaitList are not valid events.
1462+
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
1463+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
1464+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
14401465
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
14411466
UR_APIEXPORT ur_result_t UR_APICALL
14421467
urEnqueueUSMMemset2D(
14431468
ur_queue_handle_t hQueue, ///< [in] handle of the queue to submit to.
14441469
void *pMem, ///< [in] pointer to memory to be filled.
14451470
size_t pitch, ///< [in] the total width of the destination memory including padding.
1446-
int value, ///< [in] the value to fill into the region in pMem.
1471+
int value, ///< [in] the value to fill into the region in pMem. It is interpreted as
1472+
///< an 8-bit value and the upper 24 bits are ignored
14471473
size_t width, ///< [in] the width in bytes of each row to set.
14481474
size_t height, ///< [in] the height of the columns to set.
14491475
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
@@ -1467,10 +1493,21 @@ urEnqueueUSMMemset2D(
14671493
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
14681494
/// + `NULL == pDst`
14691495
/// + `NULL == pSrc`
1496+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1497+
/// + `srcPitch == 0`
1498+
/// + `dstPitch == 0`
1499+
/// + `srcPitch < width`
1500+
/// + `dstPitch < width`
1501+
/// + `height == 0`
1502+
/// + If `srcPitch * height` is higher than the allocation size of `pSrc`
1503+
/// + If `dstPitch * height` is higher than the allocation size of `pDst`
14701504
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
14711505
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
14721506
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
14731507
/// + If event objects in phEventWaitList are not valid events.
1508+
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
1509+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
1510+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
14741511
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
14751512
UR_APIEXPORT ur_result_t UR_APICALL
14761513
urEnqueueUSMMemcpy2D(
@@ -6693,7 +6730,7 @@ typedef void(UR_APICALL *ur_pfnEnqueueMemUnmapCb_t)(
66936730
typedef struct ur_enqueue_usm_memset_params_t {
66946731
ur_queue_handle_t *phQueue;
66956732
void **pptr;
6696-
int8_t *pbyteValue;
6733+
int *pvalue;
66976734
size_t *pcount;
66986735
uint32_t *pnumEventsInWaitList;
66996736
const ur_event_handle_t **pphEventWaitList;

include/ur_ddi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueMemUnmap_t)(
955955
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMMemset_t)(
956956
ur_queue_handle_t,
957957
void *,
958-
int8_t,
958+
int,
959959
size_t,
960960
uint32_t,
961961
const ur_event_handle_t *,

scripts/core/enqueue.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,9 @@ params:
943943
- type: void*
944944
name: ptr
945945
desc: "[in] pointer to USM memory object"
946-
- type: int8_t
947-
name: byteValue
948-
desc: "[in] byte value to fill"
946+
- type: int
947+
name: value
948+
desc: "[in] value to fill. It is interpreted as an 8-bit value and the upper 24 bits are ignored"
949949
- type: size_t
950950
name: count
951951
desc: "[in] size in bytes to be set"
@@ -964,6 +964,9 @@ params:
964964
returns:
965965
- $X_RESULT_ERROR_INVALID_QUEUE
966966
- $X_RESULT_ERROR_INVALID_EVENT
967+
- $X_RESULT_ERROR_INVALID_SIZE:
968+
- "`count == 0`"
969+
- "If `count` is higher than the allocation size of `ptr`"
967970
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
968971
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
969972
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
@@ -1008,6 +1011,9 @@ params:
10081011
returns:
10091012
- $X_RESULT_ERROR_INVALID_QUEUE
10101013
- $X_RESULT_ERROR_INVALID_EVENT
1014+
- $X_RESULT_ERROR_INVALID_SIZE:
1015+
- "`size == 0`"
1016+
- "If `size` is higher than the allocation size of `pSrc` or `pDst`"
10111017
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
10121018
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
10131019
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
@@ -1049,6 +1055,9 @@ params:
10491055
returns:
10501056
- $X_RESULT_ERROR_INVALID_QUEUE
10511057
- $X_RESULT_ERROR_INVALID_EVENT
1058+
- $X_RESULT_ERROR_INVALID_SIZE:
1059+
- "`size == 0`"
1060+
- "If `size` is higher than the allocation size of `pMem`"
10521061
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
10531062
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
10541063
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
@@ -1090,6 +1099,9 @@ params:
10901099
returns:
10911100
- $X_RESULT_ERROR_INVALID_QUEUE
10921101
- $X_RESULT_ERROR_INVALID_EVENT
1102+
- $X_RESULT_ERROR_INVALID_SIZE:
1103+
- "`size == 0`"
1104+
- "If `size` is higher than the allocation size of `pMem`"
10931105
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
10941106
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
10951107
- $X_RESULT_ERROR_OUT_OF_RESOURCES
@@ -1134,10 +1146,19 @@ params:
11341146
desc: |
11351147
[in,out][optional] return an event object that identifies this particular kernel execution instance.
11361148
returns:
1149+
- $X_RESULT_ERROR_INVALID_SIZE:
1150+
- "`pitch == 0`"
1151+
- "`width == 0`"
1152+
- "`height == 0`"
1153+
- "`pitch < width`"
1154+
- "If `pitch * height` is higher than the allocation size of `pMem`"
11371155
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
11381156
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
11391157
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
11401158
- "If event objects in phEventWaitList are not valid events."
1159+
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
1160+
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
1161+
- $X_RESULT_ERROR_OUT_OF_RESOURCES
11411162
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE
11421163
--- #--------------------------------------------------------------------------
11431164
type: function
@@ -1157,7 +1178,7 @@ params:
11571178
desc: "[in] the total width of the destination memory including padding."
11581179
- type: int
11591180
name: value
1160-
desc: "[in] the value to fill into the region in pMem."
1181+
desc: "[in] the value to fill into the region in pMem. It is interpreted as an 8-bit value and the upper 24 bits are ignored"
11611182
- type: size_t
11621183
name: width
11631184
desc: "[in] the width in bytes of each row to set."
@@ -1187,6 +1208,9 @@ returns:
11871208
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
11881209
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
11891210
- "If event objects in phEventWaitList are not valid events."
1211+
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
1212+
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
1213+
- $X_RESULT_ERROR_OUT_OF_RESOURCES
11901214
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE
11911215
--- #--------------------------------------------------------------------------
11921216
type: function
@@ -1232,10 +1256,21 @@ params:
12321256
desc: |
12331257
[in,out][optional] return an event object that identifies this particular kernel execution instance.
12341258
returns:
1259+
- $X_RESULT_ERROR_INVALID_SIZE:
1260+
- "`srcPitch == 0`"
1261+
- "`dstPitch == 0`"
1262+
- "`srcPitch < width`"
1263+
- "`dstPitch < width`"
1264+
- "`height == 0`"
1265+
- "If `srcPitch * height` is higher than the allocation size of `pSrc`"
1266+
- "If `dstPitch * height` is higher than the allocation size of `pDst`"
12351267
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
12361268
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
12371269
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
12381270
- "If event objects in phEventWaitList are not valid events."
1271+
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
1272+
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
1273+
- $X_RESULT_ERROR_OUT_OF_RESOURCES
12391274
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE
12401275
--- #--------------------------------------------------------------------------
12411276
type: function

source/drivers/null/ur_nullddi.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ __urdlllocal ur_result_t UR_APICALL
703703
urEnqueueUSMMemset(
704704
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
705705
void *ptr, ///< [in] pointer to USM memory object
706-
int8_t byteValue, ///< [in] byte value to fill
706+
int value, ///< [in] value to fill. It is interpreted as an 8-bit value and the upper
707+
///< 24 bits are ignored
707708
size_t count, ///< [in] size in bytes to be set
708709
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
709710
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
@@ -718,7 +719,7 @@ urEnqueueUSMMemset(
718719
// if the driver has created a custom function, then call it instead of using the generic path
719720
auto pfnUSMMemset = d_context.urDdiTable.Enqueue.pfnUSMMemset;
720721
if (nullptr != pfnUSMMemset) {
721-
result = pfnUSMMemset(hQueue, ptr, byteValue, count, numEventsInWaitList, phEventWaitList, phEvent);
722+
result = pfnUSMMemset(hQueue, ptr, value, count, numEventsInWaitList, phEventWaitList, phEvent);
722723
} else {
723724
// generic implementation
724725
if (nullptr != phEvent) {
@@ -863,7 +864,8 @@ urEnqueueUSMMemset2D(
863864
ur_queue_handle_t hQueue, ///< [in] handle of the queue to submit to.
864865
void *pMem, ///< [in] pointer to memory to be filled.
865866
size_t pitch, ///< [in] the total width of the destination memory including padding.
866-
int value, ///< [in] the value to fill into the region in pMem.
867+
int value, ///< [in] the value to fill into the region in pMem. It is interpreted as
868+
///< an 8-bit value and the upper 24 bits are ignored
867869
size_t width, ///< [in] the width in bytes of each row to set.
868870
size_t height, ///< [in] the height of the columns to set.
869871
uint32_t numEventsInWaitList, ///< [in] size of the event wait list

0 commit comments

Comments
 (0)