diff --git a/runtime/command_stream/definitions/engine_node.h b/runtime/command_stream/definitions/engine_node.h index 1c2fe93fd2..5bfe354409 100644 --- a/runtime/command_stream/definitions/engine_node.h +++ b/runtime/command_stream/definitions/engine_node.h @@ -18,11 +18,4 @@ enum EngineType : uint32_t { NUM_ENGINES }; -namespace EngineInstanceConstants { -constexpr uint32_t lowPriorityGpgpuEngineIndex = 1; -constexpr uint32_t numGpgpuEngineInstances = 2; -} // namespace EngineInstanceConstants - -constexpr uint32_t maxOsContextCount = EngineInstanceConstants::numGpgpuEngineInstances; -constexpr uint32_t maxHandleCount = 1u; } // namespace OCLRT diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index e0a5327c85..ab4c8254cf 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -175,7 +175,7 @@ bool Device::createEngines(const HardwareInfo *pHwInfo) { DeviceBitfield deviceBitfield; deviceBitfield.set(getDeviceIndex()); - bool lowPriority = deviceCsrIndex == EngineInstanceConstants::lowPriorityGpgpuEngineIndex; + bool lowPriority = deviceCsrIndex == HwHelper::lowPriorityGpgpuEngineIndex; auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(commandStreamReceiver, gpgpuEngines[deviceCsrIndex], deviceBitfield, preemptionMode, lowPriority); commandStreamReceiver->setupContext(*osContext); diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index def9a97484..4dda140572 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -60,6 +60,8 @@ class HwHelper { virtual const std::vector getGpgpuEngineInstances() const = 0; virtual bool getEnableLocalMemory(const HardwareInfo &hwInfo) const = 0; + static constexpr uint32_t lowPriorityGpgpuEngineIndex = 1; + protected: HwHelper() = default; }; diff --git a/runtime/memory_manager/CMakeLists.txt b/runtime/memory_manager/CMakeLists.txt index 245e5a3e13..a4a37bfa4a 100644 --- a/runtime/memory_manager/CMakeLists.txt +++ b/runtime/memory_manager/CMakeLists.txt @@ -14,6 +14,7 @@ set(RUNTIME_SRCS_MEMORY_MANAGER ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion.h ${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter.h + ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/engine_limits.h ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/storage_info.cpp ${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/storage_info.h ${CMAKE_CURRENT_SOURCE_DIR}/gfx_partition.cpp diff --git a/runtime/memory_manager/definitions/engine_limits.h b/runtime/memory_manager/definitions/engine_limits.h new file mode 100644 index 0000000000..48eb784649 --- /dev/null +++ b/runtime/memory_manager/definitions/engine_limits.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2017-2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include + +namespace OCLRT { + +constexpr uint32_t numGpgpuEngineInstances = 2u; +constexpr uint32_t maxOsContextCount = numGpgpuEngineInstances; +constexpr uint32_t maxHandleCount = 1u; + +} // namespace OCLRT diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index e433fb2bf5..0dd43c8e9b 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -17,6 +17,7 @@ #include "runtime/utilities/idlist.h" #include "runtime/utilities/stackvec.h" +#include "engine_limits.h" #include "storage_info.h" #include diff --git a/runtime/memory_manager/residency.h b/runtime/memory_manager/residency.h index f853cccb14..6bba5ec834 100644 --- a/runtime/memory_manager/residency.h +++ b/runtime/memory_manager/residency.h @@ -6,21 +6,15 @@ */ #pragma once -#include "engine_node.h" +#include "engine_limits.h" #include -#include -#include +#include namespace OCLRT { struct ResidencyData { - ResidencyData() { - std::fill_n(resident, sizeof(resident), false); - } - - ~ResidencyData() = default; - bool resident[maxOsContextCount]; + bool resident[maxOsContextCount] = {}; void updateCompletionData(uint64_t newFenceValue, uint32_t contextId); uint64_t getFenceValueForContextId(uint32_t contextId); diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 5b65d35fcc..c88e52920c 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -58,7 +58,7 @@ TEST_F(DeviceTest, givenDeviceWhenEngineIsCreatedThenSetInitialValueForTag) { TEST_F(DeviceTest, givenDeviceWhenAskedForSpecificEngineThenRetrunIt) { auto &engines = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances(); for (uint32_t i = 0; i < engines.size(); i++) { - bool lowPriority = (EngineInstanceConstants::lowPriorityGpgpuEngineIndex == i); + bool lowPriority = (HwHelper::lowPriorityGpgpuEngineIndex == i); auto &deviceEngine = pDevice->getEngine(engines[i], lowPriority); EXPECT_EQ(deviceEngine.osContext->getEngineType(), engines[i]); EXPECT_EQ(deviceEngine.osContext->isLowPriority(), lowPriority); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index a54039212b..82f8d1dc1d 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -1472,8 +1472,8 @@ using GraphicsAllocationTests = ::testing::Test; HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultCsrWhenCheckingUsageBeforeDestroyThenStoreItAsTemporaryAllocation) { auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - auto nonDefaultOsContext = device->engines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].osContext; - auto nonDefaultCsr = reinterpret_cast *>(device->engines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].commandStreamReceiver); + auto nonDefaultOsContext = device->engines[HwHelper::lowPriorityGpgpuEngineIndex].osContext; + auto nonDefaultCsr = static_cast *>(device->engines[HwHelper::lowPriorityGpgpuEngineIndex].commandStreamReceiver); auto memoryManager = device->getExecutionEnvironment()->memoryManager.get(); auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); @@ -1519,9 +1519,9 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedByManyOsContextsWhenCheckin memoryManager->multiContextResourceDestructor.reset(multiContextDestructor); auto device = std::unique_ptr(MockDevice::create(platformDevices[0], executionEnvironment, 0u)); - auto nonDefaultOsContext = device->engines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].osContext; - auto nonDefaultCsr = reinterpret_cast *>(device->engines[EngineInstanceConstants::lowPriorityGpgpuEngineIndex].commandStreamReceiver); - auto defaultCsr = reinterpret_cast *>(device->getDefaultEngine().commandStreamReceiver); + auto nonDefaultOsContext = device->engines[HwHelper::lowPriorityGpgpuEngineIndex].osContext; + auto nonDefaultCsr = static_cast *>(device->engines[HwHelper::lowPriorityGpgpuEngineIndex].commandStreamReceiver); + auto defaultCsr = static_cast *>(device->getDefaultEngine().commandStreamReceiver); auto defaultOsContext = device->getDefaultEngine().osContext; EXPECT_FALSE(defaultOsContext->isLowPriority());