From 5b6689ae96f6884bb23a4613ec4b149f4fd5cf31 Mon Sep 17 00:00:00 2001 From: Martin Morrison-Grant Date: Thu, 7 Mar 2024 12:46:45 +0000 Subject: [PATCH] [CTS] Modify various urEnqueueMemBuffer* conformance tests to use parameterized fixtures. --- test/conformance/enqueue/helpers.h | 39 ++++++++ .../enqueue/urEnqueueMemBufferCopy.cpp | 28 +++--- .../enqueue/urEnqueueMemBufferFill.cpp | 1 + .../enqueue/urEnqueueMemBufferMap.cpp | 92 ++++++++++++++----- .../enqueue/urEnqueueMemBufferRead.cpp | 62 ++++++++++--- .../enqueue/urEnqueueMemBufferWrite.cpp | 58 ++++++++++-- .../conformance/enqueue/urEnqueueMemUnmap.cpp | 63 +++++++++++-- .../testing/include/uur/fixtures.h | 41 +++++---- 8 files changed, 302 insertions(+), 82 deletions(-) diff --git a/test/conformance/enqueue/helpers.h b/test/conformance/enqueue/helpers.h index 6fc8dfacba..807ca46a19 100644 --- a/test/conformance/enqueue/helpers.h +++ b/test/conformance/enqueue/helpers.h @@ -96,6 +96,45 @@ print2DTestString(const testing::TestParamInfo &info) { return test_name.str(); } +struct mem_buffer_test_parameters_t { + size_t count; + ur_mem_flag_t mem_flag; +}; + +struct mem_buffer_map_write_test_parameters_t { + size_t count; + ur_mem_flag_t mem_flag; + ur_map_flag_t map_flag; +}; + +template +inline std::string printMemBufferTestString( + const testing::TestParamInfo &info) { + // ParamType will be std::tuple + const auto device_handle = std::get<0>(info.param); + const auto platform_device_name = GetPlatformAndDeviceName(device_handle); + + std::stringstream ss; + ss << std::get<1>(info.param).count; + ss << "_"; + ss << std::get<1>(info.param).mem_flag; + + return platform_device_name + "__" + ss.str(); +} + +template +inline std::string printMemBufferMapWriteTestString( + const testing::TestParamInfo &info) { + // ParamType will be std::tuple + const auto device_handle = std::get<0>(info.param); + const auto platform_device_name = GetPlatformAndDeviceName(device_handle); + + std::stringstream ss; + ss << std::get<1>(info.param).map_flag; + + return platform_device_name + "__" + ss.str(); +} + } // namespace uur #endif // UUR_ENQUEUE_RECT_HELPERS_H_INCLUDED diff --git a/test/conformance/enqueue/urEnqueueMemBufferCopy.cpp b/test/conformance/enqueue/urEnqueueMemBufferCopy.cpp index fb51f789d2..0902e8edc2 100644 --- a/test/conformance/enqueue/urEnqueueMemBufferCopy.cpp +++ b/test/conformance/enqueue/urEnqueueMemBufferCopy.cpp @@ -3,11 +3,12 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include -struct urEnqueueMemBufferCopyTest : uur::urQueueTest { +struct urEnqueueMemBufferCopyTestWithParam : uur::urQueueTestWithParam { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp()); ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_WRITE_ONLY, size, nullptr, &src_buffer)); ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_ONLY, size, @@ -25,18 +26,23 @@ struct urEnqueueMemBufferCopyTest : uur::urQueueTest { if (src_buffer) { EXPECT_SUCCESS(urMemRelease(dst_buffer)); } - urQueueTest::TearDown(); + urQueueTestWithParam::TearDown(); } - const size_t count = 1024; + const size_t count = std::get<1>(this->GetParam()); const size_t size = sizeof(uint32_t) * count; ur_mem_handle_t src_buffer = nullptr; ur_mem_handle_t dst_buffer = nullptr; std::vector input; }; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemBufferCopyTest); -TEST_P(urEnqueueMemBufferCopyTest, Success) { +static std::vector test_parameters{8, 16, 32, 64, 128, 256, 512, 1024}; + +UUR_TEST_SUITE_P(urEnqueueMemBufferCopyTestWithParam, + ::testing::ValuesIn(test_parameters), + uur::deviceTestWithParamPrinter); + +TEST_P(urEnqueueMemBufferCopyTestWithParam, Success) { ASSERT_SUCCESS(urEnqueueMemBufferCopy(queue, src_buffer, dst_buffer, 0, 0, size, 0, nullptr, nullptr)); std::vector output(count, 1); @@ -45,25 +51,25 @@ TEST_P(urEnqueueMemBufferCopyTest, Success) { ASSERT_EQ(input, output); } -TEST_P(urEnqueueMemBufferCopyTest, InvalidNullHandleQueue) { +TEST_P(urEnqueueMemBufferCopyTestWithParam, InvalidNullHandleQueue) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferCopy(nullptr, src_buffer, dst_buffer, 0, 0, size, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferCopyTest, InvalidNullHandleBufferSrc) { +TEST_P(urEnqueueMemBufferCopyTestWithParam, InvalidNullHandleBufferSrc) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferCopy(queue, nullptr, dst_buffer, 0, 0, size, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferCopyTest, InvalidNullHandleBufferDst) { +TEST_P(urEnqueueMemBufferCopyTestWithParam, InvalidNullHandleBufferDst) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferCopy(queue, src_buffer, nullptr, 0, 0, size, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferCopyTest, InvalidNullPtrEventWaitList) { +TEST_P(urEnqueueMemBufferCopyTestWithParam, InvalidNullPtrEventWaitList) { ASSERT_EQ_RESULT(urEnqueueMemBufferCopy(queue, src_buffer, dst_buffer, 0, 0, size, 1, nullptr, nullptr), UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); @@ -83,7 +89,7 @@ TEST_P(urEnqueueMemBufferCopyTest, InvalidNullPtrEventWaitList) { ASSERT_SUCCESS(urEventRelease(validEvent)); } -TEST_P(urEnqueueMemBufferCopyTest, InvalidSize) { +TEST_P(urEnqueueMemBufferCopyTestWithParam, InvalidSize) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urEnqueueMemBufferCopy(queue, src_buffer, dst_buffer, 1, 0, size, 0, nullptr, nullptr)); diff --git a/test/conformance/enqueue/urEnqueueMemBufferFill.cpp b/test/conformance/enqueue/urEnqueueMemBufferFill.cpp index 0ca75c45b9..05f6047ba4 100644 --- a/test/conformance/enqueue/urEnqueueMemBufferFill.cpp +++ b/test/conformance/enqueue/urEnqueueMemBufferFill.cpp @@ -2,6 +2,7 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include struct testParametersFill { diff --git a/test/conformance/enqueue/urEnqueueMemBufferMap.cpp b/test/conformance/enqueue/urEnqueueMemBufferMap.cpp index 4e9af10592..f31826fcef 100644 --- a/test/conformance/enqueue/urEnqueueMemBufferMap.cpp +++ b/test/conformance/enqueue/urEnqueueMemBufferMap.cpp @@ -2,12 +2,52 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include -using urEnqueueMemBufferMapTest = uur::urMemBufferQueueTest; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemBufferMapTest); - -TEST_P(urEnqueueMemBufferMapTest, SuccessRead) { +using urEnqueueMemBufferMapTestWithParam = + uur::urMemBufferQueueTestWithParam; + +static std::vector test_parameters{ + {8, UR_MEM_FLAG_READ_WRITE}, + {16, UR_MEM_FLAG_READ_WRITE}, + {32, UR_MEM_FLAG_READ_WRITE}, + {64, UR_MEM_FLAG_READ_WRITE}, + {128, UR_MEM_FLAG_READ_WRITE}, + {256, UR_MEM_FLAG_READ_WRITE}, + {512, UR_MEM_FLAG_READ_WRITE}, + {1024, UR_MEM_FLAG_READ_WRITE}, + {8, UR_MEM_FLAG_WRITE_ONLY}, + {16, UR_MEM_FLAG_WRITE_ONLY}, + {32, UR_MEM_FLAG_WRITE_ONLY}, + {64, UR_MEM_FLAG_WRITE_ONLY}, + {128, UR_MEM_FLAG_WRITE_ONLY}, + {256, UR_MEM_FLAG_WRITE_ONLY}, + {512, UR_MEM_FLAG_WRITE_ONLY}, + {1024, UR_MEM_FLAG_WRITE_ONLY}, + {8, UR_MEM_FLAG_READ_ONLY}, + {16, UR_MEM_FLAG_READ_ONLY}, + {32, UR_MEM_FLAG_READ_ONLY}, + {64, UR_MEM_FLAG_READ_ONLY}, + {128, UR_MEM_FLAG_READ_ONLY}, + {256, UR_MEM_FLAG_READ_ONLY}, + {512, UR_MEM_FLAG_READ_ONLY}, + {1024, UR_MEM_FLAG_READ_ONLY}, + {8, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {16, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {32, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {64, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {128, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {256, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {512, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {1024, UR_MEM_FLAG_ALLOC_HOST_POINTER}, +}; + +UUR_TEST_SUITE_P( + urEnqueueMemBufferMapTestWithParam, ::testing::ValuesIn(test_parameters), + uur::printMemBufferTestString); + +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccessRead) { const std::vector input(count, 42); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); @@ -21,12 +61,20 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessRead) { } } +static std::vector + map_write_test_parameters{ + {8, UR_MEM_FLAG_READ_WRITE, UR_MAP_FLAG_WRITE}, + {8, UR_MEM_FLAG_READ_WRITE, UR_MAP_FLAG_WRITE_INVALIDATE_REGION}, + }; + using urEnqueueMemBufferMapTestWithWriteFlagParam = - uur::urMemBufferQueueTestWithParam; + uur::urMemBufferQueueTestWithParam< + uur::mem_buffer_map_write_test_parameters_t>; + UUR_TEST_SUITE_P(urEnqueueMemBufferMapTestWithWriteFlagParam, - ::testing::Values(UR_MAP_FLAG_WRITE, - UR_MAP_FLAG_WRITE_INVALIDATE_REGION), - uur::deviceTestWithParamPrinter); + ::testing::ValuesIn(map_write_test_parameters), + uur::printMemBufferMapWriteTestString< + urEnqueueMemBufferMapTestWithWriteFlagParam>); TEST_P(urEnqueueMemBufferMapTestWithWriteFlagParam, SuccessWrite) { const std::vector input(count, 0); @@ -34,9 +82,9 @@ TEST_P(urEnqueueMemBufferMapTestWithWriteFlagParam, SuccessWrite) { input.data(), 0, nullptr, nullptr)); uint32_t *map = nullptr; - ASSERT_SUCCESS(urEnqueueMemBufferMap(queue, buffer, true, getParam(), 0, - size, 0, nullptr, nullptr, - (void **)&map)); + ASSERT_SUCCESS(urEnqueueMemBufferMap(queue, buffer, true, + getParam().map_flag, 0, size, 0, + nullptr, nullptr, (void **)&map)); for (unsigned i = 0; i < count; ++i) { map[i] = 42; } @@ -49,7 +97,7 @@ TEST_P(urEnqueueMemBufferMapTestWithWriteFlagParam, SuccessWrite) { } } -TEST_P(urEnqueueMemBufferMapTest, SuccessOffset) { +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccessOffset) { const std::vector input(count, 0); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); @@ -78,7 +126,7 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessOffset) { } } -TEST_P(urEnqueueMemBufferMapTest, SuccessPartialMap) { +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccessPartialMap) { const std::vector input(count, 0); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); @@ -106,7 +154,7 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessPartialMap) { } } -TEST_P(urEnqueueMemBufferMapTest, SuccesPinnedRead) { +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccesPinnedRead) { const size_t memSize = sizeof(int); const int value = 20; @@ -130,7 +178,7 @@ TEST_P(urEnqueueMemBufferMapTest, SuccesPinnedRead) { ASSERT_SUCCESS(urMemRelease(memObj)); } -TEST_P(urEnqueueMemBufferMapTest, SuccesPinnedWrite) { +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccesPinnedWrite) { const size_t memSize = sizeof(int); const int value = 30; @@ -157,7 +205,7 @@ TEST_P(urEnqueueMemBufferMapTest, SuccesPinnedWrite) { ASSERT_SUCCESS(urMemRelease(memObj)); } -TEST_P(urEnqueueMemBufferMapTest, SuccessMultiMaps) { +TEST_P(urEnqueueMemBufferMapTestWithParam, SuccessMultiMaps) { const std::vector input(count, 0); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); @@ -198,7 +246,7 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessMultiMaps) { } } -TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleQueue) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidNullHandleQueue) { void *map = nullptr; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferMap(nullptr, buffer, true, @@ -206,7 +254,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleQueue) { 0, size, 0, nullptr, nullptr, &map)); } -TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleBuffer) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidNullHandleBuffer) { void *map = nullptr; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferMap(queue, nullptr, true, @@ -214,7 +262,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullHandleBuffer) { 0, size, 0, nullptr, nullptr, &map)); } -TEST_P(urEnqueueMemBufferMapTest, InvalidEnumerationMapFlags) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidEnumerationMapFlags) { void *map = nullptr; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, urEnqueueMemBufferMap(queue, buffer, true, @@ -222,7 +270,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidEnumerationMapFlags) { nullptr, nullptr, &map)); } -TEST_P(urEnqueueMemBufferMapTest, InvalidNullPointerRetMap) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidNullPointerRetMap) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, urEnqueueMemBufferMap(queue, buffer, true, UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE, @@ -230,7 +278,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullPointerRetMap) { nullptr)); } -TEST_P(urEnqueueMemBufferMapTest, InvalidNullPtrEventWaitList) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidNullPtrEventWaitList) { void *map; ASSERT_EQ_RESULT(urEnqueueMemBufferMap(queue, buffer, true, UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE, @@ -255,7 +303,7 @@ TEST_P(urEnqueueMemBufferMapTest, InvalidNullPtrEventWaitList) { ASSERT_SUCCESS(urEventRelease(validEvent)); } -TEST_P(urEnqueueMemBufferMapTest, InvalidSize) { +TEST_P(urEnqueueMemBufferMapTestWithParam, InvalidSize) { void *map = nullptr; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urEnqueueMemBufferMap(queue, buffer, true, 0, 1, size, 0, diff --git a/test/conformance/enqueue/urEnqueueMemBufferRead.cpp b/test/conformance/enqueue/urEnqueueMemBufferRead.cpp index fa3c2ec4a4..d481a4805b 100644 --- a/test/conformance/enqueue/urEnqueueMemBufferRead.cpp +++ b/test/conformance/enqueue/urEnqueueMemBufferRead.cpp @@ -2,18 +2,58 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include -using urEnqueueMemBufferReadTest = uur::urMemBufferQueueTest; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemBufferReadTest); - -TEST_P(urEnqueueMemBufferReadTest, Success) { +using urEnqueueMemBufferReadTestWithParam = + uur::urMemBufferQueueTestWithParam; + +static std::vector test_parameters{ + {8, UR_MEM_FLAG_READ_WRITE}, + {16, UR_MEM_FLAG_READ_WRITE}, + {32, UR_MEM_FLAG_READ_WRITE}, + {64, UR_MEM_FLAG_READ_WRITE}, + {128, UR_MEM_FLAG_READ_WRITE}, + {256, UR_MEM_FLAG_READ_WRITE}, + {512, UR_MEM_FLAG_READ_WRITE}, + {1024, UR_MEM_FLAG_READ_WRITE}, + {8, UR_MEM_FLAG_WRITE_ONLY}, + {16, UR_MEM_FLAG_WRITE_ONLY}, + {32, UR_MEM_FLAG_WRITE_ONLY}, + {64, UR_MEM_FLAG_WRITE_ONLY}, + {128, UR_MEM_FLAG_WRITE_ONLY}, + {256, UR_MEM_FLAG_WRITE_ONLY}, + {512, UR_MEM_FLAG_WRITE_ONLY}, + {1024, UR_MEM_FLAG_WRITE_ONLY}, + {8, UR_MEM_FLAG_READ_ONLY}, + {16, UR_MEM_FLAG_READ_ONLY}, + {32, UR_MEM_FLAG_READ_ONLY}, + {64, UR_MEM_FLAG_READ_ONLY}, + {128, UR_MEM_FLAG_READ_ONLY}, + {256, UR_MEM_FLAG_READ_ONLY}, + {512, UR_MEM_FLAG_READ_ONLY}, + {1024, UR_MEM_FLAG_READ_ONLY}, + {8, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {16, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {32, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {64, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {128, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {256, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {512, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {1024, UR_MEM_FLAG_ALLOC_HOST_POINTER}, +}; + +UUR_TEST_SUITE_P( + urEnqueueMemBufferReadTestWithParam, ::testing::ValuesIn(test_parameters), + uur::printMemBufferTestString); + +TEST_P(urEnqueueMemBufferReadTestWithParam, Success) { std::vector output(count, 42); ASSERT_SUCCESS(urEnqueueMemBufferRead(queue, buffer, true, 0, size, output.data(), 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferReadTest, InvalidNullHandleQueue) { +TEST_P(urEnqueueMemBufferReadTestWithParam, InvalidNullHandleQueue) { std::vector output(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferRead(nullptr, buffer, true, 0, size, @@ -21,7 +61,7 @@ TEST_P(urEnqueueMemBufferReadTest, InvalidNullHandleQueue) { nullptr)); } -TEST_P(urEnqueueMemBufferReadTest, InvalidNullHandleBuffer) { +TEST_P(urEnqueueMemBufferReadTestWithParam, InvalidNullHandleBuffer) { std::vector output(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferRead(queue, nullptr, true, 0, size, @@ -29,14 +69,14 @@ TEST_P(urEnqueueMemBufferReadTest, InvalidNullHandleBuffer) { nullptr)); } -TEST_P(urEnqueueMemBufferReadTest, InvalidNullPointerDst) { +TEST_P(urEnqueueMemBufferReadTestWithParam, InvalidNullPointerDst) { std::vector output(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, urEnqueueMemBufferRead(queue, buffer, true, 0, size, nullptr, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferReadTest, InvalidNullPtrEventWaitList) { +TEST_P(urEnqueueMemBufferReadTestWithParam, InvalidNullPtrEventWaitList) { std::vector output(count, 42); ASSERT_EQ_RESULT(urEnqueueMemBufferRead(queue, buffer, true, 0, size, output.data(), 1, nullptr, nullptr), @@ -59,7 +99,7 @@ TEST_P(urEnqueueMemBufferReadTest, InvalidNullPtrEventWaitList) { ASSERT_SUCCESS(urEventRelease(validEvent)); } -TEST_P(urEnqueueMemBufferReadTest, InvalidSize) { +TEST_P(urEnqueueMemBufferReadTestWithParam, InvalidSize) { std::vector output(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urEnqueueMemBufferRead(queue, buffer, true, 1, size, @@ -67,7 +107,7 @@ TEST_P(urEnqueueMemBufferReadTest, InvalidSize) { nullptr)); } -TEST_P(urEnqueueMemBufferReadTest, Blocking) { +TEST_P(urEnqueueMemBufferReadTestWithParam, Blocking) { constexpr const size_t memSize = 10u; constexpr const size_t bytes = memSize * sizeof(int); const int data[memSize] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -93,7 +133,7 @@ TEST_P(urEnqueueMemBufferReadTest, Blocking) { } } -TEST_P(urEnqueueMemBufferReadTest, NonBlocking) { +TEST_P(urEnqueueMemBufferReadTestWithParam, NonBlocking) { constexpr const size_t memSize = 10u; constexpr const size_t bytes = memSize * sizeof(int); const int data[memSize] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/test/conformance/enqueue/urEnqueueMemBufferWrite.cpp b/test/conformance/enqueue/urEnqueueMemBufferWrite.cpp index 27ceefa3d1..fa4cc7dfd1 100644 --- a/test/conformance/enqueue/urEnqueueMemBufferWrite.cpp +++ b/test/conformance/enqueue/urEnqueueMemBufferWrite.cpp @@ -2,18 +2,58 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include -using urEnqueueMemBufferWriteTest = uur::urMemBufferQueueTest; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemBufferWriteTest); +using urEnqueueMemBufferWriteTestWithParam = + uur::urMemBufferQueueTestWithParam; -TEST_P(urEnqueueMemBufferWriteTest, Success) { +static std::vector test_parameters{ + {8, UR_MEM_FLAG_READ_WRITE}, + {16, UR_MEM_FLAG_READ_WRITE}, + {32, UR_MEM_FLAG_READ_WRITE}, + {64, UR_MEM_FLAG_READ_WRITE}, + {128, UR_MEM_FLAG_READ_WRITE}, + {256, UR_MEM_FLAG_READ_WRITE}, + {512, UR_MEM_FLAG_READ_WRITE}, + {1024, UR_MEM_FLAG_READ_WRITE}, + {8, UR_MEM_FLAG_WRITE_ONLY}, + {16, UR_MEM_FLAG_WRITE_ONLY}, + {32, UR_MEM_FLAG_WRITE_ONLY}, + {64, UR_MEM_FLAG_WRITE_ONLY}, + {128, UR_MEM_FLAG_WRITE_ONLY}, + {256, UR_MEM_FLAG_WRITE_ONLY}, + {512, UR_MEM_FLAG_WRITE_ONLY}, + {1024, UR_MEM_FLAG_WRITE_ONLY}, + {8, UR_MEM_FLAG_READ_ONLY}, + {16, UR_MEM_FLAG_READ_ONLY}, + {32, UR_MEM_FLAG_READ_ONLY}, + {64, UR_MEM_FLAG_READ_ONLY}, + {128, UR_MEM_FLAG_READ_ONLY}, + {256, UR_MEM_FLAG_READ_ONLY}, + {512, UR_MEM_FLAG_READ_ONLY}, + {1024, UR_MEM_FLAG_READ_ONLY}, + {8, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {16, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {32, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {64, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {128, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {256, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {512, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {1024, UR_MEM_FLAG_ALLOC_HOST_POINTER}, +}; + +UUR_TEST_SUITE_P( + urEnqueueMemBufferWriteTestWithParam, ::testing::ValuesIn(test_parameters), + uur::printMemBufferTestString); + +TEST_P(urEnqueueMemBufferWriteTestWithParam, Success) { std::vector input(count, 42); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferWriteTest, SuccessWriteRead) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, SuccessWriteRead) { std::vector input(count, 42); ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 0, nullptr, nullptr)); @@ -25,7 +65,7 @@ TEST_P(urEnqueueMemBufferWriteTest, SuccessWriteRead) { } } -TEST_P(urEnqueueMemBufferWriteTest, InvalidNullHandleQueue) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, InvalidNullHandleQueue) { std::vector input(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferWrite(nullptr, buffer, true, 0, size, @@ -33,7 +73,7 @@ TEST_P(urEnqueueMemBufferWriteTest, InvalidNullHandleQueue) { nullptr)); } -TEST_P(urEnqueueMemBufferWriteTest, InvalidNullHandleBuffer) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, InvalidNullHandleBuffer) { std::vector input(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemBufferWrite(queue, nullptr, true, 0, size, @@ -41,14 +81,14 @@ TEST_P(urEnqueueMemBufferWriteTest, InvalidNullHandleBuffer) { nullptr)); } -TEST_P(urEnqueueMemBufferWriteTest, InvalidNullPointerSrc) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, InvalidNullPointerSrc) { std::vector input(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, urEnqueueMemBufferWrite(queue, buffer, true, 0, size, nullptr, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemBufferWriteTest, InvalidNullPtrEventWaitList) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, InvalidNullPtrEventWaitList) { std::vector input(count, 42); ASSERT_EQ_RESULT(urEnqueueMemBufferWrite(queue, buffer, true, 0, size, input.data(), 1, nullptr, nullptr), @@ -71,7 +111,7 @@ TEST_P(urEnqueueMemBufferWriteTest, InvalidNullPtrEventWaitList) { ASSERT_SUCCESS(urEventRelease(validEvent)); } -TEST_P(urEnqueueMemBufferWriteTest, InvalidSize) { +TEST_P(urEnqueueMemBufferWriteTestWithParam, InvalidSize) { std::vector output(count, 42); ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urEnqueueMemBufferWrite(queue, buffer, true, 1, size, diff --git a/test/conformance/enqueue/urEnqueueMemUnmap.cpp b/test/conformance/enqueue/urEnqueueMemUnmap.cpp index a669ee26e3..01fa945547 100644 --- a/test/conformance/enqueue/urEnqueueMemUnmap.cpp +++ b/test/conformance/enqueue/urEnqueueMemUnmap.cpp @@ -2,45 +2,90 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include "helpers.h" #include -struct urEnqueueMemUnmapTest : public uur::urMemBufferQueueTest { +struct urEnqueueMemUnmapTestWithParam + : uur::urMemBufferQueueTestWithParam { void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(uur::urMemBufferQueueTest::SetUp()); + UUR_RETURN_ON_FATAL_FAILURE( + uur::urMemBufferQueueTestWithParam< + uur::mem_buffer_test_parameters_t>::SetUp()); ASSERT_SUCCESS(urEnqueueMemBufferMap( queue, buffer, true, UR_MAP_FLAG_READ | UR_MAP_FLAG_WRITE, 0, size, 0, nullptr, nullptr, (void **)&map)); }; - void TearDown() override { uur::urMemBufferQueueTest::TearDown(); } + void TearDown() override { + uur::urMemBufferQueueTestWithParam< + uur::mem_buffer_test_parameters_t>::TearDown(); + } uint32_t *map = nullptr; }; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueMemUnmapTest); -TEST_P(urEnqueueMemUnmapTest, Success) { +static std::vector test_parameters{ + {8, UR_MEM_FLAG_READ_WRITE}, + {16, UR_MEM_FLAG_READ_WRITE}, + {32, UR_MEM_FLAG_READ_WRITE}, + {64, UR_MEM_FLAG_READ_WRITE}, + {128, UR_MEM_FLAG_READ_WRITE}, + {256, UR_MEM_FLAG_READ_WRITE}, + {512, UR_MEM_FLAG_READ_WRITE}, + {1024, UR_MEM_FLAG_READ_WRITE}, + {8, UR_MEM_FLAG_WRITE_ONLY}, + {16, UR_MEM_FLAG_WRITE_ONLY}, + {32, UR_MEM_FLAG_WRITE_ONLY}, + {64, UR_MEM_FLAG_WRITE_ONLY}, + {128, UR_MEM_FLAG_WRITE_ONLY}, + {256, UR_MEM_FLAG_WRITE_ONLY}, + {512, UR_MEM_FLAG_WRITE_ONLY}, + {1024, UR_MEM_FLAG_WRITE_ONLY}, + {8, UR_MEM_FLAG_READ_ONLY}, + {16, UR_MEM_FLAG_READ_ONLY}, + {32, UR_MEM_FLAG_READ_ONLY}, + {64, UR_MEM_FLAG_READ_ONLY}, + {128, UR_MEM_FLAG_READ_ONLY}, + {256, UR_MEM_FLAG_READ_ONLY}, + {512, UR_MEM_FLAG_READ_ONLY}, + {1024, UR_MEM_FLAG_READ_ONLY}, + {8, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {16, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {32, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {64, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {128, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {256, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {512, UR_MEM_FLAG_ALLOC_HOST_POINTER}, + {1024, UR_MEM_FLAG_ALLOC_HOST_POINTER}, +}; + +UUR_TEST_SUITE_P(urEnqueueMemUnmapTestWithParam, + ::testing::ValuesIn(test_parameters), + uur::printMemBufferTestString); + +TEST_P(urEnqueueMemUnmapTestWithParam, Success) { ASSERT_SUCCESS(urEnqueueMemUnmap(queue, buffer, map, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemUnmapTest, InvalidNullHandleQueue) { +TEST_P(urEnqueueMemUnmapTestWithParam, InvalidNullHandleQueue) { ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemUnmap(nullptr, buffer, map, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemUnmapTest, InvalidNullHandleMem) { +TEST_P(urEnqueueMemUnmapTestWithParam, InvalidNullHandleMem) { ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_HANDLE, urEnqueueMemUnmap(queue, nullptr, map, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemUnmapTest, InvalidNullPtrMap) { +TEST_P(urEnqueueMemUnmapTestWithParam, InvalidNullPtrMap) { ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_POINTER, urEnqueueMemUnmap(queue, buffer, nullptr, 0, nullptr, nullptr)); } -TEST_P(urEnqueueMemUnmapTest, InvalidNullPtrEventWaitList) { +TEST_P(urEnqueueMemUnmapTestWithParam, InvalidNullPtrEventWaitList) { ASSERT_EQ_RESULT(urEnqueueMemUnmap(queue, buffer, map, 1, nullptr, nullptr), UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST); diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 8e0c86f9b3..332413dcd8 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -379,6 +379,27 @@ template struct urQueueTestWithParam : urContextTestWithParam { ur_queue_handle_t queue; }; +template +struct urMemBufferQueueTestWithParam : urQueueTestWithParam { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp()); + ASSERT_SUCCESS( + urMemBufferCreate(this->context, mem_flag, size, nullptr, &buffer)); + } + + void TearDown() override { + if (buffer) { + EXPECT_SUCCESS(urMemRelease(buffer)); + } + UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::TearDown()); + } + + const size_t count = this->getParam().count; + const size_t size = sizeof(uint32_t) * count; + ur_mem_handle_t buffer = nullptr; + ur_mem_flag_t mem_flag = this->getParam().mem_flag; +}; + struct urProfilingQueueTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); @@ -526,26 +547,6 @@ struct urMemBufferQueueTest : urQueueTest { ur_mem_handle_t buffer = nullptr; }; -template -struct urMemBufferQueueTestWithParam : urQueueTestWithParam { - void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam::SetUp()); - ASSERT_SUCCESS(urMemBufferCreate(this->context, UR_MEM_FLAG_READ_WRITE, - size, nullptr, &buffer)); - } - - void TearDown() override { - if (buffer) { - EXPECT_SUCCESS(urMemRelease(buffer)); - } - UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam::TearDown()); - } - - const size_t count = 8; - const size_t size = sizeof(uint32_t) * count; - ur_mem_handle_t buffer = nullptr; -}; - struct urMemImageQueueTest : urQueueTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());