Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class ur_result_v(IntEnum):
ERROR_INVALID_NULL_HANDLE = 48 ## [Validation] handle argument is not valid
ERROR_HANDLE_OBJECT_IN_USE = 49 ## [Validation] object pointed to by handle still in-use by device
ERROR_INVALID_NULL_POINTER = 50 ## [Validation] pointer argument may not be nullptr
ERROR_INVALID_SIZE = 51 ## [Validation] size argument is invalid (e.g., must not be zero)
ERROR_INVALID_SIZE = 51 ## [Validation] invalid size or dimensions (e.g., must not be zero, or is
## out of bounds)
ERROR_UNSUPPORTED_SIZE = 52 ## [Validation] size argument is not supported by the device (e.g., too
## large)
ERROR_UNSUPPORTED_ALIGNMENT = 53 ## [Validation] alignment argument is not supported by the device (e.g.,
Expand Down
9 changes: 8 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ typedef enum ur_result_t {
UR_RESULT_ERROR_INVALID_NULL_HANDLE = 48, ///< [Validation] handle argument is not valid
UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE = 49, ///< [Validation] object pointed to by handle still in-use by device
UR_RESULT_ERROR_INVALID_NULL_POINTER = 50, ///< [Validation] pointer argument may not be nullptr
UR_RESULT_ERROR_INVALID_SIZE = 51, ///< [Validation] size argument is invalid (e.g., must not be zero)
UR_RESULT_ERROR_INVALID_SIZE = 51, ///< [Validation] invalid size or dimensions (e.g., must not be zero, or is
///< out of bounds)
UR_RESULT_ERROR_UNSUPPORTED_SIZE = 52, ///< [Validation] size argument is not supported by the device (e.g., too
///< large)
UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT = 53, ///< [Validation] alignment argument is not supported by the device (e.g.,
Expand Down Expand Up @@ -1426,6 +1427,12 @@ urEnqueueUSMFill2D(
/// + `NULL == hQueue`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pMem`
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `pitch == 0`
/// + `width == 0`
/// + `height == 0`
/// + `pitch < width`
/// + `pitch * height` is higher than the memory allocation size
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ etors:
- name: ERROR_INVALID_NULL_POINTER
desc: "[Validation] pointer argument may not be nullptr"
- name: ERROR_INVALID_SIZE
desc: "[Validation] size argument is invalid (e.g., must not be zero)"
desc: "[Validation] invalid size or dimensions (e.g., must not be zero, or is out of bounds)"
- name: ERROR_UNSUPPORTED_SIZE
desc: "[Validation] size argument is not supported by the device (e.g., too large)"
- name: ERROR_UNSUPPORTED_ALIGNMENT
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/enqueue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,12 @@ params:
desc: |
[in,out][optional] return an event object that identifies this particular kernel execution instance.
returns:
- $X_RESULT_ERROR_INVALID_SIZE:
- "`pitch == 0`"
- "`width == 0`"
- "`height == 0`"
- "`pitch < width`"
- "`pitch * height` is higher than the memory allocation size"
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:
- "`phEventWaitList == NULL && numEventsInWaitList > 0`"
- "`phEventWaitList != NULL && numEventsInWaitList == 0`"
Expand Down
16 changes: 16 additions & 0 deletions source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,22 @@ urEnqueueUSMMemset2D(
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
}

if (pitch == 0) {
return UR_RESULT_ERROR_INVALID_SIZE;
}

if (width == 0) {
return UR_RESULT_ERROR_INVALID_SIZE;
}

if (height == 0) {
return UR_RESULT_ERROR_INVALID_SIZE;
}

if (pitch < width) {
return UR_RESULT_ERROR_INVALID_SIZE;
}

if (phEventWaitList == NULL && numEventsInWaitList > 0) {
return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST;
}
Expand Down
6 changes: 6 additions & 0 deletions source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,12 @@ urEnqueueUSMFill2D(
/// + `NULL == hQueue`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pMem`
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `pitch == 0`
/// + `width == 0`
/// + `height == 0`
/// + `pitch < width`
/// + `pitch * height` is higher than the memory allocation size
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
Expand Down
6 changes: 6 additions & 0 deletions source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,12 @@ urEnqueueUSMFill2D(
/// + `NULL == hQueue`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == pMem`
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `pitch == 0`
/// + `width == 0`
/// + `height == 0`
/// + `pitch < width`
/// + `pitch * height` is higher than the memory allocation size
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
/// + `phEventWaitList == NULL && numEventsInWaitList > 0`
/// + `phEventWaitList != NULL && numEventsInWaitList == 0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ inline void copyRect(std::vector<uint8_t> src, ur_rect_offset_t src_offset, ur_r
}
}

struct TestParameters2D {
int pitch;
int width;
int height;
};

template <typename T>
inline std::string print2DTestString(const testing::TestParamInfo<typename T::ParamType> &info) {
const auto device_handle = std::get<0>(info.param);
const auto platform_device_name = uur::GetPlatformAndDeviceName(device_handle);
std::stringstream test_name;
test_name << platform_device_name << "__pitch__" << std::get<1>(info.param).pitch << "__width__" << std::get<1>(info.param).width
<< "__height__" << std::get<1>(info.param).height;
return test_name.str();
}

} // namespace uur

#endif // UUR_ENQUEUE_RECT_HELPERS_H_INCLUDED
2 changes: 1 addition & 1 deletion test/conformance/enqueue/urEnqueueMemBufferCopyRect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: MIT
#include "rect_helpers.h"
#include "helpers.h"
#include <numeric>

static std::vector<uur::test_parameters_t> generateParameterizations() {
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/enqueue/urEnqueueMemBufferReadRect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: MIT
#include "rect_helpers.h"
#include "helpers.h"
#include <numeric>

// Choose parameters so that we get good coverage and catch some edge cases.
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/enqueue/urEnqueueMemBufferWriteRect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: MIT
#include "rect_helpers.h"
#include "helpers.h"
#include <numeric>

static std::vector<uur::test_parameters_t> generateParameterizations() {
Expand Down
21 changes: 13 additions & 8 deletions test/conformance/enqueue/urEnqueueUSMMemcpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ struct urEnqueueUSMMemcpyTest : uur::urQueueTest {
return UR_EVENT_STATUS_COMPLETE == memset_event_status;
}

bool verifyData() {
EXPECT_SUCCESS(
urEnqueueUSMMemcpy(queue, true, host_mem.data(), device_dst, allocation_size, 0, nullptr, nullptr));
return std::all_of(host_mem.begin(), host_mem.end(), [this](uint8_t i) { return i == memset_value; });
void verifyData() {
ASSERT_SUCCESS(
urEnqueueUSMMemcpy(queue, true, host_mem.data(), device_dst,
allocation_size, 0, nullptr, nullptr));
bool good = std::all_of(host_mem.begin(), host_mem.end(),
[this](uint8_t i) {
return i == memset_value;
});
ASSERT_TRUE(good);
}

const uint32_t num_elements = 1024;
Expand All @@ -71,7 +76,7 @@ TEST_P(urEnqueueUSMMemcpyTest, Blocking) {
ASSERT_SUCCESS(urEventWait(1, &memset_event));
ASSERT_TRUE(memsetHasFinished());
ASSERT_SUCCESS(urEnqueueUSMMemcpy(queue, true, device_dst, device_src, allocation_size, 0, nullptr, nullptr));
ASSERT_TRUE(verifyData());
ASSERT_NO_FATAL_FAILURE(verifyData());
}

/**
Expand All @@ -90,7 +95,7 @@ TEST_P(urEnqueueUSMMemcpyTest, BlockingWithEvent) {
&event_status, nullptr));
ASSERT_EQ(event_status, UR_EVENT_STATUS_COMPLETE);
EXPECT_SUCCESS(urEventRelease(memcpy_event));
ASSERT_TRUE(verifyData());
ASSERT_NO_FATAL_FAILURE(verifyData());
}

/**
Expand All @@ -105,7 +110,7 @@ TEST_P(urEnqueueUSMMemcpyTest, NonBlocking) {
urEnqueueUSMMemcpy(queue, false, device_dst, device_src, allocation_size, 0, nullptr, &memcpy_event));
ASSERT_SUCCESS(urEventWait(1, &memcpy_event));

ASSERT_TRUE(verifyData());
ASSERT_NO_FATAL_FAILURE(verifyData());
}

/**
Expand All @@ -115,7 +120,7 @@ TEST_P(urEnqueueUSMMemcpyTest, WaitForDependencies) {
ASSERT_SUCCESS(
urEnqueueUSMMemcpy(queue, true, device_dst, device_src, sizeof(int), 1, &memset_event, nullptr));
ASSERT_TRUE(memsetHasFinished());
ASSERT_TRUE(verifyData());
ASSERT_NO_FATAL_FAILURE(verifyData());
}

TEST_P(urEnqueueUSMMemcpyTest, InvalidNullQueueHandle) {
Expand Down
Loading