diff --git a/core/helpers/CMakeLists.txt b/core/helpers/CMakeLists.txt index 1392592dd8..5926cf956a 100644 --- a/core/helpers/CMakeLists.txt +++ b/core/helpers/CMakeLists.txt @@ -9,6 +9,8 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/abort.h ${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory.h ${CMAKE_CURRENT_SOURCE_DIR}/basic_math.h + ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h ${CMAKE_CURRENT_SOURCE_DIR}/common_types.h ${CMAKE_CURRENT_SOURCE_DIR}/completion_stamp.h ${CMAKE_CURRENT_SOURCE_DIR}/debug_helpers.h diff --git a/core/helpers/cache_policy.cpp b/core/helpers/cache_policy.cpp new file mode 100644 index 0000000000..efe4b4a99a --- /dev/null +++ b/core/helpers/cache_policy.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2017-2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "core/helpers/cache_policy.h" + +#include "core/helpers/aligned_memory.h" +#include "core/memory_manager/graphics_allocation.h" + +namespace NEO { + +bool isL3Capable(void *ptr, size_t size) { + return isAligned(ptr) && + isAligned(size); +} + +bool isL3Capable(const NEO::GraphicsAllocation &graphicsAllocation) { + return isL3Capable(graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize()); +} + +} // namespace NEO diff --git a/runtime/helpers/cache_policy.h b/core/helpers/cache_policy.h similarity index 100% rename from runtime/helpers/cache_policy.h rename to core/helpers/cache_policy.h diff --git a/runtime/command_queue/enqueue_read_buffer.h b/runtime/command_queue/enqueue_read_buffer.h index f9032a7fe7..3d8006c515 100644 --- a/runtime/command_queue/enqueue_read_buffer.h +++ b/runtime/command_queue/enqueue_read_buffer.h @@ -6,11 +6,11 @@ */ #pragma once +#include "core/helpers/cache_policy.h" #include "runtime/built_ins/built_ins.h" #include "runtime/command_queue/command_queue_hw.h" #include "runtime/command_queue/enqueue_common.h" #include "runtime/command_stream/command_stream_receiver.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/hardware_commands_helper.h" #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/surface.h" diff --git a/runtime/command_queue/enqueue_read_image.h b/runtime/command_queue/enqueue_read_image.h index 230c2f7284..1c076db7e2 100644 --- a/runtime/command_queue/enqueue_read_image.h +++ b/runtime/command_queue/enqueue_read_image.h @@ -7,13 +7,13 @@ #pragma once #include "core/helpers/basic_math.h" +#include "core/helpers/cache_policy.h" #include "core/memory_manager/graphics_allocation.h" #include "runtime/built_ins/built_ins.h" #include "runtime/command_queue/command_queue_hw.h" #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/context/context.h" #include "runtime/event/event.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/hardware_commands_helper.h" #include "runtime/helpers/mipmap.h" #include "runtime/helpers/surface_formats.h" diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index b5de3616b5..274c2488d4 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -8,6 +8,7 @@ #include "runtime/command_stream/command_stream_receiver.h" #include "core/command_stream/preemption.h" +#include "core/helpers/cache_policy.h" #include "core/helpers/string.h" #include "runtime/aub_mem_dump/aub_services.h" #include "runtime/built_ins/built_ins.h" @@ -18,7 +19,6 @@ #include "runtime/event/event.h" #include "runtime/gtpin/gtpin_notify.h" #include "runtime/helpers/array_count.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/flush_stamp.h" #include "runtime/helpers/timestamp_packet.h" #include "runtime/mem_obj/buffer.h" diff --git a/runtime/command_stream/command_stream_receiver_hw_base.inl b/runtime/command_stream/command_stream_receiver_hw_base.inl index 0093b7fae2..e796f4ffce 100644 --- a/runtime/command_stream/command_stream_receiver_hw_base.inl +++ b/runtime/command_stream/command_stream_receiver_hw_base.inl @@ -7,6 +7,7 @@ #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" +#include "core/helpers/cache_policy.h" #include "core/helpers/hw_helper.h" #include "core/helpers/preamble.h" #include "core/helpers/ptr_math.h" @@ -18,7 +19,6 @@ #include "runtime/event/event.h" #include "runtime/gtpin/gtpin_notify.h" #include "runtime/helpers/blit_commands_helper.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/flat_batch_buffer_helper_hw.h" #include "runtime/helpers/flush_stamp.h" #include "runtime/helpers/options.h" diff --git a/runtime/helpers/CMakeLists.txt b/runtime/helpers/CMakeLists.txt index 61dab1a2d7..0f87d44958 100644 --- a/runtime/helpers/CMakeLists.txt +++ b/runtime/helpers/CMakeLists.txt @@ -15,8 +15,6 @@ set(RUNTIME_SRCS_HELPERS_BASE ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.h - ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h ${CMAKE_CURRENT_SOURCE_DIR}/cl_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/convert_color.h ${CMAKE_CURRENT_SOURCE_DIR}/csr_deps.cpp diff --git a/runtime/helpers/cache_policy.cpp b/runtime/helpers/cache_policy.cpp index 727105542d..efe4b4a99a 100644 --- a/runtime/helpers/cache_policy.cpp +++ b/runtime/helpers/cache_policy.cpp @@ -5,7 +5,7 @@ * */ -#include "runtime/helpers/cache_policy.h" +#include "core/helpers/cache_policy.h" #include "core/helpers/aligned_memory.h" #include "core/memory_manager/graphics_allocation.h" diff --git a/runtime/helpers/state_base_address_base.inl b/runtime/helpers/state_base_address_base.inl index abe48e06f2..f6b9070881 100644 --- a/runtime/helpers/state_base_address_base.inl +++ b/runtime/helpers/state_base_address_base.inl @@ -5,10 +5,10 @@ * */ +#include "core/helpers/cache_policy.h" #include "core/helpers/hw_cmds.h" #include "core/memory_manager/memory_constants.h" #include "runtime/gmm_helper/gmm_helper.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/state_base_address.h" #include "runtime/indirect_heap/indirect_heap.h" diff --git a/runtime/memory_manager/surface.h b/runtime/memory_manager/surface.h index 8622d80f1b..ff267630ae 100644 --- a/runtime/memory_manager/surface.h +++ b/runtime/memory_manager/surface.h @@ -6,9 +6,9 @@ */ #pragma once +#include "core/helpers/cache_policy.h" #include "core/memory_manager/graphics_allocation.h" #include "runtime/command_stream/command_stream_receiver.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/mem_obj/mem_obj.h" namespace NEO { diff --git a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp index 6b4b1999a0..b2b60bcf1c 100644 --- a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp @@ -5,10 +5,10 @@ * */ +#include "core/helpers/cache_policy.h" #include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "runtime/built_ins/built_ins.h" #include "runtime/built_ins/builtins_dispatch_builder.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/memory_manager/allocations_list.h" #include "test.h" diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp index 3d62c4ce91..17471fb913 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_gmock_tests.cpp @@ -8,6 +8,7 @@ #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" #include "core/helpers/aligned_memory.h" +#include "core/helpers/cache_policy.h" #include "core/helpers/preamble.h" #include "core/helpers/ptr_math.h" #include "core/memory_manager/graphics_allocation.h" @@ -19,7 +20,6 @@ #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/command_stream/scratch_space_controller.h" #include "runtime/event/user_event.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/memory_manager.h" #include "runtime/os_interface/debug_settings_manager.h" diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index a383e51ccf..7b3f225eed 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -8,6 +8,7 @@ #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" #include "core/helpers/aligned_memory.h" +#include "core/helpers/cache_policy.h" #include "core/helpers/preamble.h" #include "core/helpers/ptr_math.h" #include "core/memory_manager/graphics_allocation.h" @@ -23,7 +24,6 @@ #include "runtime/command_stream/scratch_space_controller_base.h" #include "runtime/event/user_event.h" #include "runtime/helpers/blit_commands_helper.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/mem_obj/buffer.h" #include "runtime/mem_obj/mem_obj_helper.h" #include "runtime/memory_manager/memory_manager.h" diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index b64353038f..c9b24cc41d 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -7,11 +7,11 @@ #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" +#include "core/helpers/cache_policy.h" #include "core/memory_manager/graphics_allocation.h" #include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "runtime/aub_mem_dump/aub_services.h" #include "runtime/command_stream/command_stream_receiver.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/timestamp_packet.h" #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/internal_allocation_storage.h" diff --git a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h index c5e5efc171..174fffdb96 100644 --- a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h +++ b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h @@ -8,10 +8,10 @@ #pragma once #include "core/command_stream/linear_stream.h" #include "core/command_stream/preemption.h" +#include "core/helpers/cache_policy.h" #include "core/memory_manager/graphics_allocation.h" #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/gmm_helper/gmm_helper.h" -#include "runtime/helpers/cache_policy.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/dispatch_flags_helper.h" #include "unit_tests/helpers/hw_parse.h" diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 61b92c9b96..9eab825c87 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -6,10 +6,10 @@ */ #include "core/command_stream/preemption.h" +#include "core/helpers/cache_policy.h" #include "core/memory_manager/memory_constants.h" #include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "runtime/event/event.h" -#include "runtime/helpers/cache_policy.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/helpers/hardware_commands_helper.h" #include "runtime/mem_obj/image.h"