From a551807480e7f24c31896e9b48e0b37b631ef01c Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 15 Dec 2025 13:17:06 +0000 Subject: [PATCH] refactor: merge memory properties into single header Signed-off-by: Mateusz Jablonski --- CMakeLists.txt | 1 - level_zero/core/source/kernel/kernel_hw.h | 2 +- .../cl_memory_properties_helpers_base.inl | 4 +-- opencl/source/mem_obj/buffer.h | 2 +- opencl/source/mem_obj/mem_obj.h | 3 +- opencl/source/mem_obj/mem_obj_helper.h | 2 +- .../cl_memory_properties_helpers_tests.cpp | 4 +-- opencl/test/unit_test/mem_obj/image_tests.cpp | 2 +- opencl/test/unit_test/mocks/mock_image.h | 3 +- shared/source/helpers/CMakeLists.txt | 1 + .../memory_properties_flags.h} | 21 ++++++++++++ .../memory_properties_helpers_base.inl | 5 ++- shared/source/memory_manager/memory_manager.h | 3 +- .../memory_manager/unified_memory_manager.h | 3 +- .../unified_memory_properties.h | 3 +- .../source/memory_properties/CMakeLists.txt | 14 -------- .../memory_properties_flags.h | 33 ------------------- 17 files changed, 37 insertions(+), 69 deletions(-) rename shared/source/{memory_properties/memory_properties_flags_common.inl => helpers/memory_properties_flags.h} (64%) delete mode 100644 shared/source/memory_properties/CMakeLists.txt delete mode 100644 shared/source/memory_properties/memory_properties_flags.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 06a6e2d4a1..c0bc93da77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -934,7 +934,6 @@ else() endif() endif() include_directories(${NEO_SHARED_DIRECTORY}/helpers/definitions${BRANCH_DIR_SUFFIX}) -include_directories(${NEO_SHARED_DIRECTORY}/memory_properties${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SHARED_DIRECTORY}/release_helper/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SHARED_DIRECTORY}/sku_info/definitions${BRANCH_DIR_SUFFIX}) diff --git a/level_zero/core/source/kernel/kernel_hw.h b/level_zero/core/source/kernel/kernel_hw.h index 1b1c2c9b0d..1c81d70080 100644 --- a/level_zero/core/source/kernel/kernel_hw.h +++ b/level_zero/core/source/kernel/kernel_hw.h @@ -12,6 +12,7 @@ #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/hw_mapper.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/kernel/kernel_arg_descriptor.h" #include "shared/source/memory_manager/graphics_allocation.h" @@ -26,7 +27,6 @@ #include "level_zero/core/source/module/module.h" #include "encode_surface_state_args.h" -#include "memory_properties_flags.h" #include #include diff --git a/opencl/source/helpers/cl_memory_properties_helpers_base.inl b/opencl/source/helpers/cl_memory_properties_helpers_base.inl index 80757a3316..4389ef4873 100644 --- a/opencl/source/helpers/cl_memory_properties_helpers_base.inl +++ b/opencl/source/helpers/cl_memory_properties_helpers_base.inl @@ -1,17 +1,17 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/helpers/bit_helpers.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "opencl/extensions/public/cl_ext_private.h" #include "opencl/source/helpers/cl_memory_properties_helpers.h" #include "CL/cl_ext.h" -#include "memory_properties_flags.h" namespace NEO { diff --git a/opencl/source/mem_obj/buffer.h b/opencl/source/mem_obj/buffer.h index 6c7eaef413..a0272c6982 100644 --- a/opencl/source/mem_obj/buffer.h +++ b/opencl/source/mem_obj/buffer.h @@ -7,11 +7,11 @@ #pragma once #include "shared/source/helpers/constants.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "opencl/extensions/public/cl_ext_private.h" #include "opencl/source/mem_obj/mem_obj.h" -#include "memory_properties_flags.h" #include "neo_igfxfmid.h" #include diff --git a/opencl/source/mem_obj/mem_obj.h b/opencl/source/mem_obj/mem_obj.h index 6990425415..e7fe331117 100644 --- a/opencl/source/mem_obj/mem_obj.h +++ b/opencl/source/mem_obj/mem_obj.h @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/memory_manager/multi_graphics_allocation.h" #include "opencl/extensions/public/cl_ext_private.h" @@ -15,8 +16,6 @@ #include "opencl/source/helpers/destructor_callbacks.h" #include "opencl/source/helpers/properties_helper.h" -#include "memory_properties_flags.h" - #include #include diff --git a/opencl/source/mem_obj/mem_obj_helper.h b/opencl/source/mem_obj/mem_obj_helper.h index 43819a0505..e8d8a9f322 100644 --- a/opencl/source/mem_obj/mem_obj_helper.h +++ b/opencl/source/mem_obj/mem_obj_helper.h @@ -8,13 +8,13 @@ #pragma once #include "shared/source/helpers/bit_helpers.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/unified_memory_manager.h" #include "opencl/extensions/public/cl_ext_private.h" #include "CL/cl.h" -#include "memory_properties_flags.h" namespace NEO { diff --git a/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp b/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp index 277164f76e..ca4b1d3c2e 100644 --- a/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp +++ b/opencl/test/unit_test/helpers/cl_memory_properties_helpers_tests.cpp @@ -1,11 +1,12 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/helpers/hw_info.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/helpers/memory_properties_helpers.h" #include "shared/source/memory_manager/allocation_properties.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" @@ -20,7 +21,6 @@ #include "CL/cl_ext.h" #include "gtest/gtest.h" -#include "memory_properties_flags.h" using namespace NEO; diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index 2d5b6f532f..0e466b33da 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/gmm_helper/gmm.h" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/bit_helpers.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/helpers/surface_format_info.h" #include "shared/source/image/image_surface_state.h" #include "shared/source/memory_manager/graphics_allocation.h" @@ -39,7 +40,6 @@ #include "opencl/test/unit_test/mocks/mock_platform.h" #include "CL/cl.h" -#include "memory_properties_flags.h" namespace NEO { template diff --git a/opencl/test/unit_test/mocks/mock_image.h b/opencl/test/unit_test/mocks/mock_image.h index 5f01f22c01..25951a9485 100644 --- a/opencl/test/unit_test/mocks/mock_image.h +++ b/opencl/test/unit_test/mocks/mock_image.h @@ -7,12 +7,11 @@ #pragma once +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "opencl/source/mem_obj/image.h" -#include "memory_properties_flags.h" - namespace NEO { struct MockImageBase : public Image { diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index b44d97a349..53d932b7c1 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -114,6 +114,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/local_id_gen_sse4.cpp ${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.cpp ${CMAKE_CURRENT_SOURCE_DIR}/local_work_size.h + ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags.h ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_base.inl diff --git a/shared/source/memory_properties/memory_properties_flags_common.inl b/shared/source/helpers/memory_properties_flags.h similarity index 64% rename from shared/source/memory_properties/memory_properties_flags_common.inl rename to shared/source/helpers/memory_properties_flags.h index 6fce338a8a..66e95d44ae 100644 --- a/shared/source/memory_properties/memory_properties_flags_common.inl +++ b/shared/source/helpers/memory_properties_flags.h @@ -5,9 +5,13 @@ * */ +#pragma once #include +#include namespace NEO { +class Device; + struct MemoryFlags { uint32_t readWrite : 1; uint32_t writeOnly : 1; @@ -41,4 +45,21 @@ struct MemoryAllocFlags { uint32_t usmInitialPlacementGpu : 1; }; +struct MemoryProperties { + uint64_t handle = 0; + uint64_t handleType = 0; + uintptr_t hostptr = 0; + const Device *pDevice = nullptr; + std::vector associatedDevices; + uint32_t memCacheClos = 0; + union { + MemoryFlags flags; + uint32_t allFlags = 0; + }; + union { + MemoryAllocFlags allocFlags; + uint32_t allAllocFlags = 0; + }; + static_assert(sizeof(MemoryProperties::flags) == sizeof(MemoryProperties::allFlags) && sizeof(MemoryProperties::allocFlags) == sizeof(MemoryProperties::allAllocFlags), ""); +}; } // namespace NEO diff --git a/shared/source/helpers/memory_properties_helpers_base.inl b/shared/source/helpers/memory_properties_helpers_base.inl index 753ec9f020..64c44e532a 100644 --- a/shared/source/helpers/memory_properties_helpers_base.inl +++ b/shared/source/helpers/memory_properties_helpers_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,11 +8,10 @@ #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/device/device.h" #include "shared/source/helpers/bit_helpers.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/helpers/memory_properties_helpers.h" #include "shared/source/memory_manager/allocation_properties.h" -#include "memory_properties_flags.h" - namespace NEO { AllocationProperties MemoryPropertiesHelper::getAllocationProperties( diff --git a/shared/source/memory_manager/memory_manager.h b/shared/source/memory_manager/memory_manager.h index a983b08b76..25ca2001cc 100644 --- a/shared/source/memory_manager/memory_manager.h +++ b/shared/source/memory_manager/memory_manager.h @@ -14,6 +14,7 @@ #include "shared/source/helpers/engine_control.h" #include "shared/source/helpers/engine_node_helper.h" #include "shared/source/helpers/heap_assigner.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/memory_manager/address_range.h" #include "shared/source/memory_manager/alignment_selector.h" #include "shared/source/memory_manager/definitions/storage_info.h" @@ -25,8 +26,6 @@ #include "shared/source/os_interface/product_helper.h" #include "shared/source/utilities/stackvec.h" -#include "memory_properties_flags.h" - #include #include #include diff --git a/shared/source/memory_manager/unified_memory_manager.h b/shared/source/memory_manager/unified_memory_manager.h index a123bafaca..9de5a0f4fe 100644 --- a/shared/source/memory_manager/unified_memory_manager.h +++ b/shared/source/memory_manager/unified_memory_manager.h @@ -10,6 +10,7 @@ #include "shared/source/helpers/common_types.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/device_bitfield.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/helpers/non_copyable_or_moveable.h" #include "shared/source/memory_manager/memadvise_flags.h" #include "shared/source/memory_manager/multi_graphics_allocation.h" @@ -18,8 +19,6 @@ #include "shared/source/utilities/sorted_vector.h" #include "shared/source/utilities/spinlock.h" -#include "memory_properties_flags.h" - #include #include #include diff --git a/shared/source/memory_manager/unified_memory_properties.h b/shared/source/memory_manager/unified_memory_properties.h index 3418dce4e9..6dabbb2cc2 100644 --- a/shared/source/memory_manager/unified_memory_properties.h +++ b/shared/source/memory_manager/unified_memory_properties.h @@ -7,12 +7,11 @@ #pragma once #include "shared/source/helpers/device_bitfield.h" +#include "shared/source/helpers/memory_properties_flags.h" #include "shared/source/memory_manager/allocation_type.h" #include "shared/source/unified_memory/unified_memory.h" #include "shared/source/utilities/stackvec.h" -#include "memory_properties_flags.h" - #include #include diff --git a/shared/source/memory_properties/CMakeLists.txt b/shared/source/memory_properties/CMakeLists.txt deleted file mode 100644 index d85f392997..0000000000 --- a/shared/source/memory_properties/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright (C) 2019-2021 Intel Corporation -# -# SPDX-License-Identifier: MIT -# - -set(NEO_CORE_MEMORY_PROPERTIES - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_properties_flags.h - ${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_flags_common.inl -) - -set_property(GLOBAL PROPERTY NEO_CORE_MEMORY_PROPERTIES ${NEO_CORE_MEMORY_PROPERTIES}) -add_subdirectories() diff --git a/shared/source/memory_properties/memory_properties_flags.h b/shared/source/memory_properties/memory_properties_flags.h deleted file mode 100644 index 4a5e119040..0000000000 --- a/shared/source/memory_properties/memory_properties_flags.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2019-2025 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#pragma once -#include "shared/source/memory_properties/memory_properties_flags_common.inl" - -#include -namespace NEO { - -class Device; - -struct MemoryProperties { - uint64_t handle = 0; - uint64_t handleType = 0; - uintptr_t hostptr = 0; - const Device *pDevice = nullptr; - std::vector associatedDevices; - uint32_t memCacheClos = 0; - union { - MemoryFlags flags; - uint32_t allFlags = 0; - }; - union { - MemoryAllocFlags allocFlags; - uint32_t allAllocFlags = 0; - }; - static_assert(sizeof(MemoryProperties::flags) == sizeof(MemoryProperties::allFlags) && sizeof(MemoryProperties::allocFlags) == sizeof(MemoryProperties::allAllocFlags), ""); -}; -} // namespace NEO