diff --git a/opencl/test/unit_test/os_interface/linux/cl_mem_cache_clos_tests_xe_hpc.cpp b/opencl/test/unit_test/os_interface/linux/cl_mem_cache_clos_tests_xe_hpc.cpp index 1d62f24eb3..e3fcef162b 100644 --- a/opencl/test/unit_test/os_interface/linux/cl_mem_cache_clos_tests_xe_hpc.cpp +++ b/opencl/test/unit_test/os_interface/linux/cl_mem_cache_clos_tests_xe_hpc.cpp @@ -28,7 +28,7 @@ struct BuffersWithClMemCacheClosTests : public DrmMemoryManagerLocalMemoryPrelim auto memoryInfo = new MockExtendedMemoryInfo(); 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; multiTileArchInfo.TileCount = (memoryInfo->getDrmRegionInfos().size() - 1); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 6c15e10a40..59891d8672 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -4446,7 +4446,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFalse executionEnvironment->prepareRootDeviceEnvironments(1); 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); @@ -4458,7 +4458,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenRe executionEnvironment->prepareRootDeviceEnvironments(1); 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); @@ -4470,7 +4470,7 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSe executionEnvironment->prepareRootDeviceEnvironments(1); 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); MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory); @@ -4566,7 +4566,7 @@ TEST(DrmAllocationTest, givenBoWhenMarkingForCaptureThenBosAreMarked) { TEST_F(DrmMemoryManagerTest, givenDrmAllocationWithHostPtrWhenItIsCreatedWithCacheRegionThenSetRegionInBufferObject) { mock->ioctl_expected.total = -1; auto drm = static_cast(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as()); - 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(0x1000); auto size = MemoryConstants::pageSize; diff --git a/opencl/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp index cb358bc24a..ce19370cfc 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_residency_handler_prelim_tests.cpp @@ -11,7 +11,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/timestamp_packet.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/drm_memory_operations_handler_bind.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()); 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}); diff --git a/shared/source/os_interface/linux/CMakeLists.txt b/shared/source/os_interface/linux/CMakeLists.txt index ec1c7bae30..7b95eddd62 100644 --- a/shared/source/os_interface/linux/CMakeLists.txt +++ b/shared/source/os_interface/linux/CMakeLists.txt @@ -8,7 +8,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper.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.h ${CMAKE_CURRENT_SOURCE_DIR}/clos_helper.h diff --git a/shared/source/os_interface/linux/cache_info.cpp b/shared/source/os_interface/linux/cache_info.cpp new file mode 100644 index 0000000000..fa9ab0edb3 --- /dev/null +++ b/shared/source/os_interface/linux/cache_info.cpp @@ -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 diff --git a/shared/source/os_interface/linux/cache_info.h b/shared/source/os_interface/linux/cache_info.h index 40f8131675..dbf71b7ae5 100644 --- a/shared/source/os_interface/linux/cache_info.h +++ b/shared/source/os_interface/linux/cache_info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,8 +7,12 @@ #pragma once +#include "shared/source/os_interface/linux/clos_cache.h" +#include "shared/source/utilities/spinlock.h" + #include #include +#include namespace NEO { @@ -27,13 +31,66 @@ enum class CacheRegion : uint16_t { None = 0xFFFF }; -struct CacheInfo { - CacheInfo() = default; - virtual ~CacheInfo() = 0; - - virtual bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) = 0; +enum class CacheLevel : uint16_t { + Default = 0, + Level3 = 3 }; -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 lock{mtx}; + return reserveRegion(cacheReservationSize); + } + + CacheRegion freeCacheRegion(CacheRegion regionIndex) { + std::unique_lock lock{mtx}; + return freeRegion(regionIndex); + } + + MOCKABLE_VIRTUAL bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) { + std::unique_lock 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 cacheRegionsReserved; + SpinLock mtx; +}; } // namespace NEO diff --git a/shared/source/os_interface/linux/cache_info_impl.h b/shared/source/os_interface/linux/cache_info_impl.h deleted file mode 100644 index 4d49238580..0000000000 --- a/shared/source/os_interface/linux/cache_info_impl.h +++ /dev/null @@ -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 - -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 lock{mtx}; - return reserveRegion(cacheReservationSize); - } - - CacheRegion freeCacheRegion(CacheRegion regionIndex) { - std::unique_lock lock{mtx}; - return freeRegion(regionIndex); - } - - bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override { - std::unique_lock 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 cacheRegionsReserved; - SpinLock mtx; -}; - -} // namespace NEO diff --git a/shared/source/os_interface/linux/drm_allocation.cpp b/shared/source/os_interface/linux/drm_allocation.cpp index 0a63f9061d..748f2ded9f 100644 --- a/shared/source/os_interface/linux/drm_allocation.cpp +++ b/shared/source/os_interface/linux/drm_allocation.cpp @@ -8,7 +8,7 @@ #include "shared/source/os_interface/linux/drm_allocation.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_memory_manager.h" #include "shared/source/os_interface/linux/ioctl_helper.h" @@ -53,7 +53,7 @@ bool DrmAllocation::setCacheRegion(Drm *drm, CacheRegion regionIndex) { return true; } - auto cacheInfo = static_cast(drm->getCacheInfo()); + auto cacheInfo = drm->getCacheInfo(); if (cacheInfo == nullptr) { return false; } diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 61e35cb76d..078f91eacf 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -16,7 +16,7 @@ #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/ptr_math.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/drm_engine_mapper.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); 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; } @@ -987,7 +987,7 @@ void Drm::setupCacheInfo(const HardwareInfo &hwInfo) { const size_t maxReservationCacheSize = (totalCacheSize * maxReservationNumWays) / maxNumWays; 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) { diff --git a/shared/test/common/libult/linux/drm_mock_prelim_context.cpp b/shared/test/common/libult/linux/drm_mock_prelim_context.cpp index ae4fa66071..a3c54833d0 100644 --- a/shared/test/common/libult/linux/drm_mock_prelim_context.cpp +++ b/shared/test/common/libult/linux/drm_mock_prelim_context.cpp @@ -10,7 +10,7 @@ #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/ptr_math.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 "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) { return EINVAL; } - auto cacheInfoImpl = static_cast(cacheInfo); - auto maxReservationNumWays = cacheInfoImpl ? cacheInfoImpl->getMaxReservationNumWays() : maxNumWays; + auto maxReservationNumWays = cacheInfo ? cacheInfo->getMaxReservationNumWays() : maxNumWays; if (cacheReserveArg->num_ways > maxReservationNumWays) { return EINVAL; } diff --git a/shared/test/common/os_interface/linux/drm_mock_cache_info.h b/shared/test/common/os_interface/linux/drm_mock_cache_info.h index 21ebcef69b..96879ea5a5 100644 --- a/shared/test/common/os_interface/linux/drm_mock_cache_info.h +++ b/shared/test/common/os_interface/linux/drm_mock_cache_info.h @@ -7,18 +7,18 @@ #pragma once -#include "shared/source/os_interface/linux/cache_info_impl.h" +#include "shared/source/os_interface/linux/cache_info.h" namespace NEO { -struct MockCacheInfoImpl : public CacheInfoImpl { - using CacheInfoImpl::cacheRegionsReserved; - using CacheInfoImpl::isRegionReserved; +struct MockCacheInfo : public CacheInfo { + using CacheInfo::cacheRegionsReserved; + using CacheInfo::isRegionReserved; - MockCacheInfoImpl(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays) - : CacheInfoImpl(drm, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays) {} + MockCacheInfo(Drm &drm, size_t maxReservationCacheSize, uint32_t maxReservationNumCacheRegions, uint16_t maxReservationNumWays) + : CacheInfo(drm, maxReservationCacheSize, maxReservationNumCacheRegions, maxReservationNumWays) {} - ~MockCacheInfoImpl() override = default; + ~MockCacheInfo() override = default; bool getCacheRegion(size_t regionSize, CacheRegion regionIndex) override { if (regionIndex >= CacheRegion::Count) { diff --git a/shared/test/unit_test/os_interface/linux/drm_cache_info_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_cache_info_tests.cpp index 42a797b7b9..08bb8876f3 100644 --- a/shared/test/unit_test/os_interface/linux/drm_cache_info_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_cache_info_tests.cpp @@ -6,7 +6,7 @@ */ #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/default_hw_info.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); drm.setupCacheInfo(*defaultHwInfo.get()); - EXPECT_NE(nullptr, drm.getCacheInfo()); - auto cacheInfo = static_cast(drm.getCacheInfo()); + + auto cacheInfo = drm.getCacheInfo(); + EXPECT_NE(nullptr, cacheInfo); if (hwHelper.getNumCacheRegions() == 0) { EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize()); @@ -56,7 +57,7 @@ TEST(DrmCacheInfoTest, givenDebugFlagSetWhenCallingSetUpCacheInfoThenCacheInfoIs drm.setupCacheInfo(*defaultHwInfo.get()); EXPECT_NE(nullptr, drm.getCacheInfo()); - auto cacheInfo = static_cast(drm.getCacheInfo()); + auto cacheInfo = drm.getCacheInfo(); EXPECT_EQ(0u, cacheInfo->getMaxReservationCacheSize()); EXPECT_EQ(0u, cacheInfo->getMaxReservationNumCacheRegions()); @@ -68,7 +69,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionSucceedsToReserveC executionEnvironment->prepareRootDeviceEnvironments(1); 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(); EXPECT_TRUE(cacheInfo.getCacheRegion(cacheReservationSize, CacheRegion::Region1)); @@ -81,7 +82,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionFailsToReserveCach executionEnvironment->prepareRootDeviceEnvironments(1); 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(); drm.context.closIndex = 0xFFFF; @@ -95,7 +96,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWithReservedCacheRegionWhenGetCacheRegionIs executionEnvironment->prepareRootDeviceEnvironments(1); 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(); EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(cacheReservationSize)); @@ -110,7 +111,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenGetCacheRegionIsCalledForReserva executionEnvironment->prepareRootDeviceEnvironments(1); 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(); EXPECT_TRUE(cacheInfo.getCacheRegion(regionSize, CacheRegion::Region1)); @@ -130,7 +131,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWhenSpecificNumCacheWaysIsRequestedThenRese executionEnvironment->prepareRootDeviceEnvironments(1); 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(); EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize)); @@ -150,7 +151,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoWhenNumCacheWaysIsExceededThenDontReserveCa executionEnvironment->prepareRootDeviceEnvironments(1); 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(); EXPECT_EQ(CacheRegion::Region1, cacheInfo.reserveCacheRegion(maxReservationCacheSize)); @@ -165,7 +166,7 @@ TEST(DrmCacheInfoTest, givenCacheInfoCreatedWhenFreeCacheRegionIsCalledForNonRes executionEnvironment->prepareRootDeviceEnvironments(1); 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}); EXPECT_EQ(CacheRegion::None, cacheInfo.freeCacheRegion(CacheRegion::Region1));