Remove cache info base class
There is only one implementation of said class and we don't even adhere to the interface it provides. Signed-off-by: Daniel Chabrowski <daniel.chabrowski@intel.com>
This commit is contained in:
parent
2d92379fe8
commit
4d4ccfd128
|
@ -28,7 +28,7 @@ struct BuffersWithClMemCacheClosTests : public DrmMemoryManagerLocalMemoryPrelim
|
||||||
auto memoryInfo = new MockExtendedMemoryInfo();
|
auto memoryInfo = new MockExtendedMemoryInfo();
|
||||||
|
|
||||||
mock->memoryInfo.reset(memoryInfo);
|
mock->memoryInfo.reset(memoryInfo);
|
||||||
mock->cacheInfo.reset(new MockCacheInfoImpl(*mock, 1024, 2, 32));
|
mock->cacheInfo.reset(new MockCacheInfo(*mock, 1024, 2, 32));
|
||||||
|
|
||||||
auto &multiTileArchInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->gtSystemInfo.MultiTileArchInfo;
|
auto &multiTileArchInfo = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->gtSystemInfo.MultiTileArchInfo;
|
||||||
multiTileArchInfo.TileCount = (memoryInfo->getDrmRegionInfos().size() - 1);
|
multiTileArchInfo.TileCount = (memoryInfo->getDrmRegionInfos().size() - 1);
|
||||||
|
|
|
@ -4446,7 +4446,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFalse
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
drm.cacheInfo.reset(new MockCacheInfoImpl(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
||||||
|
|
||||||
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
||||||
|
|
||||||
|
@ -4458,7 +4458,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenRe
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
drm.cacheInfo.reset(new MockCacheInfoImpl(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
||||||
|
|
||||||
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
||||||
|
|
||||||
|
@ -4470,7 +4470,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSe
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
drm.cacheInfo.reset(new MockCacheInfoImpl(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
||||||
|
|
||||||
MockBufferObject bo(&drm, 0, 0, 1);
|
MockBufferObject bo(&drm, 0, 0, 1);
|
||||||
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
|
||||||
|
@ -4566,7 +4566,7 @@ TEST(DrmAllocationTest, givenBoWhenMarkingForCaptureThenBosAreMarked) {
|
||||||
TEST_F(DrmMemoryManagerTest, givenDrmAllocationWithHostPtrWhenItIsCreatedWithCacheRegionThenSetRegionInBufferObject) {
|
TEST_F(DrmMemoryManagerTest, givenDrmAllocationWithHostPtrWhenItIsCreatedWithCacheRegionThenSetRegionInBufferObject) {
|
||||||
mock->ioctl_expected.total = -1;
|
mock->ioctl_expected.total = -1;
|
||||||
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
|
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
|
||||||
drm->cacheInfo.reset(new MockCacheInfoImpl(*drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
drm->cacheInfo.reset(new MockCacheInfo(*drm, 32 * MemoryConstants::kiloByte, 2, 32));
|
||||||
|
|
||||||
auto ptr = reinterpret_cast<void *>(0x1000);
|
auto ptr = reinterpret_cast<void *>(0x1000);
|
||||||
auto size = MemoryConstants::pageSize;
|
auto size = MemoryConstants::pageSize;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "shared/source/execution_environment/root_device_environment.h"
|
#include "shared/source/execution_environment/root_device_environment.h"
|
||||||
#include "shared/source/helpers/timestamp_packet.h"
|
#include "shared/source/helpers/timestamp_packet.h"
|
||||||
#include "shared/source/os_interface/hw_info_config.h"
|
#include "shared/source/os_interface/hw_info_config.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
#include "shared/source/os_interface/linux/clos_helper.h"
|
#include "shared/source/os_interface/linux/clos_helper.h"
|
||||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h"
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h"
|
||||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||||
|
@ -744,7 +744,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenClosEnabledAndAllocationToBeCach
|
||||||
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
|
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
|
||||||
csr->setupContext(*osContext);
|
csr->setupContext(*osContext);
|
||||||
|
|
||||||
mock->cacheInfo.reset(new CacheInfoImpl(*mock, 64 * MemoryConstants::kiloByte, 2, 32));
|
mock->cacheInfo.reset(new CacheInfo(*mock, 64 * MemoryConstants::kiloByte, 2, 32));
|
||||||
|
|
||||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
|
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper.h
|
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_info.h
|
${CMAKE_CURRENT_SOURCE_DIR}/cache_info.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_info_impl.h
|
${CMAKE_CURRENT_SOURCE_DIR}/cache_info.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/clos_cache.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/clos_cache.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/clos_cache.h
|
${CMAKE_CURRENT_SOURCE_DIR}/clos_cache.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/clos_helper.h
|
${CMAKE_CURRENT_SOURCE_DIR}/clos_helper.h
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
|
|
||||||
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||||
|
#include "shared/source/helpers/debug_helpers.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
|
||||||
|
CacheInfo::~CacheInfo() {
|
||||||
|
for (auto const &cacheRegion : cacheRegionsReserved) {
|
||||||
|
cacheReserve.freeCache(CacheLevel::Level3, cacheRegion.first);
|
||||||
|
}
|
||||||
|
cacheRegionsReserved.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheRegion CacheInfo::reserveRegion(size_t cacheReservationSize) {
|
||||||
|
uint16_t numWays = (maxReservationNumWays * cacheReservationSize) / maxReservationCacheSize;
|
||||||
|
if (DebugManager.flags.ClosNumCacheWays.get() != -1) {
|
||||||
|
numWays = DebugManager.flags.ClosNumCacheWays.get();
|
||||||
|
cacheReservationSize = (numWays * maxReservationCacheSize) / maxReservationNumWays;
|
||||||
|
}
|
||||||
|
auto regionIndex = cacheReserve.reserveCache(CacheLevel::Level3, numWays);
|
||||||
|
if (regionIndex == CacheRegion::None) {
|
||||||
|
return CacheRegion::None;
|
||||||
|
}
|
||||||
|
cacheRegionsReserved.insert({regionIndex, cacheReservationSize});
|
||||||
|
|
||||||
|
return regionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheRegion CacheInfo::freeRegion(CacheRegion regionIndex) {
|
||||||
|
auto search = cacheRegionsReserved.find(regionIndex);
|
||||||
|
if (search != cacheRegionsReserved.end()) {
|
||||||
|
cacheRegionsReserved.erase(search);
|
||||||
|
return cacheReserve.freeCache(CacheLevel::Level3, regionIndex);
|
||||||
|
}
|
||||||
|
return CacheRegion::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CacheInfo::isRegionReserved(CacheRegion regionIndex, [[maybe_unused]] size_t regionSize) const {
|
||||||
|
auto search = cacheRegionsReserved.find(regionIndex);
|
||||||
|
if (search != cacheRegionsReserved.end()) {
|
||||||
|
if (DebugManager.flags.ClosNumCacheWays.get() != -1) {
|
||||||
|
auto numWays = DebugManager.flags.ClosNumCacheWays.get();
|
||||||
|
regionSize = (numWays * maxReservationCacheSize) / maxReservationNumWays;
|
||||||
|
}
|
||||||
|
DEBUG_BREAK_IF(search->second != regionSize);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CacheInfo::getRegion(size_t regionSize, CacheRegion regionIndex) {
|
||||||
|
if (regionIndex == CacheRegion::Default) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!isRegionReserved(regionIndex, regionSize)) {
|
||||||
|
auto regionIdx = reserveRegion(regionSize);
|
||||||
|
if (regionIdx == CacheRegion::None) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DEBUG_BREAK_IF(regionIdx != regionIndex);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace NEO
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Intel Corporation
|
* Copyright (C) 2021-2022 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -7,8 +7,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/clos_cache.h"
|
||||||
|
#include "shared/source/utilities/spinlock.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
|
@ -27,13 +31,66 @@ enum class CacheRegion : uint16_t {
|
||||||
None = 0xFFFF
|
None = 0xFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CacheInfo {
|
enum class CacheLevel : uint16_t {
|
||||||
CacheInfo() = default;
|
Default = 0,
|
||||||
virtual ~CacheInfo() = 0;
|
Level3 = 3
|
||||||
|
|
||||||
virtual bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline CacheInfo::~CacheInfo(){};
|
class Drm;
|
||||||
|
|
||||||
|
struct CacheInfo {
|
||||||
|
CacheInfo(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays)
|
||||||
|
: maxReservationCacheSize(maxReservationCacheSize),
|
||||||
|
maxReservationNumCacheRegions(maxReservationNumCacheRegions),
|
||||||
|
maxReservationNumWays(maxReservationNumWays),
|
||||||
|
cacheReserve(drm) {
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL ~CacheInfo();
|
||||||
|
|
||||||
|
CacheInfo(const CacheInfo &) = delete;
|
||||||
|
CacheInfo &operator=(const CacheInfo &) = delete;
|
||||||
|
|
||||||
|
size_t getMaxReservationCacheSize() const {
|
||||||
|
return maxReservationCacheSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getMaxReservationNumCacheRegions() const {
|
||||||
|
return maxReservationNumCacheRegions;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getMaxReservationNumWays() const {
|
||||||
|
return maxReservationNumWays;
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheRegion reserveCacheRegion(size_t cacheReservationSize) {
|
||||||
|
std::unique_lock<SpinLock> lock{mtx};
|
||||||
|
return reserveRegion(cacheReservationSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheRegion freeCacheRegion(CacheRegion regionIndex) {
|
||||||
|
std::unique_lock<SpinLock> lock{mtx};
|
||||||
|
return freeRegion(regionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
MOCKABLE_VIRTUAL bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) {
|
||||||
|
std::unique_lock<SpinLock> lock{mtx};
|
||||||
|
return getRegion(regionSize, regionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CacheRegion reserveRegion(size_t cacheReservationSize);
|
||||||
|
CacheRegion freeRegion(CacheRegion regionIndex);
|
||||||
|
bool isRegionReserved(CacheRegion regionIndex, [[maybe_unused]] size_t regionSize) const;
|
||||||
|
bool getRegion(size_t regionSize, CacheRegion regionIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t maxReservationCacheSize;
|
||||||
|
uint32_t maxReservationNumCacheRegions;
|
||||||
|
uint16_t maxReservationNumWays;
|
||||||
|
ClosCacheReservation cacheReserve;
|
||||||
|
std::unordered_map<CacheRegion, size_t> cacheRegionsReserved;
|
||||||
|
SpinLock mtx;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2021-2022 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
||||||
#include "shared/source/helpers/debug_helpers.h"
|
|
||||||
#include "shared/source/os_interface/linux/cache_info.h"
|
|
||||||
#include "shared/source/os_interface/linux/clos_cache.h"
|
|
||||||
#include "shared/source/utilities/spinlock.h"
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
|
|
||||||
class Drm;
|
|
||||||
|
|
||||||
enum class CacheLevel : uint16_t {
|
|
||||||
Default = 0,
|
|
||||||
Level3 = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
class CacheInfoImpl : public CacheInfo {
|
|
||||||
public:
|
|
||||||
CacheInfoImpl(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays)
|
|
||||||
: maxReservationCacheSize(maxReservationCacheSize), maxReservationNumCacheRegions(maxReservationNumCacheRegions), maxReservationNumWays(maxReservationNumWays), cacheReserve(drm) {
|
|
||||||
}
|
|
||||||
|
|
||||||
~CacheInfoImpl() override {
|
|
||||||
for (auto const &cacheRegion : cacheRegionsReserved) {
|
|
||||||
cacheReserve.freeCache(CacheLevel::Level3, cacheRegion.first);
|
|
||||||
}
|
|
||||||
cacheRegionsReserved.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getMaxReservationCacheSize() const {
|
|
||||||
return maxReservationCacheSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getMaxReservationNumCacheRegions() const {
|
|
||||||
return maxReservationNumCacheRegions;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getMaxReservationNumWays() const {
|
|
||||||
return maxReservationNumWays;
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheRegion reserveCacheRegion(size_t cacheReservationSize) {
|
|
||||||
std::unique_lock<SpinLock> lock{mtx};
|
|
||||||
return reserveRegion(cacheReservationSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheRegion freeCacheRegion(CacheRegion regionIndex) {
|
|
||||||
std::unique_lock<SpinLock> lock{mtx};
|
|
||||||
return freeRegion(regionIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override {
|
|
||||||
std::unique_lock<SpinLock> lock{mtx};
|
|
||||||
return getRegion(regionSize, regionIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CacheRegion reserveRegion(size_t cacheReservationSize) {
|
|
||||||
uint16_t numWays = (maxReservationNumWays * cacheReservationSize) / maxReservationCacheSize;
|
|
||||||
if (DebugManager.flags.ClosNumCacheWays.get() != -1) {
|
|
||||||
numWays = DebugManager.flags.ClosNumCacheWays.get();
|
|
||||||
cacheReservationSize = (numWays * maxReservationCacheSize) / maxReservationNumWays;
|
|
||||||
}
|
|
||||||
auto regionIndex = cacheReserve.reserveCache(CacheLevel::Level3, numWays);
|
|
||||||
if (regionIndex == CacheRegion::None) {
|
|
||||||
return CacheRegion::None;
|
|
||||||
}
|
|
||||||
cacheRegionsReserved.insert({regionIndex, cacheReservationSize});
|
|
||||||
|
|
||||||
return regionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheRegion freeRegion(CacheRegion regionIndex) {
|
|
||||||
auto search = cacheRegionsReserved.find(regionIndex);
|
|
||||||
if (search != cacheRegionsReserved.end()) {
|
|
||||||
cacheRegionsReserved.erase(search);
|
|
||||||
return cacheReserve.freeCache(CacheLevel::Level3, regionIndex);
|
|
||||||
}
|
|
||||||
return CacheRegion::None;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isRegionReserved(CacheRegion regionIndex, [[maybe_unused]] size_t regionSize) const {
|
|
||||||
auto search = cacheRegionsReserved.find(regionIndex);
|
|
||||||
if (search != cacheRegionsReserved.end()) {
|
|
||||||
if (DebugManager.flags.ClosNumCacheWays.get() != -1) {
|
|
||||||
auto numWays = DebugManager.flags.ClosNumCacheWays.get();
|
|
||||||
regionSize = (numWays * maxReservationCacheSize) / maxReservationNumWays;
|
|
||||||
}
|
|
||||||
DEBUG_BREAK_IF(search->second != regionSize);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getRegion(size_t regionSize, CacheRegion regionIndex) {
|
|
||||||
if (regionIndex == CacheRegion::Default) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!isRegionReserved(regionIndex, regionSize)) {
|
|
||||||
auto regionIdx = reserveRegion(regionSize);
|
|
||||||
if (regionIdx == CacheRegion::None) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DEBUG_BREAK_IF(regionIdx != regionIndex);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t maxReservationCacheSize;
|
|
||||||
uint32_t maxReservationNumCacheRegions;
|
|
||||||
uint16_t maxReservationNumWays;
|
|
||||||
ClosCacheReservation cacheReserve;
|
|
||||||
std::unordered_map<CacheRegion, size_t> cacheRegionsReserved;
|
|
||||||
SpinLock mtx;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace NEO
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||||
|
|
||||||
#include "shared/source/memory_manager/residency.h"
|
#include "shared/source/memory_manager/residency.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||||
|
@ -53,7 +53,7 @@ bool DrmAllocation::setCacheRegion(Drm *drm, CacheRegion regionIndex) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cacheInfo = static_cast<CacheInfoImpl *>(drm->getCacheInfo());
|
auto cacheInfo = drm->getCacheInfo();
|
||||||
if (cacheInfo == nullptr) {
|
if (cacheInfo == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "shared/source/helpers/hw_info.h"
|
#include "shared/source/helpers/hw_info.h"
|
||||||
#include "shared/source/helpers/ptr_math.h"
|
#include "shared/source/helpers/ptr_math.h"
|
||||||
#include "shared/source/os_interface/driver_info.h"
|
#include "shared/source/os_interface/driver_info.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
#include "shared/source/os_interface/linux/clos_helper.h"
|
#include "shared/source/os_interface/linux/clos_helper.h"
|
||||||
#include "shared/source/os_interface/linux/drm_engine_mapper.h"
|
#include "shared/source/os_interface/linux/drm_engine_mapper.h"
|
||||||
#include "shared/source/os_interface/linux/drm_gem_close_worker.h"
|
#include "shared/source/os_interface/linux/drm_gem_close_worker.h"
|
||||||
|
@ -973,7 +973,7 @@ void Drm::setupCacheInfo(const HardwareInfo &hwInfo) {
|
||||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||||
|
|
||||||
if (DebugManager.flags.ClosEnabled.get() == 0 || hwHelper.getNumCacheRegions() == 0) {
|
if (DebugManager.flags.ClosEnabled.get() == 0 || hwHelper.getNumCacheRegions() == 0) {
|
||||||
this->cacheInfo.reset(new CacheInfoImpl(*this, 0, 0, 0));
|
this->cacheInfo.reset(new CacheInfo(*this, 0, 0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@ void Drm::setupCacheInfo(const HardwareInfo &hwInfo) {
|
||||||
const size_t maxReservationCacheSize = (totalCacheSize * maxReservationNumWays) / maxNumWays;
|
const size_t maxReservationCacheSize = (totalCacheSize * maxReservationNumWays) / maxNumWays;
|
||||||
const uint32_t maxReservationNumCacheRegions = hwHelper.getNumCacheRegions() - 1;
|
const uint32_t maxReservationNumCacheRegions = hwHelper.getNumCacheRegions() - 1;
|
||||||
|
|
||||||
this->cacheInfo.reset(new CacheInfoImpl(*this, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays));
|
this->cacheInfo.reset(new CacheInfo(*this, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Drm::getPrelimVersion(std::string &prelimVersion) {
|
void Drm::getPrelimVersion(std::string &prelimVersion) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "shared/source/helpers/basic_math.h"
|
#include "shared/source/helpers/basic_math.h"
|
||||||
#include "shared/source/helpers/ptr_math.h"
|
#include "shared/source/helpers/ptr_math.h"
|
||||||
#include "shared/source/helpers/string.h"
|
#include "shared/source/helpers/string.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
#include "shared/test/common/libult/linux/drm_mock_helper.h"
|
#include "shared/test/common/libult/linux/drm_mock_helper.h"
|
||||||
|
|
||||||
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||||
|
@ -93,8 +93,7 @@ int DrmMockPrelimContext::handlePrelimRequest(unsigned long request, void *arg)
|
||||||
if (cacheReserveArg->clos_index > closIndex) {
|
if (cacheReserveArg->clos_index > closIndex) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
auto cacheInfoImpl = static_cast<const CacheInfoImpl *>(cacheInfo);
|
auto maxReservationNumWays = cacheInfo ? cacheInfo->getMaxReservationNumWays() : maxNumWays;
|
||||||
auto maxReservationNumWays = cacheInfoImpl ? cacheInfoImpl->getMaxReservationNumWays() : maxNumWays;
|
|
||||||
if (cacheReserveArg->num_ways > maxReservationNumWays) {
|
if (cacheReserveArg->num_ways > maxReservationNumWays) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,18 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
struct MockCacheInfoImpl : public CacheInfoImpl {
|
struct MockCacheInfo : public CacheInfo {
|
||||||
using CacheInfoImpl::cacheRegionsReserved;
|
using CacheInfo::cacheRegionsReserved;
|
||||||
using CacheInfoImpl::isRegionReserved;
|
using CacheInfo::isRegionReserved;
|
||||||
|
|
||||||
MockCacheInfoImpl(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays)
|
MockCacheInfo(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays)
|
||||||
: CacheInfoImpl(drm, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays) {}
|
: CacheInfo(drm, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays) {}
|
||||||
|
|
||||||
~MockCacheInfoImpl() override = default;
|
~MockCacheInfo() override = default;
|
||||||
|
|
||||||
bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override {
|
bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override {
|
||||||
if (regionIndex >= CacheRegion::Count) {
|
if (regionIndex >= CacheRegion::Count) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shared/source/helpers/constants.h"
|
#include "shared/source/helpers/constants.h"
|
||||||
#include "shared/source/os_interface/linux/cache_info_impl.h"
|
#include "shared/source/os_interface/linux/cache_info.h"
|
||||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/common/helpers/default_hw_info.h"
|
#include "shared/test/common/helpers/default_hw_info.h"
|
||||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||||
|
@ -24,8 +24,9 @@ TEST(DrmCacheInfoTest, givenCacheRegionsExistsWhenCallingSetUpCacheInfoThenCache
|
||||||
auto &hwHelper = HwHelper::get(drm.context.hwInfo->platform.eRenderCoreFamily);
|
auto &hwHelper = HwHelper::get(drm.context.hwInfo->platform.eRenderCoreFamily);
|
||||||
|
|
||||||
drm.setupCacheInfo(*defaultHwInfo.get());
|
drm.setupCacheInfo(*defaultHwInfo.get());
|
||||||
EXPECT_NE(nullptr, drm.getCacheInfo());
|
|
||||||
auto cacheInfo = static_cast<CacheInfoImpl *>(drm.getCacheInfo());
|
auto cacheInfo = drm.getCacheInfo();
|
||||||
|
EXPECT_NE(nullptr, cacheInfo);
|
||||||
|
|
||||||
if (hwHelper.getNumCacheRegions() == 0) {
|
if (hwHelper.getNumCacheRegions() == 0) {
|
||||||
EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize());
|
EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize());
|
||||||
|
@ -56,7 +57,7 @@ TEST(DrmCacheInfoTest, givenDebugFlagSetWhenCallingSetUpCacheInfoThenCacheInfoIs
|
||||||
|
|
||||||
drm.setupCacheInfo(*defaultHwInfo.get());
|
drm.setupCacheInfo(*defaultHwInfo.get());
|
||||||
EXPECT_NE(nullptr, drm.getCacheInfo());
|
EXPECT_NE(nullptr, drm.getCacheInfo());
|
||||||
auto cacheInfo = static_cast<CacheInfoImpl *>(drm.getCacheInfo());
|
auto cacheInfo = drm.getCacheInfo();
|
||||||
|
|
||||||
EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize());
|
EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize());
|
||||||
EXPECT_EQ(0u, cacheInfo->getMaxReservationNumCacheRegions());
|
EXPECT_EQ(0u, cacheInfo->getMaxReservationNumCacheRegions());
|
||||||
|
@ -68,7 +69,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionSucceedsToReserveC
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
CacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
CacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
||||||
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
||||||
|
|
||||||
EXPECT_TRUE(cacheInfo.getCacheRegion(cacheReservationSize, CacheRegion::Region1));
|
EXPECT_TRUE(cacheInfo.getCacheRegion(cacheReservationSize, CacheRegion::Region1));
|
||||||
|
@ -81,7 +82,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionFailsToReserveCach
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
CacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
CacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
||||||
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
||||||
|
|
||||||
drm.context.closIndex = 0xFFFF;
|
drm.context.closIndex = 0xFFFF;
|
||||||
|
@ -95,7 +96,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWithReservedCacheRegionWhenGetCacheRegionIs
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
CacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
CacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
||||||
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
size_t cacheReservationSize = cacheInfo.getMaxReservationCacheSize();
|
||||||
|
|
||||||
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(cacheReservationSize));
|
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(cacheReservationSize));
|
||||||
|
@ -110,7 +111,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionIsCalledForReserva
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
CacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
CacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
||||||
size_t regionSize = cacheInfo.getMaxReservationCacheSize() / cacheInfo.getMaxReservationNumCacheRegions();
|
size_t regionSize = cacheInfo.getMaxReservationCacheSize() / cacheInfo.getMaxReservationNumCacheRegions();
|
||||||
|
|
||||||
EXPECT_TRUE(cacheInfo.getCacheRegion(regionSize, CacheRegion::Region1));
|
EXPECT_TRUE(cacheInfo.getCacheRegion(regionSize, CacheRegion::Region1));
|
||||||
|
@ -130,7 +131,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWhenSpecificNumCacheWaysIsRequestedThenRese
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
MockCacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, maxNumCacheWays);
|
MockCacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, maxNumCacheWays);
|
||||||
size_t maxReservationCacheSize = cacheInfo.getMaxReservationCacheSize();
|
size_t maxReservationCacheSize = cacheInfo.getMaxReservationCacheSize();
|
||||||
|
|
||||||
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize));
|
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize));
|
||||||
|
@ -150,7 +151,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWhenNumCacheWaysIsExceededThenDontReserveCa
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
MockCacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, maxNumCacheWays);
|
MockCacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, maxNumCacheWays);
|
||||||
size_t maxReservationCacheSize = cacheInfo.getMaxReservationCacheSize();
|
size_t maxReservationCacheSize = cacheInfo.getMaxReservationCacheSize();
|
||||||
|
|
||||||
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize));
|
EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize));
|
||||||
|
@ -165,7 +166,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenFreeCacheRegionIsCalledForNonRes
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|
||||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
MockCacheInfoImpl cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
MockCacheInfo cacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32);
|
||||||
|
|
||||||
cacheInfo.cacheRegionsReserved.insert({CacheRegion::Region1, MemoryConstants::kiloByte});
|
cacheInfo.cacheRegionsReserved.insert({CacheRegion::Region1, MemoryConstants::kiloByte});
|
||||||
EXPECT_EQ(CacheRegion::None, cacheInfo.freeCacheRegion(CacheRegion::Region1));
|
EXPECT_EQ(CacheRegion::None, cacheInfo.freeCacheRegion(CacheRegion::Region1));
|
||||||
|
|
Loading…
Reference in New Issue