Skip to content

Commit 2c533e6

Browse files
authored
Update specification for urEnqueue entrypoints (#851)
- Added extra conditions to the validation layers of urEnqueueMemBufferFill, urEnqueueMemImageCopy, urEnqueueMemImageWrite and urEnqueueMemImageReady
1 parent 6d59b4c commit 2c533e6

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

include/ur_api.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6217,6 +6217,11 @@ urEnqueueMemBufferCopyRect(
62176217
/// + If event objects in phEventWaitList are not valid events.
62186218
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
62196219
/// - ::UR_RESULT_ERROR_INVALID_SIZE
6220+
/// + `patternSize == 0 || size == 0`
6221+
/// + `patternSize > size`
6222+
/// + `(patternSize & (patternSize - 1)) != 0`
6223+
/// + `size % patternSize != 0`
6224+
/// + `offset % patternSize != 0`
62206225
/// + If `offset + size` results in an out-of-bounds access.
62216226
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
62226227
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
@@ -6266,6 +6271,8 @@ urEnqueueMemBufferFill(
62666271
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
62676272
/// + If event objects in phEventWaitList are not valid events.
62686273
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
6274+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
6275+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
62696276
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
62706277
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
62716278
UR_APIEXPORT ur_result_t UR_APICALL
@@ -6317,6 +6324,8 @@ urEnqueueMemImageRead(
63176324
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
63186325
/// + If event objects in phEventWaitList are not valid events.
63196326
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
6327+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
6328+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
63206329
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
63216330
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
63226331
UR_APIEXPORT ur_result_t UR_APICALL
@@ -6362,6 +6371,8 @@ urEnqueueMemImageWrite(
63626371
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
63636372
/// + If event objects in phEventWaitList are not valid events.
63646373
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
6374+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
6375+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
63656376
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
63666377
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
63676378
UR_APIEXPORT ur_result_t UR_APICALL

scripts/core/enqueue.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@ returns:
571571
- "If event objects in phEventWaitList are not valid events."
572572
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
573573
- $X_RESULT_ERROR_INVALID_SIZE:
574+
- "`patternSize == 0 || size == 0`"
575+
- "`patternSize > size`"
576+
- "`(patternSize & (patternSize - 1)) != 0`"
577+
- "`size % patternSize != 0`"
578+
- "`offset % patternSize != 0`"
574579
- "If `offset + size` results in an out-of-bounds access."
575580
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
576581
- $X_RESULT_ERROR_OUT_OF_RESOURCES
@@ -629,6 +634,8 @@ returns:
629634
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
630635
- "If event objects in phEventWaitList are not valid events."
631636
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
637+
- $X_RESULT_ERROR_INVALID_SIZE:
638+
- "`region.width == 0 || region.height == 0 || region.depth == 0`"
632639
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
633640
- $X_RESULT_ERROR_OUT_OF_RESOURCES
634641
--- #--------------------------------------------------------------------------
@@ -686,6 +693,8 @@ returns:
686693
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
687694
- "If event objects in phEventWaitList are not valid events."
688695
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
696+
- $X_RESULT_ERROR_INVALID_SIZE:
697+
- "`region.width == 0 || region.height == 0 || region.depth == 0`"
689698
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
690699
- $X_RESULT_ERROR_OUT_OF_RESOURCES
691700
--- #--------------------------------------------------------------------------
@@ -735,6 +744,8 @@ returns:
735744
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
736745
- "If event objects in phEventWaitList are not valid events."
737746
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
747+
- $X_RESULT_ERROR_INVALID_SIZE:
748+
- "`region.width == 0 || region.height == 0 || region.depth == 0`"
738749
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
739750
- $X_RESULT_ERROR_OUT_OF_RESOURCES
740751
--- #--------------------------------------------------------------------------

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4525,6 +4525,26 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill(
45254525
if (phEventWaitList != NULL && numEventsInWaitList == 0) {
45264526
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
45274527
}
4528+
4529+
if (patternSize == 0 || size == 0) {
4530+
return UR_RESULT_ERROR_INVALID_SIZE;
4531+
}
4532+
4533+
if (patternSize > size) {
4534+
return UR_RESULT_ERROR_INVALID_SIZE;
4535+
}
4536+
4537+
if ((patternSize & (patternSize - 1)) != 0) {
4538+
return UR_RESULT_ERROR_INVALID_SIZE;
4539+
}
4540+
4541+
if (size % patternSize != 0) {
4542+
return UR_RESULT_ERROR_INVALID_SIZE;
4543+
}
4544+
4545+
if (offset % patternSize != 0) {
4546+
return UR_RESULT_ERROR_INVALID_SIZE;
4547+
}
45284548
}
45294549

45304550
ur_result_t result =
@@ -4584,6 +4604,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead(
45844604
if (phEventWaitList != NULL && numEventsInWaitList == 0) {
45854605
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
45864606
}
4607+
4608+
if (region.width == 0 || region.height == 0 || region.depth == 0) {
4609+
return UR_RESULT_ERROR_INVALID_SIZE;
4610+
}
45874611
}
45884612

45894613
ur_result_t result = pfnMemImageRead(
@@ -4644,6 +4668,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite(
46444668
if (phEventWaitList != NULL && numEventsInWaitList == 0) {
46454669
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
46464670
}
4671+
4672+
if (region.width == 0 || region.height == 0 || region.depth == 0) {
4673+
return UR_RESULT_ERROR_INVALID_SIZE;
4674+
}
46474675
}
46484676

46494677
ur_result_t result = pfnMemImageWrite(
@@ -4704,6 +4732,10 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy(
47044732
if (phEventWaitList != NULL && numEventsInWaitList == 0) {
47054733
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
47064734
}
4735+
4736+
if (region.width == 0 || region.height == 0 || region.depth == 0) {
4737+
return UR_RESULT_ERROR_INVALID_SIZE;
4738+
}
47074739
}
47084740

47094741
ur_result_t result =

source/loader/ur_libapi.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,6 +5197,11 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopyRect(
51975197
/// + If event objects in phEventWaitList are not valid events.
51985198
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
51995199
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5200+
/// + `patternSize == 0 || size == 0`
5201+
/// + `patternSize > size`
5202+
/// + `(patternSize & (patternSize - 1)) != 0`
5203+
/// + `size % patternSize != 0`
5204+
/// + `offset % patternSize != 0`
52005205
/// + If `offset + size` results in an out-of-bounds access.
52015206
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
52025207
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
@@ -5259,6 +5264,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferFill(
52595264
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
52605265
/// + If event objects in phEventWaitList are not valid events.
52615266
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
5267+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5268+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
52625269
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
52635270
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
52645271
ur_result_t UR_APICALL urEnqueueMemImageRead(
@@ -5324,6 +5331,8 @@ ur_result_t UR_APICALL urEnqueueMemImageRead(
53245331
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
53255332
/// + If event objects in phEventWaitList are not valid events.
53265333
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
5334+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5335+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
53275336
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
53285337
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
53295338
ur_result_t UR_APICALL urEnqueueMemImageWrite(
@@ -5385,6 +5394,8 @@ ur_result_t UR_APICALL urEnqueueMemImageWrite(
53855394
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
53865395
/// + If event objects in phEventWaitList are not valid events.
53875396
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
5397+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5398+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
53885399
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
53895400
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
53905401
ur_result_t UR_APICALL urEnqueueMemImageCopy(

source/ur_api.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,6 +4405,11 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopyRect(
44054405
/// + If event objects in phEventWaitList are not valid events.
44064406
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
44074407
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4408+
/// + `patternSize == 0 || size == 0`
4409+
/// + `patternSize > size`
4410+
/// + `(patternSize & (patternSize - 1)) != 0`
4411+
/// + `size % patternSize != 0`
4412+
/// + `offset % patternSize != 0`
44084413
/// + If `offset + size` results in an out-of-bounds access.
44094414
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
44104415
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
@@ -4458,6 +4463,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferFill(
44584463
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
44594464
/// + If event objects in phEventWaitList are not valid events.
44604465
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
4466+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4467+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
44614468
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
44624469
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
44634470
ur_result_t UR_APICALL urEnqueueMemImageRead(
@@ -4515,6 +4522,8 @@ ur_result_t UR_APICALL urEnqueueMemImageRead(
45154522
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
45164523
/// + If event objects in phEventWaitList are not valid events.
45174524
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
4525+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4526+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
45184527
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
45194528
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
45204529
ur_result_t UR_APICALL urEnqueueMemImageWrite(
@@ -4567,6 +4576,8 @@ ur_result_t UR_APICALL urEnqueueMemImageWrite(
45674576
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
45684577
/// + If event objects in phEventWaitList are not valid events.
45694578
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
4579+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4580+
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
45704581
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
45714582
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
45724583
ur_result_t UR_APICALL urEnqueueMemImageCopy(

0 commit comments

Comments
 (0)