Skip to content

Commit 9f0d891

Browse files
authored
Merge pull request #601 from aarongreig/aaron/enqueueMemOpFixes
A number of small fixes for some mem operation tests and validation.
2 parents 51dede3 + c5b6845 commit 9f0d891

File tree

8 files changed

+56
-57
lines changed

8 files changed

+56
-57
lines changed

include/ur_api.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,8 +5230,8 @@ urEnqueueMemBufferCopy(
52305230
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
52315231
/// - ::UR_RESULT_ERROR_INVALID_SIZE
52325232
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
5233-
/// + `srcRowPitch != 0 && srcRowPitch < region.height`
5234-
/// + `dstRowPitch != 0 && dstRowPitch < region.height`
5233+
/// + `srcRowPitch != 0 && srcRowPitch < region.width`
5234+
/// + `dstRowPitch != 0 && dstRowPitch < region.width`
52355235
/// + `srcSlicePitch != 0 && srcSlicePitch < region.height * (srcRowPitch != 0 ? srcRowPitch : region.width)`
52365236
/// + `srcSlicePitch != 0 && srcSlicePitch % (srcRowPitch != 0 ? srcRowPitch : region.width) != 0`
52375237
/// + `dstSlicePitch != 0 && dstSlicePitch < region.height * (dstRowPitch != 0 ? dstRowPitch : region.width)`
@@ -5589,11 +5589,11 @@ urEnqueueMemUnmap(
55895589
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
55905590
/// - ::UR_RESULT_ERROR_INVALID_EVENT
55915591
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5592-
/// + `size == 0`
5593-
/// + `size % patternSize != 0`
55945592
/// + `patternSize == 0`
55955593
/// + `patternSize > size`
55965594
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
5595+
/// + `size == 0`
5596+
/// + `size % patternSize != 0`
55975597
/// + If `size` is higher than the allocation size of `ptr`
55985598
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
55995599
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
@@ -5745,12 +5745,12 @@ urEnqueueUSMAdvise(
57455745
/// - ::UR_RESULT_ERROR_INVALID_SIZE
57465746
/// + `pitch == 0`
57475747
/// + `pitch < width`
5748-
/// + `width == 0`
5749-
/// + `width % patternSize != 0`
5750-
/// + `height == 0`
57515748
/// + `patternSize == 0`
5752-
/// + `patternSize > width`
5749+
/// + `patternSize > width * height`
57535750
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
5751+
/// + `width == 0`
5752+
/// + `height == 0`
5753+
/// + `width * height % patternSize != 0`
57545754
/// + If `pitch * height` is higher than the allocation size of `pMem`
57555755
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
57565756
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`

scripts/core/enqueue.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ returns:
513513
- $X_RESULT_ERROR_INVALID_MEM_OBJECT
514514
- $X_RESULT_ERROR_INVALID_SIZE:
515515
- "`region.width == 0 || region.height == 0 || region.depth == 0`"
516-
- "`srcRowPitch != 0 && srcRowPitch < region.height`"
517-
- "`dstRowPitch != 0 && dstRowPitch < region.height`"
516+
- "`srcRowPitch != 0 && srcRowPitch < region.width`"
517+
- "`dstRowPitch != 0 && dstRowPitch < region.width`"
518518
- "`srcSlicePitch != 0 && srcSlicePitch < region.height * (srcRowPitch != 0 ? srcRowPitch : region.width)`"
519519
- "`srcSlicePitch != 0 && srcSlicePitch % (srcRowPitch != 0 ? srcRowPitch : region.width) != 0`"
520520
- "`dstSlicePitch != 0 && dstSlicePitch < region.height * (dstRowPitch != 0 ? dstRowPitch : region.width)`"
@@ -1012,11 +1012,11 @@ returns:
10121012
- $X_RESULT_ERROR_INVALID_QUEUE
10131013
- $X_RESULT_ERROR_INVALID_EVENT
10141014
- $X_RESULT_ERROR_INVALID_SIZE:
1015-
- "`size == 0`"
1016-
- "`size % patternSize != 0`"
10171015
- "`patternSize == 0`"
10181016
- "`patternSize > size`"
10191017
- "`patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`"
1018+
- "`size == 0`"
1019+
- "`size % patternSize != 0`"
10201020
- "If `size` is higher than the allocation size of `ptr`"
10211021
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
10221022
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
@@ -1192,12 +1192,12 @@ returns:
11921192
- $X_RESULT_ERROR_INVALID_SIZE:
11931193
- "`pitch == 0`"
11941194
- "`pitch < width`"
1195-
- "`width == 0`"
1196-
- "`width % patternSize != 0`"
1197-
- "`height == 0`"
11981195
- "`patternSize == 0`"
1199-
- "`patternSize > width`"
1196+
- "`patternSize > width * height`"
12001197
- "`patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`"
1198+
- "`width == 0`"
1199+
- "`height == 0`"
1200+
- "`width * height % patternSize != 0`"
12011201
- "If `pitch * height` is higher than the allocation size of `pMem`"
12021202
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
12031203
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3980,11 +3980,11 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueMemBufferCopyRect(
39803980
return UR_RESULT_ERROR_INVALID_SIZE;
39813981
}
39823982

3983-
if (srcRowPitch != 0 && srcRowPitch < region.height) {
3983+
if (srcRowPitch != 0 && srcRowPitch < region.width) {
39843984
return UR_RESULT_ERROR_INVALID_SIZE;
39853985
}
39863986

3987-
if (dstRowPitch != 0 && dstRowPitch < region.height) {
3987+
if (dstRowPitch != 0 && dstRowPitch < region.width) {
39883988
return UR_RESULT_ERROR_INVALID_SIZE;
39893989
}
39903990

@@ -4407,23 +4407,23 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill(
44074407
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
44084408
}
44094409

4410-
if (size == 0) {
4410+
if (patternSize == 0) {
44114411
return UR_RESULT_ERROR_INVALID_SIZE;
44124412
}
44134413

4414-
if (size % patternSize != 0) {
4414+
if (patternSize > size) {
44154415
return UR_RESULT_ERROR_INVALID_SIZE;
44164416
}
44174417

4418-
if (patternSize == 0) {
4418+
if (patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)) {
44194419
return UR_RESULT_ERROR_INVALID_SIZE;
44204420
}
44214421

4422-
if (patternSize > size) {
4422+
if (size == 0) {
44234423
return UR_RESULT_ERROR_INVALID_SIZE;
44244424
}
44254425

4426-
if (patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)) {
4426+
if (size % patternSize != 0) {
44274427
return UR_RESULT_ERROR_INVALID_SIZE;
44284428
}
44294429

@@ -4649,27 +4649,27 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill2D(
46494649
return UR_RESULT_ERROR_INVALID_SIZE;
46504650
}
46514651

4652-
if (width == 0) {
4652+
if (patternSize == 0) {
46534653
return UR_RESULT_ERROR_INVALID_SIZE;
46544654
}
46554655

4656-
if (width % patternSize != 0) {
4656+
if (patternSize > width * height) {
46574657
return UR_RESULT_ERROR_INVALID_SIZE;
46584658
}
46594659

4660-
if (height == 0) {
4660+
if (patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)) {
46614661
return UR_RESULT_ERROR_INVALID_SIZE;
46624662
}
46634663

4664-
if (patternSize == 0) {
4664+
if (width == 0) {
46654665
return UR_RESULT_ERROR_INVALID_SIZE;
46664666
}
46674667

4668-
if (patternSize > width) {
4668+
if (height == 0) {
46694669
return UR_RESULT_ERROR_INVALID_SIZE;
46704670
}
46714671

4672-
if (patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)) {
4672+
if (width * height % patternSize != 0) {
46734673
return UR_RESULT_ERROR_INVALID_SIZE;
46744674
}
46754675

source/loader/ur_libapi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,8 +4314,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopy(
43144314
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
43154315
/// - ::UR_RESULT_ERROR_INVALID_SIZE
43164316
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
4317-
/// + `srcRowPitch != 0 && srcRowPitch < region.height`
4318-
/// + `dstRowPitch != 0 && dstRowPitch < region.height`
4317+
/// + `srcRowPitch != 0 && srcRowPitch < region.width`
4318+
/// + `dstRowPitch != 0 && dstRowPitch < region.width`
43194319
/// + `srcSlicePitch != 0 && srcSlicePitch < region.height * (srcRowPitch != 0 ? srcRowPitch : region.width)`
43204320
/// + `srcSlicePitch != 0 && srcSlicePitch % (srcRowPitch != 0 ? srcRowPitch : region.width) != 0`
43214321
/// + `dstSlicePitch != 0 && dstSlicePitch < region.height * (dstRowPitch != 0 ? dstRowPitch : region.width)`
@@ -4746,11 +4746,11 @@ ur_result_t UR_APICALL urEnqueueMemUnmap(
47464746
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
47474747
/// - ::UR_RESULT_ERROR_INVALID_EVENT
47484748
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4749-
/// + `size == 0`
4750-
/// + `size % patternSize != 0`
47514749
/// + `patternSize == 0`
47524750
/// + `patternSize > size`
47534751
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4752+
/// + `size == 0`
4753+
/// + `size % patternSize != 0`
47544754
/// + If `size` is higher than the allocation size of `ptr`
47554755
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
47564756
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
@@ -4947,12 +4947,12 @@ ur_result_t UR_APICALL urEnqueueUSMAdvise(
49474947
/// - ::UR_RESULT_ERROR_INVALID_SIZE
49484948
/// + `pitch == 0`
49494949
/// + `pitch < width`
4950-
/// + `width == 0`
4951-
/// + `width % patternSize != 0`
4952-
/// + `height == 0`
49534950
/// + `patternSize == 0`
4954-
/// + `patternSize > width`
4951+
/// + `patternSize > width * height`
49554952
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4953+
/// + `width == 0`
4954+
/// + `height == 0`
4955+
/// + `width * height % patternSize != 0`
49564956
/// + If `pitch * height` is higher than the allocation size of `pMem`
49574957
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
49584958
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`

source/ur_api.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,8 +3621,8 @@ ur_result_t UR_APICALL urEnqueueMemBufferCopy(
36213621
/// - ::UR_RESULT_ERROR_INVALID_MEM_OBJECT
36223622
/// - ::UR_RESULT_ERROR_INVALID_SIZE
36233623
/// + `region.width == 0 || region.height == 0 || region.depth == 0`
3624-
/// + `srcRowPitch != 0 && srcRowPitch < region.height`
3625-
/// + `dstRowPitch != 0 && dstRowPitch < region.height`
3624+
/// + `srcRowPitch != 0 && srcRowPitch < region.width`
3625+
/// + `dstRowPitch != 0 && dstRowPitch < region.width`
36263626
/// + `srcSlicePitch != 0 && srcSlicePitch < region.height * (srcRowPitch != 0 ? srcRowPitch : region.width)`
36273627
/// + `srcSlicePitch != 0 && srcSlicePitch % (srcRowPitch != 0 ? srcRowPitch : region.width) != 0`
36283628
/// + `dstSlicePitch != 0 && dstSlicePitch < region.height * (dstRowPitch != 0 ? dstRowPitch : region.width)`
@@ -3994,11 +3994,11 @@ ur_result_t UR_APICALL urEnqueueMemUnmap(
39943994
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
39953995
/// - ::UR_RESULT_ERROR_INVALID_EVENT
39963996
/// - ::UR_RESULT_ERROR_INVALID_SIZE
3997-
/// + `size == 0`
3998-
/// + `size % patternSize != 0`
39993997
/// + `patternSize == 0`
40003998
/// + `patternSize > size`
40013999
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4000+
/// + `size == 0`
4001+
/// + `size % patternSize != 0`
40024002
/// + If `size` is higher than the allocation size of `ptr`
40034003
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
40044004
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
@@ -4168,12 +4168,12 @@ ur_result_t UR_APICALL urEnqueueUSMAdvise(
41684168
/// - ::UR_RESULT_ERROR_INVALID_SIZE
41694169
/// + `pitch == 0`
41704170
/// + `pitch < width`
4171-
/// + `width == 0`
4172-
/// + `width % patternSize != 0`
4173-
/// + `height == 0`
41744171
/// + `patternSize == 0`
4175-
/// + `patternSize > width`
4172+
/// + `patternSize > width * height`
41764173
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4174+
/// + `width == 0`
4175+
/// + `height == 0`
4176+
/// + `width * height % patternSize != 0`
41774177
/// + If `pitch * height` is higher than the allocation size of `pMem`
41784178
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
41794179
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`

test/conformance/enqueue/urEnqueueMemBufferMap.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,29 +141,27 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessMultiMaps) {
141141
}
142142

143143
TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleQueue) {
144-
uint32_t *map = nullptr;
144+
void *map = nullptr;
145145
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
146146
urEnqueueMemBufferMap(nullptr, buffer, true,
147147
UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE,
148-
0, size, 0, nullptr, nullptr,
149-
(void **)&map));
148+
0, size, 0, nullptr, nullptr, &map));
150149
}
151150

152151
TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleBuffer) {
153-
uint32_t *map = nullptr;
152+
void *map = nullptr;
154153
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
155154
urEnqueueMemBufferMap(queue, nullptr, true,
156155
UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE,
157-
0, size, 0, nullptr, nullptr,
158-
(void **)&map));
156+
0, size, 0, nullptr, nullptr, &map));
159157
}
160158

161159
TEST_P(urEnqueueMemBufferMapTest, InvalidEnumerationMapFlags) {
162-
uint32_t *map = nullptr;
160+
void *map = nullptr;
163161
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION,
164162
urEnqueueMemBufferMap(queue, buffer, true,
165163
UR_MAP_FLAG_FORCE_UINT32, 0, size, 0,
166-
nullptr, nullptr, (void **)&map));
164+
nullptr, nullptr, &map));
167165
}
168166

169167
TEST_P(urEnqueueMemBufferMapTest, InvalidNullPointerRetMap) {
@@ -175,10 +173,10 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullPointerRetMap) {
175173
}
176174

177175
TEST_P(urEnqueueMemBufferMapTest, InvalidNullPtrEventWaitList) {
176+
void *map;
178177
ASSERT_EQ_RESULT(urEnqueueMemBufferMap(queue, buffer, true,
179178
UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE,
180-
0, size, 1, nullptr, nullptr,
181-
nullptr),
179+
0, size, 1, nullptr, nullptr, &map),
182180
UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST);
183181

184182
ur_event_handle_t validEvent;
@@ -187,7 +185,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullPtrEventWaitList) {
187185
ASSERT_EQ_RESULT(urEnqueueMemBufferMap(queue, buffer, true,
188186
UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE,
189187
0, size, 0, &validEvent, nullptr,
190-
nullptr),
188+
&map),
191189
UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST);
192190
}
193191

test/conformance/enqueue/urEnqueueUSMFill.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct urEnqueueUSMFillTestWithParam
3030
void SetUp() override {
3131
UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp());
3232

33+
size = std::get<1>(GetParam()).size;
3334
host_mem = std::vector<uint8_t>(size);
3435
pattern_size = std::get<1>(GetParam()).pattern_size;
3536
pattern = std::vector<uint8_t>(pattern_size);

test/conformance/enqueue/urEnqueueUSMMemcpy2D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ struct urEnqueueUSMMemcpy2DTestWithParam
3838
}
3939

4040
void TearDown() override {
41-
uur::urQueueTestWithParam<uur::TestParameters2D>::TearDown();
4241
if (pSrc) {
4342
ASSERT_SUCCESS(urUSMFree(context, pSrc));
4443
}
4544
if (pDst) {
4645
ASSERT_SUCCESS(urUSMFree(context, pDst));
4746
}
47+
uur::urQueueTestWithParam<uur::TestParameters2D>::TearDown();
4848
}
4949

5050
void verifyMemcpySucceeded() {

0 commit comments

Comments
 (0)