From 3a58579bbe81529fb4d4b95ea64a88d064e9685f Mon Sep 17 00:00:00 2001 From: "Milczarek, Slawomir" Date: Mon, 14 Nov 2022 16:42:36 +0000 Subject: [PATCH] Move memory properties helper tests from opencl to shared project Related-To: NEO-7092 Signed-off-by: Milczarek, Slawomir --- opencl/test/unit_test/helpers/CMakeLists.txt | 2 +- ...=> cl_memory_properties_helpers_tests.cpp} | 40 -------------- shared/test/unit_test/helpers/CMakeLists.txt | 1 + .../memory_properties_helpers_tests.cpp | 53 +++++++++++++++++++ 4 files changed, 55 insertions(+), 41 deletions(-) rename opencl/test/unit_test/helpers/{memory_properties_helpers_tests.cpp => cl_memory_properties_helpers_tests.cpp} (93%) create mode 100644 shared/test/unit_test/helpers/memory_properties_helpers_tests.cpp diff --git a/opencl/test/unit_test/helpers/CMakeLists.txt b/opencl/test/unit_test/helpers/CMakeLists.txt index 09abb0d2f1..6f6ffbaed6 100644 --- a/opencl/test/unit_test/helpers/CMakeLists.txt +++ b/opencl/test/unit_test/helpers/CMakeLists.txt @@ -10,6 +10,7 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/base_object_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cl_helper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cl_hw_parse.h + ${CMAKE_CURRENT_SOURCE_DIR}/cl_memory_properties_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_info_builder_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/get_info_status_mapper_tests.cpp @@ -17,7 +18,6 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/hardware_commands_helper_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/heap_assigner_ocl_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/queue_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sampler_helpers_tests.cpp diff --git a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp b/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp similarity index 93% rename from opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp rename to opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp index a9951f9cfc..469e7ec3f5 100644 --- a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp +++ b/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp @@ -557,43 +557,3 @@ TEST_F(MemoryPropertiesHelperTests, givenSubDeviceIdWhenParsingExtraMemoryProper EXPECT_EQ(0b10u, memoryProperties.pDevice->getDeviceBitfield().to_ulong()); EXPECT_EQ(&context.pSubDevice1->getDevice(), memoryProperties.pDevice); } - -TEST_F(MemoryPropertiesHelperTests, whenQueryingUseSystemMemoryForCrossRootDeviceAccessThenReturnTrueForMultiRootDeviceContexts) { - for (auto multiRootDevice : {false, true}) { - EXPECT_EQ(multiRootDevice, MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(multiRootDevice)); - } -} - -TEST_F(MemoryPropertiesHelperTests, givenAllocateBuffersInLocalMemoryForMultiRootDeviceContextsWhenQueryingUseSystemMemoryForCrossRootDeviceAccessThenReturnFalseForMultiRootDeviceContexts) { - DebugManagerStateRestore restore; - - for (auto localMemory : {false, true}) { - DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); - EXPECT_FALSE(MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(false)); - } - - for (auto localMemory : {false, true}) { - DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); - EXPECT_NE(localMemory, MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(true)); - } -} - -TEST_F(MemoryPropertiesHelperTests, whenQueryingUseMultiStorageForCrossRootDeviceAccessThenReturnFalseForMultiRootDeviceContexts) { - for (auto multiRootDevice : {false, true}) { - EXPECT_FALSE(MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(multiRootDevice)); - } -} - -TEST_F(MemoryPropertiesHelperTests, givenAllocateBuffersInLocalMemoryForMultiRootDeviceContextsWhenQueryingUseMultiStorageForCrossRootDeviceAccessThenReturnTrueForMultiRootDeviceContexts) { - DebugManagerStateRestore restore; - - for (auto localMemory : {false, true}) { - DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); - EXPECT_FALSE(MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(false)); - } - - for (auto localMemory : {false, true}) { - DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); - EXPECT_EQ(localMemory, MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(true)); - } -} diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index 83298ed9d3..aca6ea688e 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -37,6 +37,7 @@ target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/matcher_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_management_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ptr_math_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ray_tracing_helper_tests.cpp diff --git a/shared/test/unit_test/helpers/memory_properties_helpers_tests.cpp b/shared/test/unit_test/helpers/memory_properties_helpers_tests.cpp new file mode 100644 index 0000000000..05bd5b966e --- /dev/null +++ b/shared/test/unit_test/helpers/memory_properties_helpers_tests.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/memory_properties_helpers.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" + +#include "gtest/gtest.h" + +using namespace NEO; + +TEST(MemoryPropertiesHelperTests, whenQueryingUseSystemMemoryForCrossRootDeviceAccessThenReturnTrueForMultiRootDeviceContexts) { + for (auto multiRootDevice : {false, true}) { + EXPECT_EQ(multiRootDevice, MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(multiRootDevice)); + } +} + +TEST(MemoryPropertiesHelperTests, givenAllocateBuffersInLocalMemoryForMultiRootDeviceContextsWhenQueryingUseSystemMemoryForCrossRootDeviceAccessThenReturnFalseForMultiRootDeviceContexts) { + DebugManagerStateRestore restore; + + for (auto localMemory : {false, true}) { + DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); + EXPECT_FALSE(MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(false)); + } + + for (auto localMemory : {false, true}) { + DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); + EXPECT_NE(localMemory, MemoryPropertiesHelper::useSystemMemoryForCrossRootDeviceAccess(true)); + } +} + +TEST(MemoryPropertiesHelperTests, whenQueryingUseMultiStorageForCrossRootDeviceAccessThenReturnFalseForMultiRootDeviceContexts) { + for (auto multiRootDevice : {false, true}) { + EXPECT_FALSE(MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(multiRootDevice)); + } +} + +TEST(MemoryPropertiesHelperTests, givenAllocateBuffersInLocalMemoryForMultiRootDeviceContextsWhenQueryingUseMultiStorageForCrossRootDeviceAccessThenReturnTrueForMultiRootDeviceContexts) { + DebugManagerStateRestore restore; + + for (auto localMemory : {false, true}) { + DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); + EXPECT_FALSE(MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(false)); + } + + for (auto localMemory : {false, true}) { + DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(localMemory); + EXPECT_EQ(localMemory, MemoryPropertiesHelper::useMultiStorageForCrossRootDeviceAccess(true)); + } +}