diff --git a/test/conformance/queue/queue_adapter_native_cpu.match b/test/conformance/queue/queue_adapter_native_cpu.match index 9ae8f7c03a..1c48a80fed 100644 --- a/test/conformance/queue/queue_adapter_native_cpu.match +++ b/test/conformance/queue/queue_adapter_native_cpu.match @@ -3,12 +3,12 @@ urQueueCreateTest.CheckContext/* urQueueCreateWithParamTest.SuccessWithProperties/* urQueueCreateWithParamTest.MatchingDeviceHandles/* urQueueFlushTest.Success/* -urQueueGetInfoTestWithInfoParam.Success/*__UR_QUEUE_INFO_CONTEXT -urQueueGetInfoTestWithInfoParam.Success/*__UR_QUEUE_INFO_DEVICE -urQueueGetInfoTestWithInfoParam.Success/*__UR_QUEUE_INFO_FLAGS -urQueueGetInfoTestWithInfoParam.Success/*__UR_QUEUE_INFO_REFERENCE_COUNT -urQueueGetInfoTestWithInfoParam.Success/*__UR_QUEUE_INFO_EMPTY -urQueueGetInfoDeviceQueueTestWithInfoParam.Success/* +urQueueGetInfoTest.Context/* +urQueueGetInfoTest.Device/* +urQueueGetInfoTest.Flags/* +urQueueGetInfoTest.ReferenceCount/* urQueueGetInfoTest.InvalidSizeSmall/* +urQueueGetInfoDeviceQueueTestWithInfoParam.DeviceDefault/* +urQueueGetInfoDeviceQueueTestWithInfoParam.Size/* urQueueRetainTest.Success/* urQueueReleaseTest.Success/* diff --git a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp index 06cfe5c0bd..db1c161023 100644 --- a/test/conformance/queue/urQueueCreateWithNativeHandle.cpp +++ b/test/conformance/queue/urQueueCreateWithNativeHandle.cpp @@ -54,33 +54,3 @@ TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullPointer) { nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); } - -TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) { - ur_native_handle_t native_handle = 0; - { - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urQueueGetNativeHandle(queue, nullptr, &native_handle)); - } - - ur_queue_handle_t q = nullptr; - ur_queue_native_properties_t properties{ - UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, nullptr, true}; - ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, - &properties, &q)); - ASSERT_NE(q, nullptr); -} - -TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) { - ur_native_handle_t native_handle = 0; - { - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urQueueGetNativeHandle(queue, nullptr, &native_handle)); - } - - ur_queue_handle_t q = nullptr; - ur_queue_native_properties_t properties{ - UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, nullptr, false}; - ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device, - &properties, &q)); - ASSERT_NE(q, nullptr); -} diff --git a/test/conformance/queue/urQueueGetInfo.cpp b/test/conformance/queue/urQueueGetInfo.cpp index 8f48fa7dad..e3330fef6f 100644 --- a/test/conformance/queue/urQueueGetInfo.cpp +++ b/test/conformance/queue/urQueueGetInfo.cpp @@ -5,120 +5,80 @@ #include #include -std::unordered_map queue_info_size_map = { - {UR_QUEUE_INFO_CONTEXT, sizeof(ur_context_handle_t)}, - {UR_QUEUE_INFO_DEVICE, sizeof(ur_device_handle_t)}, - {UR_QUEUE_INFO_DEVICE_DEFAULT, sizeof(ur_queue_handle_t)}, - {UR_QUEUE_INFO_FLAGS, sizeof(ur_queue_flags_t)}, - {UR_QUEUE_INFO_REFERENCE_COUNT, sizeof(uint32_t)}, - {UR_QUEUE_INFO_SIZE, sizeof(uint32_t)}, - {UR_QUEUE_INFO_EMPTY, sizeof(ur_bool_t)}, -}; +using urQueueGetInfoTest = uur::urQueueTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest); -using urQueueGetInfoTestWithInfoParam = - uur::urQueueTestWithParam; +TEST_P(urQueueGetInfoTest, Context) { + size_t size = 0; + auto infoType = UR_QUEUE_INFO_CONTEXT; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(ur_context_handle_t), size); + + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); -UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam, - ::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE, - UR_QUEUE_INFO_FLAGS, - UR_QUEUE_INFO_REFERENCE_COUNT, - UR_QUEUE_INFO_EMPTY), - uur::deviceTestWithParamPrinter); + auto returned_context = + reinterpret_cast(data.data()); + ASSERT_EQ(context, *returned_context); +} -TEST_P(urQueueGetInfoTestWithInfoParam, Success) { - ur_queue_info_t info_type = getParam(); +TEST_P(urQueueGetInfoTest, Device) { size_t size = 0; - auto result = urQueueGetInfo(queue, info_type, 0, nullptr, &size); + auto infoType = UR_QUEUE_INFO_DEVICE; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(ur_device_handle_t), size); - if (result == UR_RESULT_SUCCESS) { - ASSERT_NE(size, 0); + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); - if (const auto expected_size = queue_info_size_map.find(info_type); - expected_size != queue_info_size_map.end()) { - ASSERT_EQ(expected_size->second, size); - } + auto returned_device = reinterpret_cast(data.data()); + ASSERT_EQ(device, *returned_device); +} - std::vector data(size); - ASSERT_SUCCESS( - urQueueGetInfo(queue, info_type, size, data.data(), nullptr)); - - switch (info_type) { - case UR_QUEUE_INFO_CONTEXT: { - auto returned_context = - reinterpret_cast(data.data()); - ASSERT_EQ(context, *returned_context); - break; - } - case UR_QUEUE_INFO_DEVICE: { - auto returned_device = - reinterpret_cast(data.data()); - ASSERT_EQ(*returned_device, device); - break; - } - case UR_QUEUE_INFO_DEVICE_DEFAULT: { - auto returned_default_queue = - reinterpret_cast(data.data()); - ASSERT_EQ(*returned_default_queue, queue); - break; - } - case UR_QUEUE_INFO_FLAGS: { - auto returned_flags = - reinterpret_cast(data.data()); - EXPECT_EQ(*returned_flags, *returned_flags & UR_QUEUE_FLAGS_MASK); - break; - } - case UR_QUEUE_INFO_REFERENCE_COUNT: { - auto returned_reference_count = - reinterpret_cast(data.data()); - ASSERT_GT(*returned_reference_count, 0U); - break; - } - case UR_QUEUE_INFO_EMPTY: { - auto returned_empty_queue = - reinterpret_cast(data.data()); - ASSERT_TRUE(returned_empty_queue); - break; - } - default: - break; - } - } else { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); - } +TEST_P(urQueueGetInfoTest, Flags) { + size_t size = 0; + auto infoType = UR_QUEUE_INFO_FLAGS; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(ur_queue_flags_t), size); + + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + + auto returned_flags = reinterpret_cast(data.data()); + EXPECT_EQ(*returned_flags, queue_properties.flags); } -struct urQueueGetInfoDeviceQueueTestWithInfoParam - : public uur::urContextTestWithParam { - void SetUp() { - urContextTestWithParam::SetUp(); - ur_queue_flags_t deviceQueueCapabilities; - ASSERT_SUCCESS( - urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES, - sizeof(deviceQueueCapabilities), - &deviceQueueCapabilities, nullptr)); - if (!deviceQueueCapabilities) { - GTEST_SKIP() << "Queue on device is not supported."; - } - ASSERT_SUCCESS( - urQueueCreate(context, device, &queueProperties, &queue)); - } +TEST_P(urQueueGetInfoTest, ReferenceCount) { + size_t size = 0; + auto infoType = UR_QUEUE_INFO_REFERENCE_COUNT; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(uint32_t), size); - void TearDown() { - if (queue) { - ASSERT_SUCCESS(urQueueRelease(queue)); - } - urContextTestWithParam::TearDown(); - } + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); - ur_queue_handle_t queue = nullptr; - ur_queue_properties_t queueProperties = { - UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr, - UR_QUEUE_FLAG_ON_DEVICE | UR_QUEUE_FLAG_ON_DEVICE_DEFAULT | - UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE}; -}; + auto returned_reference_count = reinterpret_cast(data.data()); + ASSERT_GT(*returned_reference_count, 0U); +} -using urQueueGetInfoTest = uur::urQueueTest; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest); +TEST_P(urQueueGetInfoTest, EmptyQueue) { + size_t size = 0; + auto infoType = UR_QUEUE_INFO_EMPTY; + UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( + urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(ur_bool_t), size); + + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + + auto returned_empty_queue = reinterpret_cast(data.data()); + ASSERT_TRUE(returned_empty_queue); +} TEST_P(urQueueGetInfoTest, InvalidNullHandleQueue) { ur_context_handle_t context = nullptr; @@ -163,3 +123,64 @@ TEST_P(urQueueGetInfoTest, InvalidNullPointerPropSizeRet) { UR_RESULT_ERROR_INVALID_NULL_POINTER, urQueueGetInfo(queue, UR_QUEUE_INFO_CONTEXT, 0, nullptr, nullptr)); } + +struct urQueueGetInfoDeviceQueueTestWithInfoParam : public uur::urQueueTest { + void SetUp() { + urQueueGetInfoTest::SetUp(); + ur_queue_flags_t deviceQueueCapabilities; + ASSERT_SUCCESS( + urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES, + sizeof(deviceQueueCapabilities), + &deviceQueueCapabilities, nullptr)); + if (!deviceQueueCapabilities) { + GTEST_SKIP() << "Queue on device is not supported."; + } + ASSERT_SUCCESS( + urQueueCreate(context, device, &queueProperties, &queue)); + } + + void TearDown() { + if (queue) { + ASSERT_SUCCESS(urQueueRelease(queue)); + } + urQueueGetInfoTest::TearDown(); + } + + ur_queue_handle_t queue = nullptr; + ur_queue_properties_t queueProperties = { + UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr, + UR_QUEUE_FLAG_ON_DEVICE | UR_QUEUE_FLAG_ON_DEVICE_DEFAULT | + UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE}; +}; + +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoDeviceQueueTestWithInfoParam); + +TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, DeviceDefault) { + + size_t size = 0; + auto infoType = UR_QUEUE_INFO_DEVICE_DEFAULT; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(ur_queue_handle_t), size); + + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + + auto returned_queue = reinterpret_cast(data.data()); + ASSERT_EQ(queue, *returned_queue); +} + +TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Size) { + + size_t size = 0; + auto infoType = UR_QUEUE_INFO_SIZE; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_NE(size, 0); + ASSERT_EQ(sizeof(uint32_t), size); + + std::vector data(size); + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + + auto returned_size = reinterpret_cast(data.data()); + ASSERT_GT(*returned_size, 0); +}