@@ -4822,9 +4822,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferRead(
4822
4822
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
4823
4823
}
4824
4824
4825
- if (auto boundsError = bounds (hBuffer, offset, size);
4826
- boundsError != UR_RESULT_SUCCESS) {
4827
- return boundsError;
4825
+ if (getContext ()->enableBoundsChecking ) {
4826
+ if (auto boundsError = bounds (hBuffer, offset, size);
4827
+ boundsError != UR_RESULT_SUCCESS) {
4828
+ return boundsError;
4829
+ }
4828
4830
}
4829
4831
4830
4832
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -4902,9 +4904,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWrite(
4902
4904
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
4903
4905
}
4904
4906
4905
- if (auto boundsError = bounds (hBuffer, offset, size);
4906
- boundsError != UR_RESULT_SUCCESS) {
4907
- return boundsError;
4907
+ if (getContext ()->enableBoundsChecking ) {
4908
+ if (auto boundsError = bounds (hBuffer, offset, size);
4909
+ boundsError != UR_RESULT_SUCCESS) {
4910
+ return boundsError;
4911
+ }
4908
4912
}
4909
4913
4910
4914
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5033,9 +5037,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
5033
5037
return UR_RESULT_ERROR_INVALID_SIZE;
5034
5038
}
5035
5039
5036
- if (auto boundsError = bounds (hBuffer, bufferOrigin, region);
5037
- boundsError != UR_RESULT_SUCCESS) {
5038
- return boundsError;
5040
+ if (getContext ()->enableBoundsChecking ) {
5041
+ if (auto boundsError = bounds (hBuffer, bufferOrigin, region);
5042
+ boundsError != UR_RESULT_SUCCESS) {
5043
+ return boundsError;
5044
+ }
5039
5045
}
5040
5046
5041
5047
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5168,9 +5174,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferWriteRect(
5168
5174
return UR_RESULT_ERROR_INVALID_SIZE;
5169
5175
}
5170
5176
5171
- if (auto boundsError = bounds (hBuffer, bufferOrigin, region);
5172
- boundsError != UR_RESULT_SUCCESS) {
5173
- return boundsError;
5177
+ if (getContext ()->enableBoundsChecking ) {
5178
+ if (auto boundsError = bounds (hBuffer, bufferOrigin, region);
5179
+ boundsError != UR_RESULT_SUCCESS) {
5180
+ return boundsError;
5181
+ }
5174
5182
}
5175
5183
5176
5184
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5248,14 +5256,18 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopy(
5248
5256
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
5249
5257
}
5250
5258
5251
- if (auto boundsError = bounds (hBufferSrc, srcOffset, size);
5252
- boundsError != UR_RESULT_SUCCESS) {
5253
- return boundsError;
5259
+ if (getContext ()->enableBoundsChecking ) {
5260
+ if (auto boundsError = bounds (hBufferSrc, srcOffset, size);
5261
+ boundsError != UR_RESULT_SUCCESS) {
5262
+ return boundsError;
5263
+ }
5254
5264
}
5255
5265
5256
- if (auto boundsError = bounds (hBufferDst, dstOffset, size);
5257
- boundsError != UR_RESULT_SUCCESS) {
5258
- return boundsError;
5266
+ if (getContext ()->enableBoundsChecking ) {
5267
+ if (auto boundsError = bounds (hBufferDst, dstOffset, size);
5268
+ boundsError != UR_RESULT_SUCCESS) {
5269
+ return boundsError;
5270
+ }
5259
5271
}
5260
5272
5261
5273
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5383,14 +5395,18 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect(
5383
5395
return UR_RESULT_ERROR_INVALID_SIZE;
5384
5396
}
5385
5397
5386
- if (auto boundsError = bounds (hBufferSrc, srcOrigin, region);
5387
- boundsError != UR_RESULT_SUCCESS) {
5388
- return boundsError;
5398
+ if (getContext ()->enableBoundsChecking ) {
5399
+ if (auto boundsError = bounds (hBufferSrc, srcOrigin, region);
5400
+ boundsError != UR_RESULT_SUCCESS) {
5401
+ return boundsError;
5402
+ }
5389
5403
}
5390
5404
5391
- if (auto boundsError = bounds (hBufferDst, dstOrigin, region);
5392
- boundsError != UR_RESULT_SUCCESS) {
5393
- return boundsError;
5405
+ if (getContext ()->enableBoundsChecking ) {
5406
+ if (auto boundsError = bounds (hBufferDst, dstOrigin, region);
5407
+ boundsError != UR_RESULT_SUCCESS) {
5408
+ return boundsError;
5409
+ }
5394
5410
}
5395
5411
5396
5412
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5492,9 +5508,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferFill(
5492
5508
return UR_RESULT_ERROR_INVALID_SIZE;
5493
5509
}
5494
5510
5495
- if (auto boundsError = bounds (hBuffer, offset, size);
5496
- boundsError != UR_RESULT_SUCCESS) {
5497
- return boundsError;
5511
+ if (getContext ()->enableBoundsChecking ) {
5512
+ if (auto boundsError = bounds (hBuffer, offset, size);
5513
+ boundsError != UR_RESULT_SUCCESS) {
5514
+ return boundsError;
5515
+ }
5498
5516
}
5499
5517
5500
5518
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5579,9 +5597,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageRead(
5579
5597
return UR_RESULT_ERROR_INVALID_SIZE;
5580
5598
}
5581
5599
5582
- if (auto boundsError = boundsImage (hImage, origin, region);
5583
- boundsError != UR_RESULT_SUCCESS) {
5584
- return boundsError;
5600
+ if (getContext ()->enableBoundsChecking ) {
5601
+ if (auto boundsError = boundsImage (hImage, origin, region);
5602
+ boundsError != UR_RESULT_SUCCESS) {
5603
+ return boundsError;
5604
+ }
5585
5605
}
5586
5606
5587
5607
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5667,9 +5687,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageWrite(
5667
5687
return UR_RESULT_ERROR_INVALID_SIZE;
5668
5688
}
5669
5689
5670
- if (auto boundsError = boundsImage (hImage, origin, region);
5671
- boundsError != UR_RESULT_SUCCESS) {
5672
- return boundsError;
5690
+ if (getContext ()->enableBoundsChecking ) {
5691
+ if (auto boundsError = boundsImage (hImage, origin, region);
5692
+ boundsError != UR_RESULT_SUCCESS) {
5693
+ return boundsError;
5694
+ }
5673
5695
}
5674
5696
5675
5697
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5756,14 +5778,18 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemImageCopy(
5756
5778
return UR_RESULT_ERROR_INVALID_SIZE;
5757
5779
}
5758
5780
5759
- if (auto boundsError = boundsImage (hImageSrc, srcOrigin, region);
5760
- boundsError != UR_RESULT_SUCCESS) {
5761
- return boundsError;
5781
+ if (getContext ()->enableBoundsChecking ) {
5782
+ if (auto boundsError = boundsImage (hImageSrc, srcOrigin, region);
5783
+ boundsError != UR_RESULT_SUCCESS) {
5784
+ return boundsError;
5785
+ }
5762
5786
}
5763
5787
5764
- if (auto boundsError = boundsImage (hImageDst, dstOrigin, region);
5765
- boundsError != UR_RESULT_SUCCESS) {
5766
- return boundsError;
5788
+ if (getContext ()->enableBoundsChecking ) {
5789
+ if (auto boundsError = boundsImage (hImageDst, dstOrigin, region);
5790
+ boundsError != UR_RESULT_SUCCESS) {
5791
+ return boundsError;
5792
+ }
5767
5793
}
5768
5794
5769
5795
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -5850,9 +5876,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferMap(
5850
5876
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
5851
5877
}
5852
5878
5853
- if (auto boundsError = bounds (hBuffer, offset, size);
5854
- boundsError != UR_RESULT_SUCCESS) {
5855
- return boundsError;
5879
+ if (getContext ()->enableBoundsChecking ) {
5880
+ if (auto boundsError = bounds (hBuffer, offset, size);
5881
+ boundsError != UR_RESULT_SUCCESS) {
5882
+ return boundsError;
5883
+ }
5856
5884
}
5857
5885
5858
5886
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -6012,9 +6040,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill(
6012
6040
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
6013
6041
}
6014
6042
6015
- if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6016
- boundsError != UR_RESULT_SUCCESS) {
6017
- return boundsError;
6043
+ if (getContext ()->enableBoundsChecking ) {
6044
+ if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6045
+ boundsError != UR_RESULT_SUCCESS) {
6046
+ return boundsError;
6047
+ }
6018
6048
}
6019
6049
6020
6050
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -6089,14 +6119,18 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy(
6089
6119
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
6090
6120
}
6091
6121
6092
- if (auto boundsError = bounds (hQueue, pDst, 0 , size);
6093
- boundsError != UR_RESULT_SUCCESS) {
6094
- return boundsError;
6122
+ if (getContext ()->enableBoundsChecking ) {
6123
+ if (auto boundsError = bounds (hQueue, pDst, 0 , size);
6124
+ boundsError != UR_RESULT_SUCCESS) {
6125
+ return boundsError;
6126
+ }
6095
6127
}
6096
6128
6097
- if (auto boundsError = bounds (hQueue, pSrc, 0 , size);
6098
- boundsError != UR_RESULT_SUCCESS) {
6099
- return boundsError;
6129
+ if (getContext ()->enableBoundsChecking ) {
6130
+ if (auto boundsError = bounds (hQueue, pSrc, 0 , size);
6131
+ boundsError != UR_RESULT_SUCCESS) {
6132
+ return boundsError;
6133
+ }
6100
6134
}
6101
6135
6102
6136
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -6169,9 +6203,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMPrefetch(
6169
6203
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
6170
6204
}
6171
6205
6172
- if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6173
- boundsError != UR_RESULT_SUCCESS) {
6174
- return boundsError;
6206
+ if (getContext ()->enableBoundsChecking ) {
6207
+ if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6208
+ boundsError != UR_RESULT_SUCCESS) {
6209
+ return boundsError;
6210
+ }
6175
6211
}
6176
6212
6177
6213
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -6230,9 +6266,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMAdvise(
6230
6266
return UR_RESULT_ERROR_INVALID_SIZE;
6231
6267
}
6232
6268
6233
- if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6234
- boundsError != UR_RESULT_SUCCESS) {
6235
- return boundsError;
6269
+ if (getContext ()->enableBoundsChecking ) {
6270
+ if (auto boundsError = bounds (hQueue, pMem, 0 , size);
6271
+ boundsError != UR_RESULT_SUCCESS) {
6272
+ return boundsError;
6273
+ }
6236
6274
}
6237
6275
}
6238
6276
@@ -6332,9 +6370,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D(
6332
6370
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
6333
6371
}
6334
6372
6335
- if (auto boundsError = bounds (hQueue, pMem, 0 , pitch * height);
6336
- boundsError != UR_RESULT_SUCCESS) {
6337
- return boundsError;
6373
+ if (getContext ()->enableBoundsChecking ) {
6374
+ if (auto boundsError = bounds (hQueue, pMem, 0 , pitch * height);
6375
+ boundsError != UR_RESULT_SUCCESS) {
6376
+ return boundsError;
6377
+ }
6338
6378
}
6339
6379
6340
6380
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -6431,14 +6471,18 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMMemcpy2D(
6431
6471
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
6432
6472
}
6433
6473
6434
- if (auto boundsError = bounds (hQueue, pDst, 0 , dstPitch * height);
6435
- boundsError != UR_RESULT_SUCCESS) {
6436
- return boundsError;
6474
+ if (getContext ()->enableBoundsChecking ) {
6475
+ if (auto boundsError = bounds (hQueue, pDst, 0 , dstPitch * height);
6476
+ boundsError != UR_RESULT_SUCCESS) {
6477
+ return boundsError;
6478
+ }
6437
6479
}
6438
6480
6439
- if (auto boundsError = bounds (hQueue, pSrc, 0 , srcPitch * height);
6440
- boundsError != UR_RESULT_SUCCESS) {
6441
- return boundsError;
6481
+ if (getContext ()->enableBoundsChecking ) {
6482
+ if (auto boundsError = bounds (hQueue, pSrc, 0 , srcPitch * height);
6483
+ boundsError != UR_RESULT_SUCCESS) {
6484
+ return boundsError;
6485
+ }
6442
6486
}
6443
6487
6444
6488
if (phEventWaitList != NULL && numEventsInWaitList > 0 ) {
@@ -10997,9 +11041,13 @@ ur_result_t context_t::init(ur_dditable_t *dditable,
10997
11041
10998
11042
if (enabledLayerNames.count (nameFullValidation)) {
10999
11043
enableParameterValidation = true ;
11044
+ enableBoundsChecking = true ;
11000
11045
enableLeakChecking = true ;
11001
11046
enableLifetimeValidation = true ;
11002
11047
} else {
11048
+ if (enabledLayerNames.count (nameBoundsChecking)) {
11049
+ enableBoundsChecking = true ;
11050
+ }
11003
11051
if (enabledLayerNames.count (nameParameterValidation)) {
11004
11052
enableParameterValidation = true ;
11005
11053
}
0 commit comments