Skip to content

Commit 89f6a4a

Browse files
author
Fábio
authored
Add tests for urEnqueueUSMMemset2D (#297)
1 parent 35e2b8c commit 89f6a4a

File tree

13 files changed

+285
-14
lines changed

13 files changed

+285
-14
lines changed

include/ur.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class ur_result_v(IntEnum):
169169
ERROR_INVALID_NULL_HANDLE = 48 ## [Validation] handle argument is not valid
170170
ERROR_HANDLE_OBJECT_IN_USE = 49 ## [Validation] object pointed to by handle still in-use by device
171171
ERROR_INVALID_NULL_POINTER = 50 ## [Validation] pointer argument may not be nullptr
172-
ERROR_INVALID_SIZE = 51 ## [Validation] size argument is invalid (e.g., must not be zero)
172+
ERROR_INVALID_SIZE = 51 ## [Validation] invalid size or dimensions (e.g., must not be zero, or is
173+
## out of bounds)
173174
ERROR_UNSUPPORTED_SIZE = 52 ## [Validation] size argument is not supported by the device (e.g., too
174175
## large)
175176
ERROR_UNSUPPORTED_ALIGNMENT = 53 ## [Validation] alignment argument is not supported by the device (e.g.,

include/ur_api.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ typedef enum ur_result_t {
192192
UR_RESULT_ERROR_INVALID_NULL_HANDLE = 48, ///< [Validation] handle argument is not valid
193193
UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE = 49, ///< [Validation] object pointed to by handle still in-use by device
194194
UR_RESULT_ERROR_INVALID_NULL_POINTER = 50, ///< [Validation] pointer argument may not be nullptr
195-
UR_RESULT_ERROR_INVALID_SIZE = 51, ///< [Validation] size argument is invalid (e.g., must not be zero)
195+
UR_RESULT_ERROR_INVALID_SIZE = 51, ///< [Validation] invalid size or dimensions (e.g., must not be zero, or is
196+
///< out of bounds)
196197
UR_RESULT_ERROR_UNSUPPORTED_SIZE = 52, ///< [Validation] size argument is not supported by the device (e.g., too
197198
///< large)
198199
UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT = 53, ///< [Validation] alignment argument is not supported by the device (e.g.,
@@ -1426,6 +1427,12 @@ urEnqueueUSMFill2D(
14261427
/// + `NULL == hQueue`
14271428
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
14281429
/// + `NULL == pMem`
1430+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1431+
/// + `pitch == 0`
1432+
/// + `width == 0`
1433+
/// + `height == 0`
1434+
/// + `pitch < width`
1435+
/// + `pitch * height` is higher than the memory allocation size
14291436
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
14301437
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
14311438
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`

scripts/core/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ etors:
225225
- name: ERROR_INVALID_NULL_POINTER
226226
desc: "[Validation] pointer argument may not be nullptr"
227227
- name: ERROR_INVALID_SIZE
228-
desc: "[Validation] size argument is invalid (e.g., must not be zero)"
228+
desc: "[Validation] invalid size or dimensions (e.g., must not be zero, or is out of bounds)"
229229
- name: ERROR_UNSUPPORTED_SIZE
230230
desc: "[Validation] size argument is not supported by the device (e.g., too large)"
231231
- name: ERROR_UNSUPPORTED_ALIGNMENT

scripts/core/enqueue.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,12 @@ params:
11771177
desc: |
11781178
[in,out][optional] return an event object that identifies this particular kernel execution instance.
11791179
returns:
1180+
- $X_RESULT_ERROR_INVALID_SIZE:
1181+
- "`pitch == 0`"
1182+
- "`width == 0`"
1183+
- "`height == 0`"
1184+
- "`pitch < width`"
1185+
- "`pitch * height` is higher than the memory allocation size"
11801186
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
11811187
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
11821188
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,22 @@ urEnqueueUSMMemset2D(
12001200
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
12011201
}
12021202

1203+
if (pitch == 0) {
1204+
return UR_RESULT_ERROR_INVALID_SIZE;
1205+
}
1206+
1207+
if (width == 0) {
1208+
return UR_RESULT_ERROR_INVALID_SIZE;
1209+
}
1210+
1211+
if (height == 0) {
1212+
return UR_RESULT_ERROR_INVALID_SIZE;
1213+
}
1214+
1215+
if (pitch < width) {
1216+
return UR_RESULT_ERROR_INVALID_SIZE;
1217+
}
1218+
12031219
if (phEventWaitList == NULL && numEventsInWaitList > 0) {
12041220
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
12051221
}

source/loader/ur_libapi.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,12 @@ urEnqueueUSMFill2D(
12881288
/// + `NULL == hQueue`
12891289
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
12901290
/// + `NULL == pMem`
1291+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1292+
/// + `pitch == 0`
1293+
/// + `width == 0`
1294+
/// + `height == 0`
1295+
/// + `pitch < width`
1296+
/// + `pitch * height` is higher than the memory allocation size
12911297
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
12921298
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
12931299
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`

source/ur_api.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,12 @@ urEnqueueUSMFill2D(
11771177
/// + `NULL == hQueue`
11781178
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
11791179
/// + `NULL == pMem`
1180+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1181+
/// + `pitch == 0`
1182+
/// + `width == 0`
1183+
/// + `height == 0`
1184+
/// + `pitch < width`
1185+
/// + `pitch * height` is higher than the memory allocation size
11801186
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
11811187
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
11821188
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`

test/conformance/enqueue/rect_helpers.h renamed to test/conformance/enqueue/helpers.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ inline void copyRect(std::vector<uint8_t> src, ur_rect_offset_t src_offset, ur_r
5353
}
5454
}
5555

56+
struct TestParameters2D {
57+
int pitch;
58+
int width;
59+
int height;
60+
};
61+
62+
template <typename T>
63+
inline std::string print2DTestString(const testing::TestParamInfo<typename T::ParamType> &info) {
64+
const auto device_handle = std::get<0>(info.param);
65+
const auto platform_device_name = uur::GetPlatformAndDeviceName(device_handle);
66+
std::stringstream test_name;
67+
test_name << platform_device_name << "__pitch__" << std::get<1>(info.param).pitch << "__width__" << std::get<1>(info.param).width
68+
<< "__height__" << std::get<1>(info.param).height;
69+
return test_name.str();
70+
}
71+
5672
} // namespace uur
5773

5874
#endif // UUR_ENQUEUE_RECT_HELPERS_H_INCLUDED

test/conformance/enqueue/urEnqueueMemBufferCopyRect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (C) 2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
3-
#include "rect_helpers.h"
3+
#include "helpers.h"
44
#include <numeric>
55

66
static std::vector<uur::test_parameters_t> generateParameterizations() {

test/conformance/enqueue/urEnqueueMemBufferReadRect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (C) 2023 Intel Corporation
22
// SPDX-License-Identifier: MIT
3-
#include "rect_helpers.h"
3+
#include "helpers.h"
44
#include <numeric>
55

66
// Choose parameters so that we get good coverage and catch some edge cases.

0 commit comments

Comments
 (0)