From 09f45fc2afa259e7a674a499d925c90bda23c19d Mon Sep 17 00:00:00 2001 From: Wenbin Lu Date: Fri, 22 Nov 2024 02:12:39 +0000 Subject: [PATCH] feature: add physical system memory tests 1/n Related-To: NEO-11981 Signed-off-by: Wenbin Lu --- .../core/test_ipc/src/test_ipc_memory.cpp | 6 +- .../test_ipc/src/test_ipc_multidevice.cpp | 6 +- .../test_ipc/src/test_ipc_multisubdevice.cpp | 6 +- .../core/test_ipc/src/test_ipc_put_handle.cpp | 4 +- .../test_memory/src/test_virtual_memory.cpp | 143 ++++++++++++++---- .../core/test_p2p/src/test_p2p.cpp | 14 +- .../core/test_p2p/src/test_p2p_mem_access.cpp | 4 +- layer_tests/tracing/src/test_api_ltracing.cpp | 33 ++-- .../tracing/src/test_api_ltracing_compat.cpp | 40 ++--- .../test_harness/test_harness_memory.hpp | 13 +- .../test_harness/src/test_harness_memory.cpp | 25 ++- 11 files changed, 194 insertions(+), 100 deletions(-) diff --git a/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp b/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp index 772a356f..261bfa27 100644 --- a/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp +++ b/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -63,8 +63,8 @@ static void run_ipc_mem_access_test(ipc_mem_access_test_t test_type, int size, ze_physical_mem_handle_t reservedPhysicalMemory = {}; void *memory = nullptr; if (reserved) { - memory = lzt::reserve_allocate_and_map_memory(context, device, allocSize, - &reservedPhysicalMemory); + memory = lzt::reserve_allocate_and_map_device_memory( + context, device, allocSize, &reservedPhysicalMemory); } else { memory = lzt::allocate_device_memory(size, 1, 0, context); } diff --git a/conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp b/conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp index 49665aeb..d3e995fe 100644 --- a/conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp +++ b/conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -70,8 +70,8 @@ void multi_device_sender(size_t size, bool reserved, bool is_immediate) { ze_physical_mem_handle_t reservedPhysicalMemory = {}; void *memory = nullptr; if (reserved) { - memory = lzt::reserve_allocate_and_map_memory(context, device, allocSize, - &reservedPhysicalMemory); + memory = lzt::reserve_allocate_and_map_device_memory( + context, device, allocSize, &reservedPhysicalMemory); } else { memory = lzt::allocate_device_memory(size, 1, flags, device, context); } diff --git a/conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp b/conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp index 49cdf474..309a11b0 100644 --- a/conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp +++ b/conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -85,8 +85,8 @@ void multi_sub_device_sender(size_t size, bool reserved, bool is_immediate) { ze_physical_mem_handle_t reservedPhysicalMemory = {}; void *memory = nullptr; if (reserved) { - memory = lzt::reserve_allocate_and_map_memory(context, device, allocSize, - &reservedPhysicalMemory); + memory = lzt::reserve_allocate_and_map_device_memory( + context, device, allocSize, &reservedPhysicalMemory); } else { memory = lzt::allocate_device_memory(size, 1, flags, device, context); } diff --git a/conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp b/conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp index d949fd40..488b701b 100644 --- a/conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp +++ b/conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp @@ -64,8 +64,8 @@ static void run_ipc_put_handle_test(ipc_put_mem_access_test_t test_type, ze_physical_mem_handle_t reservedPhysicalMemory = {}; void *memory = nullptr; if (reserved) { - memory = lzt::reserve_allocate_and_map_memory(context, device, allocSize, - &reservedPhysicalMemory); + memory = lzt::reserve_allocate_and_map_device_memory( + context, device, allocSize, &reservedPhysicalMemory); } else { memory = lzt::allocate_device_memory(size, 1, 0, context); } diff --git a/conformance_tests/core/test_memory/src/test_virtual_memory.cpp b/conformance_tests/core/test_memory/src/test_virtual_memory.cpp index 65836d5b..ddd03575 100644 --- a/conformance_tests/core/test_memory/src/test_virtual_memory.cpp +++ b/conformance_tests/core/test_memory/src/test_virtual_memory.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,6 +15,10 @@ #include "test_harness/test_harness.hpp" #include "logging/logging.hpp" +#ifdef __linux__ +#include +#endif + namespace lzt = level_zero_tests; #include @@ -35,7 +39,8 @@ class zeVirtualMemoryTests : public ::testing::Test { size_t pageSize = 0; size_t allocationSize = (1024 * 1024); void *reservedVirtualMemory = nullptr; - ze_physical_mem_handle_t reservedPhysicalMemory; + ze_physical_mem_handle_t reservedPhysicalDeviceMemory = nullptr; + ze_physical_mem_handle_t reservedPhysicalHostMemory = nullptr; }; TEST_F(zeVirtualMemoryTests, @@ -134,9 +139,23 @@ TEST_F(zeVirtualMemoryTests, GivenPageAlignedSizeThenVirtualAndPhysicalMemoryReservedSuccessfully) { lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); - lzt::physical_memory_destroy(context, reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalDeviceMemory); + lzt::physical_memory_destroy(context, reservedPhysicalDeviceMemory); +} + +TEST_F( + zeVirtualMemoryTests, + GivenPageAlignedSizeThenVirtualAndPhysicalHostMemoryReservedSuccessfully) { +#ifdef __linux__ + pageSize = sysconf(_SC_PAGE_SIZE); + allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); + lzt::physical_host_memory_allocation(context, allocationSize, + &reservedPhysicalHostMemory); + lzt::physical_memory_destroy(context, reservedPhysicalHostMemory); +#else + GTEST_SKIP() << "Physical host memory is unsupported on Windows"; +#endif } TEST_F( @@ -144,8 +163,12 @@ TEST_F( GivenPageAlignedSizeThenPhysicalMemoryisSuccessfullyReservedForAllAccessTypes) { lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalDeviceMemory); +#ifdef __linux__ + lzt::physical_host_memory_allocation(context, allocationSize, + &reservedPhysicalHostMemory); +#endif lzt::virtual_memory_reservation(context, nullptr, allocationSize, &reservedVirtualMemory); EXPECT_NE(nullptr, reservedVirtualMemory); @@ -156,33 +179,62 @@ TEST_F( for (auto accessFlags : memoryAccessFlags) { lzt::virtual_memory_map(context, reservedVirtualMemory, allocationSize, - reservedPhysicalMemory, 0, accessFlags); + reservedPhysicalDeviceMemory, 0, accessFlags); + lzt::virtual_memory_unmap(context, reservedVirtualMemory, allocationSize); + } +#ifdef __linux__ + for (auto accessFlags : memoryAccessFlags) { + lzt::virtual_memory_map(context, reservedVirtualMemory, allocationSize, + reservedPhysicalHostMemory, 0, accessFlags); lzt::virtual_memory_unmap(context, reservedVirtualMemory, allocationSize); } - lzt::physical_memory_destroy(context, reservedPhysicalMemory); + lzt::physical_memory_destroy(context, reservedPhysicalHostMemory); +#endif + lzt::physical_memory_destroy(context, reservedPhysicalDeviceMemory); lzt::virtual_memory_free(context, reservedVirtualMemory, allocationSize); } void RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( - zeVirtualMemoryTests &test, bool is_immediate) { + zeVirtualMemoryTests &test, bool is_host_memory, bool is_immediate) { auto bundle = lzt::create_command_bundle(test.device, is_immediate); - lzt::query_page_size(test.context, test.device, test.allocationSize, - &test.pageSize); + if (is_host_memory) { +#ifdef __linux__ + test.pageSize = sysconf(_SC_PAGE_SIZE); +#endif + } else { + lzt::query_page_size(test.context, test.device, test.allocationSize, + &test.pageSize); + } + test.allocationSize = lzt::create_page_aligned_size(test.allocationSize, test.pageSize); - lzt::physical_memory_allocation(test.context, test.device, - test.allocationSize, - &test.reservedPhysicalMemory); lzt::virtual_memory_reservation(test.context, nullptr, test.allocationSize, &test.reservedVirtualMemory); + EXPECT_NE(nullptr, test.reservedVirtualMemory); + if (is_host_memory) { + lzt::physical_host_memory_allocation(test.context, test.allocationSize, + &test.reservedPhysicalHostMemory); + EXPECT_NE(nullptr, test.reservedPhysicalHostMemory); + ASSERT_EQ(zeVirtualMemMap(test.context, test.reservedVirtualMemory, + test.allocationSize, + test.reservedPhysicalHostMemory, 0, + ZE_MEMORY_ACCESS_ATTRIBUTE_READWRITE), + ZE_RESULT_SUCCESS); + } else { + lzt::physical_device_memory_allocation(test.context, test.device, + test.allocationSize, + &test.reservedPhysicalDeviceMemory); + EXPECT_NE(nullptr, test.reservedPhysicalDeviceMemory); + ASSERT_EQ(zeVirtualMemMap(test.context, test.reservedVirtualMemory, + test.allocationSize, + test.reservedPhysicalDeviceMemory, 0, + ZE_MEMORY_ACCESS_ATTRIBUTE_READWRITE), + ZE_RESULT_SUCCESS); + } - ASSERT_EQ(zeVirtualMemMap(test.context, test.reservedVirtualMemory, - test.allocationSize, test.reservedPhysicalMemory, 0, - ZE_MEMORY_ACCESS_ATTRIBUTE_READWRITE), - ZE_RESULT_SUCCESS); int8_t pattern = 9; void *memory = lzt::allocate_shared_memory(test.allocationSize, test.pageSize); @@ -200,7 +252,12 @@ void RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( lzt::virtual_memory_unmap(test.context, test.reservedVirtualMemory, test.allocationSize); - lzt::physical_memory_destroy(test.context, test.reservedPhysicalMemory); + if (is_host_memory) { + lzt::physical_memory_destroy(test.context, test.reservedPhysicalHostMemory); + } else { + lzt::physical_memory_destroy(test.context, + test.reservedPhysicalDeviceMemory); + } lzt::virtual_memory_free(test.context, test.reservedVirtualMemory, test.allocationSize); lzt::free_memory(memory); @@ -210,15 +267,37 @@ void RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( TEST_F( zeVirtualMemoryTests, GivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemorySucceeds) { - RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory(*this, - false); + RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( + *this, false, false); } TEST_F( zeVirtualMemoryTests, GivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemoryOnImmediateCommandListSucceeds) { - RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory(*this, - true); + RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( + *this, false, true); +} + +TEST_F( + zeVirtualMemoryTests, + GivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualHostMemorySucceeds) { +#ifdef __linux__ + RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( + *this, true, false); +#else + GTEST_SKIP() << "Physical host memory is unsupported on Windows"; +#endif +} + +TEST_F( + zeVirtualMemoryTests, + GivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualHostMemoryOnImmediateCommandListSucceeds) { +#ifdef __linux__ + RunGivenMappedReadWriteMemoryThenFillAndCopyWithMappedVirtualMemory( + *this, true, true); +#else + GTEST_SKIP() << "Physical host memory is unsupported on Windows"; +#endif } void RunGivenMappedMultiplePhysicalMemoryAcrossAvailableDevicesWhenFillAndCopyWithSingleMappedVirtualMemory( @@ -242,9 +321,9 @@ void RunGivenMappedMultiplePhysicalMemoryAcrossAvailableDevicesWhenFillAndCopyWi test.allocationSize = lzt::create_page_aligned_size(test.allocationSize, test.pageSize); for (int i = 0; i < devices.size(); i++) { - lzt::physical_memory_allocation(test.context, devices[i], - test.allocationSize, - &reservedPhysicalMemoryArray[i]); + lzt::physical_device_memory_allocation(test.context, devices[i], + test.allocationSize, + &reservedPhysicalMemoryArray[i]); } size_t totalAllocationSize = test.allocationSize * devices.size(); @@ -330,9 +409,9 @@ void RunGivenVirtualMemoryMappedToMultipleAllocationsWhenFullAddressUsageInKerne test.allocationSize = lzt::create_page_aligned_size(test.allocationSize, test.pageSize); for (int i = 0; i < devices.size(); i++) { - lzt::physical_memory_allocation(test.context, devices[i], - test.allocationSize, - &reservedPhysicalMemoryArray[i]); + lzt::physical_device_memory_allocation(test.context, devices[i], + test.allocationSize, + &reservedPhysicalMemoryArray[i]); } size_t totalAllocationSize = test.allocationSize * devices.size(); size_t virtualReservationSize = lzt::nextPowerOfTwo(totalAllocationSize); @@ -498,8 +577,8 @@ void dataCheckMemoryReservations(enum MemoryReservationTestType type, lzt::query_page_size(context, rootDevice, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); for (int i = 0; i < devices.size(); i++) { - lzt::physical_memory_allocation(context, devices[i], allocationSize, - &reservedPhysicalMemory[i]); + lzt::physical_device_memory_allocation(context, devices[i], allocationSize, + &reservedPhysicalMemory[i]); } size_t virtualReservationSize = lzt::nextPowerOfTwo(allocationSize * devices.size()); diff --git a/conformance_tests/core/test_p2p/src/test_p2p.cpp b/conformance_tests/core/test_p2p/src/test_p2p.cpp index ffece57f..257342ea 100644 --- a/conformance_tests/core/test_p2p/src/test_p2p.cpp +++ b/conformance_tests/core/test_p2p/src/test_p2p.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -56,10 +56,10 @@ class zeP2PTests : public ::testing::Test, mem_size_ = lzt::create_page_aligned_size(mem_size_ + offset_, pageSize); offset_ = 0; - lzt::physical_memory_allocation(context, device, mem_size_, - &instance.src_physical_region); - lzt::physical_memory_allocation(context, device, mem_size_, - &instance.dst_physical_region); + lzt::physical_device_memory_allocation(context, device, mem_size_, + &instance.src_physical_region); + lzt::physical_device_memory_allocation(context, device, mem_size_, + &instance.dst_physical_region); lzt::virtual_memory_reservation(context, nullptr, mem_size_, &instance.src_region); EXPECT_NE(nullptr, instance.src_region); @@ -103,10 +103,10 @@ class zeP2PTests : public ::testing::Test, mem_size_ = lzt::create_page_aligned_size(mem_size_ + offset_, pageSize); offset_ = 0; - lzt::physical_memory_allocation( + lzt::physical_device_memory_allocation( context, sub_device, mem_size_, &sub_device_instance.src_physical_region); - lzt::physical_memory_allocation( + lzt::physical_device_memory_allocation( context, sub_device, mem_size_, &sub_device_instance.dst_physical_region); lzt::virtual_memory_reservation(context, nullptr, mem_size_, diff --git a/conformance_tests/core/test_p2p/src/test_p2p_mem_access.cpp b/conformance_tests/core/test_p2p/src/test_p2p_mem_access.cpp index 7c52448e..88a6839f 100644 --- a/conformance_tests/core/test_p2p/src/test_p2p_mem_access.cpp +++ b/conformance_tests/core/test_p2p/src/test_p2p_mem_access.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -249,7 +249,7 @@ class zeP2PMemAccessTests dev_access_[std::max(static_cast(1), (num - 1))].dev, mem_size_, &pageSize); mem_size_ = lzt::create_page_aligned_size(mem_size_, pageSize); - lzt::physical_memory_allocation( + lzt::physical_device_memory_allocation( lzt::get_default_context(), dev_access_[std::max(static_cast(1), (num - 1))].dev, mem_size_, &dev_access_[0].device_mem_remote_physical); diff --git a/layer_tests/tracing/src/test_api_ltracing.cpp b/layer_tests/tracing/src/test_api_ltracing.cpp index 2b2bcb88..3632bb22 100644 --- a/layer_tests/tracing/src/test_api_ltracing.cpp +++ b/layer_tests/tracing/src/test_api_ltracing.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -50,7 +50,8 @@ class LTracingCreateMultipleTests public ::testing::WithParamInterface {}; #ifdef USE_RUNTIME_TRACING -class LDynamicTracingCreateMultipleTests : public LTracingCreateMultipleTests {}; +class LDynamicTracingCreateMultipleTests : public LTracingCreateMultipleTests { +}; #define LTRACING_CREATE_MULTIPLE_TEST_NAME LDynamicTracingCreateMultipleTests #else // USE Tracing ENV #define LTRACING_CREATE_MULTIPLE_TEST_NAME LTracingCreateMultipleTests @@ -79,7 +80,8 @@ TEST_P(LTRACING_CREATE_MULTIPLE_TEST_NAME, delete[] user_data; } -INSTANTIATE_TEST_CASE_P(CreateMultipleTracerTest, LTRACING_CREATE_MULTIPLE_TEST_NAME, +INSTANTIATE_TEST_CASE_P(CreateMultipleTracerTest, + LTRACING_CREATE_MULTIPLE_TEST_NAME, ::testing::Values(1, 10, 100, 1000)); #ifdef USE_RUNTIME_TRACING @@ -162,15 +164,15 @@ class LTracingPrologueEpilogueTests : public ::testing::Test { std::memcpy(region.get_address(), &test_data, sizeof(lzt::shared_ipc_event_data_t)); - #ifdef USE_RUNTIME_TRACING +#ifdef USE_RUNTIME_TRACING // launch child boost::process::child c("./tracing/test_ltracing_ipc_event_helper_dynamic", test_type_name.c_str()); - #else +#else // launch child boost::process::child c("./tracing/test_ltracing_ipc_event_helper", test_type_name.c_str()); - #endif +#endif lzt::send_ipc_handle(hIpcEventPool); c.wait(); // wait for the process to exit @@ -404,7 +406,8 @@ static void ready_ltracer(zel_tracer_handle_t tracer, ze_callbacks_t prologues, } #ifdef USE_RUNTIME_TRACING -class LDynamicTracingPrologueEpilogueTests : public LTracingPrologueEpilogueTests {}; +class LDynamicTracingPrologueEpilogueTests + : public LTracingPrologueEpilogueTests {}; #define LTRACING_TEST_NAME LDynamicTracingPrologueEpilogueTests #else // USE Tracing ENV #define LTRACING_TEST_NAME LTracingPrologueEpilogueTests @@ -943,9 +946,8 @@ TEST_F( ASSERT_EQ(initial_result, zeCommandListReset(command_list)); } -TEST_F( - LTRACING_TEST_NAME, - GivenWhenTracerEnabledWithCalltoZetAPIThenSuccessIsReturnedFromZetAPI) { +TEST_F(LTRACING_TEST_NAME, + GivenWhenTracerEnabledWithCalltoZetAPIThenSuccessIsReturnedFromZetAPI) { prologues.CommandList.pfnResetCb = lzt::lprologue_callback; epilogues.CommandList.pfnResetCb = lzt::lepilogue_callback; @@ -960,9 +962,8 @@ TEST_F( zetMetricGroupGet(device, &metricGroupCount, nullptr)); } -TEST_F( - LTRACING_TEST_NAME, - GivenWhenTracerEnabledWithCalltoZesAPIThenSuccessIsReturnedFromZesAPI) { +TEST_F(LTRACING_TEST_NAME, + GivenWhenTracerEnabledWithCalltoZesAPIThenSuccessIsReturnedFromZesAPI) { prologues.CommandList.pfnResetCb = lzt::lprologue_callback; epilogues.CommandList.pfnResetCb = lzt::lepilogue_callback; @@ -972,11 +973,9 @@ TEST_F( ready_ltracer(tracer_handle, prologues, epilogues); ASSERT_EQ(initial_result, zeCommandListReset(command_list)); - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesInit(0)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zesInit(0)); uint32_t zesCount = 0; - EXPECT_EQ(ZE_RESULT_SUCCESS, - zesDriverGet(&zesCount, nullptr)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&zesCount, nullptr)); } TEST_F( diff --git a/layer_tests/tracing/src/test_api_ltracing_compat.cpp b/layer_tests/tracing/src/test_api_ltracing_compat.cpp index 654dea2d..8aefedb3 100644 --- a/layer_tests/tracing/src/test_api_ltracing_compat.cpp +++ b/layer_tests/tracing/src/test_api_ltracing_compat.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2021 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -52,9 +52,9 @@ class LCTracingCreateMultipleTests : public ::testing::Test, public ::testing::WithParamInterface {}; - #ifdef USE_RUNTIME_TRACING -class LCDynamicTracingCreateMultipleTests : public LCTracingCreateMultipleTests {}; +class LCDynamicTracingCreateMultipleTests + : public LCTracingCreateMultipleTests {}; #define LCTRACING_CREATE_MULTIPLE_TEST_NAME LCDynamicTracingCreateMultipleTests #else // USE Tracing ENV #define LCTRACING_CREATE_MULTIPLE_TEST_NAME LCTracingCreateMultipleTests @@ -170,15 +170,16 @@ class LCTracingPrologueEpilogueTests : public ::testing::Test { std::memcpy(region.get_address(), &test_data, sizeof(lzt::shared_ipc_event_data_t)); - #ifdef USE_RUNTIME_TRACING +#ifdef USE_RUNTIME_TRACING // launch child - boost::process::child c("./tracing/test_ltracing_compat_ipc_event_helper_dynamic", - test_type_name.c_str()); - #else + boost::process::child c( + "./tracing/test_ltracing_compat_ipc_event_helper_dynamic", + test_type_name.c_str()); +#else // launch child boost::process::child c("./tracing/test_ltracing_compat_ipc_event_helper", test_type_name.c_str()); - #endif +#endif lzt::send_ipc_handle(hIpcEventPool); c.wait(); // wait for the process to exit @@ -403,7 +404,8 @@ class LCTracingPrologueEpilogueTests : public ::testing::Test { }; #ifdef USE_RUNTIME_TRACING -class LCDynamicTracingPrologueEpilogueTests : public LCTracingPrologueEpilogueTests {}; +class LCDynamicTracingPrologueEpilogueTests + : public LCTracingPrologueEpilogueTests {}; #define LCTRACING_TEST_NAME LCDynamicTracingPrologueEpilogueTests #else // USE Tracing ENV #define LCTRACING_TEST_NAME LCTracingPrologueEpilogueTests @@ -3245,8 +3247,8 @@ TEST_F( lzt::enable_ltracer(tracer_handle); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalMemory); lzt::physical_memory_destroy(context, reservedPhysicalMemory); } @@ -3265,8 +3267,8 @@ TEST_F( lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalMemory); lzt::enable_ltracer(tracer_handle); @@ -3373,8 +3375,8 @@ TEST_F( lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalMemory); lzt::physical_memory_destroy(context, reservedPhysicalMemory); } @@ -3422,8 +3424,8 @@ TEST_F( lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalMemory); lzt::virtual_memory_reservation(context, nullptr, allocationSize, &reservedVirtualMemory); EXPECT_NE(nullptr, reservedVirtualMemory); @@ -3459,8 +3461,8 @@ TEST_F( lzt::query_page_size(context, device, allocationSize, &pageSize); allocationSize = lzt::create_page_aligned_size(allocationSize, pageSize); - lzt::physical_memory_allocation(context, device, allocationSize, - &reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocationSize, + &reservedPhysicalMemory); lzt::virtual_memory_reservation(context, nullptr, allocationSize, &reservedVirtualMemory); EXPECT_NE(nullptr, reservedVirtualMemory); diff --git a/utils/test_harness/include/test_harness/test_harness_memory.hpp b/utils/test_harness/include/test_harness/test_harness_memory.hpp index 6735f995..f29d6651 100644 --- a/utils/test_harness/include/test_harness/test_harness_memory.hpp +++ b/utils/test_harness/include/test_harness/test_harness_memory.hpp @@ -137,10 +137,13 @@ void physical_memory_allocation(ze_context_handle_t context, ze_device_handle_t device, ze_physical_mem_desc_t *desc, ze_physical_mem_handle_t *memory); -void physical_memory_allocation(ze_context_handle_t context, - ze_device_handle_t device, - size_t allocation_size, - ze_physical_mem_handle_t *memory); +void physical_device_memory_allocation(ze_context_handle_t context, + ze_device_handle_t device, + size_t allocation_size, + ze_physical_mem_handle_t *memory); +void physical_host_memory_allocation(ze_context_handle_t context, + size_t allocation_size, + ze_physical_mem_handle_t *memory); void physical_memory_destroy(ze_context_handle_t context, ze_physical_mem_handle_t memory); void virtual_memory_map(ze_context_handle_t context, @@ -157,7 +160,7 @@ void virtual_memory_reservation_get_access(ze_context_handle_t context, void virtual_memory_reservation_set_access(ze_context_handle_t context, const void *ptr, size_t size, ze_memory_access_attribute_t access); -void *reserve_allocate_and_map_memory( +void *reserve_allocate_and_map_device_memory( ze_context_handle_t context, ze_device_handle_t device, size_t &allocSize, ze_physical_mem_handle_t *reservedPhysicalMemory); void unmap_and_free_reserved_memory( diff --git a/utils/test_harness/src/test_harness_memory.cpp b/utils/test_harness/src/test_harness_memory.cpp index 34647a0b..5128c6a9 100644 --- a/utils/test_harness/src/test_harness_memory.cpp +++ b/utils/test_harness/src/test_harness_memory.cpp @@ -365,15 +365,15 @@ void get_mem_alloc_properties( EXPECT_EQ(context, context_initial); } -void *reserve_allocate_and_map_memory( +void *reserve_allocate_and_map_device_memory( ze_context_handle_t context, ze_device_handle_t device, size_t &allocSize, ze_physical_mem_handle_t *reservedPhysicalMemory) { size_t pageSize = 0; void *reservedMemory = nullptr; lzt::query_page_size(context, device, allocSize, &pageSize); allocSize = lzt::create_page_aligned_size(allocSize, pageSize); - lzt::physical_memory_allocation(context, device, allocSize, - reservedPhysicalMemory); + lzt::physical_device_memory_allocation(context, device, allocSize, + reservedPhysicalMemory); lzt::virtual_memory_reservation(context, nullptr, allocSize, &reservedMemory); EXPECT_NE(nullptr, reservedMemory); EXPECT_EQ(zeVirtualMemMap(context, reservedMemory, allocSize, @@ -424,16 +424,27 @@ void virtual_memory_free(ze_context_handle_t context, void *memory, EXPECT_EQ(zeVirtualMemFree(context, memory, alloc_size), ZE_RESULT_SUCCESS); } -void physical_memory_allocation(ze_context_handle_t context, - ze_device_handle_t device, - size_t allocation_size, - ze_physical_mem_handle_t *memory) { +void physical_device_memory_allocation(ze_context_handle_t context, + ze_device_handle_t device, + size_t allocation_size, + ze_physical_mem_handle_t *memory) { ze_physical_mem_desc_t physDesc = {ZE_STRUCTURE_TYPE_PHYSICAL_MEM_DESC, nullptr}; physDesc.size = allocation_size; + physDesc.flags = ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_DEVICE; lzt::physical_memory_allocation(context, device, &physDesc, memory); } +void physical_host_memory_allocation(ze_context_handle_t context, + size_t allocation_size, + ze_physical_mem_handle_t *memory) { + ze_physical_mem_desc_t physDesc = {ZE_STRUCTURE_TYPE_PHYSICAL_MEM_DESC, + nullptr}; + physDesc.size = allocation_size; + physDesc.flags = ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_HOST; + lzt::physical_memory_allocation(context, nullptr, &physDesc, memory); +} + void physical_memory_allocation(ze_context_handle_t context, ze_device_handle_t device, ze_physical_mem_desc_t *desc,