From b7218bdd75962c00cc2590f2280762f2d6fc8ac4 Mon Sep 17 00:00:00 2001 From: Petr Vesely Date: Mon, 31 Jul 2023 16:27:02 +0100 Subject: [PATCH] [UR] Check for VM support --- .../enqueue/urEnqueueKernelLaunch.cpp | 14 +++++++++++++- .../conformance/testing/include/uur/fixtures.h | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test/conformance/enqueue/urEnqueueKernelLaunch.cpp b/test/conformance/enqueue/urEnqueueKernelLaunch.cpp index 10441dafc6..0bca070da9 100644 --- a/test/conformance/enqueue/urEnqueueKernelLaunch.cpp +++ b/test/conformance/enqueue/urEnqueueKernelLaunch.cpp @@ -126,6 +126,15 @@ struct urEnqueueKernelLaunchWithVirtualMemory : uur::urKernelExecutionTest { void SetUp() override { program_name = "fill_usm"; UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp()); + + ur_bool_t virtual_memory_support = false; + ASSERT_SUCCESS(urDeviceGetInfo( + device, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), + &virtual_memory_support, nullptr)); + if (!virtual_memory_support) { + GTEST_SKIP() << "Virtual memory is not supported."; + } + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity), &granularity, nullptr)); @@ -179,8 +188,11 @@ TEST_P(urEnqueueKernelLaunchWithVirtualMemory, Success) { size_t work_dim = 1; size_t global_offset = 0; size_t global_size = alloc_size / sizeof(uint32_t); + uint32_t fill_val = 42; ASSERT_SUCCESS(urKernelSetArgPointer(kernel, 0, nullptr, virtual_ptr)); + ASSERT_SUCCESS( + urKernelSetArgValue(kernel, 1, sizeof(fill_val), nullptr, &fill_val)); ur_event_handle_t kernel_evt; ASSERT_SUCCESS(urEnqueueKernelLaunch(queue, kernel, work_dim, @@ -195,6 +207,6 @@ TEST_P(urEnqueueKernelLaunchWithVirtualMemory, Success) { // verify fill worked for (size_t i = 0; i < data.size(); i++) { - ASSERT_EQ(i, data.at(i)); + ASSERT_EQ(fill_val, data.at(i)); } } diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 7765e00ade..f408ad4482 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -670,6 +670,15 @@ template struct urUSMPoolTestWithParam : urContextTestWithParam { struct urVirtualMemGranularityTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + + ur_bool_t virtual_memory_support = false; + ASSERT_SUCCESS(urDeviceGetInfo( + device, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t), + &virtual_memory_support, nullptr)); + if (!virtual_memory_support) { + GTEST_SKIP() << "Virtual memory is not supported."; + } + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( context, device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity), &granularity, nullptr)); @@ -681,6 +690,15 @@ template struct urVirtualMemGranularityTestWithParam : urContextTestWithParam { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); + + ur_bool_t virtual_memory_support = false; + ASSERT_SUCCESS(urDeviceGetInfo( + this->device, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, + sizeof(ur_bool_t), &virtual_memory_support, nullptr)); + if (!virtual_memory_support) { + GTEST_SKIP() << "Virtual memory is not supported."; + } + ASSERT_SUCCESS(urVirtualMemGranularityGetInfo( this->context, this->device, UR_VIRTUAL_MEM_GRANULARITY_INFO_MINIMUM, sizeof(granularity),