feature: specify cache level when reserving a region

Related-To: NEO-12837
Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
Maciej Bielski
2024-12-04 15:54:56 +00:00
committed by Compute-Runtime-Automation
parent 37e81d2a11
commit 4467b1e8de
10 changed files with 15 additions and 15 deletions

View File

@@ -16,7 +16,7 @@
namespace NEO { namespace NEO {
CacheRegion ClosCacheReservation::reserveCache(CacheLevel cacheLevel, uint16_t numWays) { CacheRegion ClosCacheReservation::reserveCache(CacheLevel cacheLevel, uint16_t numWays) {
auto closIndex = allocEntry(); auto closIndex = allocEntry(cacheLevel);
if (closIndex == CacheRegion::none) { if (closIndex == CacheRegion::none) {
return CacheRegion::none; return CacheRegion::none;
} }
@@ -36,8 +36,8 @@ CacheRegion ClosCacheReservation::freeCache(CacheLevel cacheLevel, CacheRegion c
return freeEntry(closIndex); return freeEntry(closIndex);
} }
CacheRegion ClosCacheReservation::allocEntry() { CacheRegion ClosCacheReservation::allocEntry(CacheLevel cacheLevel) {
return ioctlHelper.closAlloc(); return ioctlHelper.closAlloc(cacheLevel);
} }
CacheRegion ClosCacheReservation::freeEntry(CacheRegion closIndex) { CacheRegion ClosCacheReservation::freeEntry(CacheRegion closIndex) {

View File

@@ -24,7 +24,7 @@ class ClosCacheReservation {
CacheRegion freeCache(CacheLevel cacheLevel, CacheRegion closIndex); CacheRegion freeCache(CacheLevel cacheLevel, CacheRegion closIndex);
protected: protected:
CacheRegion allocEntry(); CacheRegion allocEntry(CacheLevel cacheLevel);
CacheRegion freeEntry(CacheRegion closIndex); CacheRegion freeEntry(CacheRegion closIndex);
uint16_t allocCacheWay(CacheRegion closIndex, CacheLevel cacheLevel, uint16_t numWays); uint16_t allocCacheWay(CacheRegion closIndex, CacheLevel cacheLevel, uint16_t numWays);

View File

@@ -116,7 +116,7 @@ class IoctlHelper {
virtual bool isVmBindAvailable() = 0; virtual bool isVmBindAvailable() = 0;
virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) = 0; virtual int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) = 0;
virtual uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional<bool> isCoherent) = 0; virtual uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional<bool> isCoherent) = 0;
virtual CacheRegion closAlloc() = 0; virtual CacheRegion closAlloc(CacheLevel cacheLevel) = 0;
virtual uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0; virtual uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) = 0;
virtual CacheRegion closFree(CacheRegion closIndex) = 0; virtual CacheRegion closFree(CacheRegion closIndex) = 0;
virtual int waitUserFence(uint32_t ctxId, uint64_t address, virtual int waitUserFence(uint32_t ctxId, uint64_t address,
@@ -286,7 +286,7 @@ class IoctlHelperUpstream : public IoctlHelperI915 {
bool isChunkingAvailable() override; bool isChunkingAvailable() override;
bool isVmBindAvailable() override; bool isVmBindAvailable() override;
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override;
CacheRegion closAlloc() override; CacheRegion closAlloc(CacheLevel cacheLevel) override;
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
CacheRegion closFree(CacheRegion closIndex) override; CacheRegion closFree(CacheRegion closIndex) override;
int waitUserFence(uint32_t ctxId, uint64_t address, int waitUserFence(uint32_t ctxId, uint64_t address,
@@ -363,7 +363,7 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 {
bool isChunkingAvailable() override; bool isChunkingAvailable() override;
bool isVmBindAvailable() override; bool isVmBindAvailable() override;
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override;
CacheRegion closAlloc() override; CacheRegion closAlloc(CacheLevel cacheLevel) override;
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
CacheRegion closFree(CacheRegion closIndex) override; CacheRegion closFree(CacheRegion closIndex) override;
int waitUserFence(uint32_t ctxId, uint64_t address, int waitUserFence(uint32_t ctxId, uint64_t address,

View File

@@ -262,7 +262,7 @@ int IoctlHelperPrelim20::createGemExt(const MemRegionsVec &memClassInstances, si
return ret; return ret;
} }
CacheRegion IoctlHelperPrelim20::closAlloc() { CacheRegion IoctlHelperPrelim20::closAlloc(CacheLevel cacheLevel) {
struct prelim_drm_i915_gem_clos_reserve clos = {}; struct prelim_drm_i915_gem_clos_reserve clos = {};
int ret = IoctlHelper::ioctl(DrmIoctl::gemClosReserve, &clos); int ret = IoctlHelper::ioctl(DrmIoctl::gemClosReserve, &clos);

View File

@@ -115,7 +115,7 @@ void IoctlHelperUpstream::detectExtSetPatSupport() {
this->isSetPatSupported ? "enabled" : "disabled"); this->isSetPatSupported ? "enabled" : "disabled");
} }
CacheRegion IoctlHelperUpstream::closAlloc() { CacheRegion IoctlHelperUpstream::closAlloc(CacheLevel cacheLevel) {
return CacheRegion::none; return CacheRegion::none;
} }

View File

@@ -698,7 +698,7 @@ uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks, std::opti
return create.handle; return create.handle;
} }
CacheRegion IoctlHelperXe::closAlloc() { CacheRegion IoctlHelperXe::closAlloc(CacheLevel cacheLevel) {
xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__); xeLog(" -> IoctlHelperXe::%s\n", __FUNCTION__);
return CacheRegion::none; return CacheRegion::none;
} }

View File

@@ -47,7 +47,7 @@ class IoctlHelperXe : public IoctlHelper {
bool isVmBindAvailable() override; bool isVmBindAvailable() override;
int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override; int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, std::optional<uint32_t> memPolicyMode, std::optional<std::vector<unsigned long>> memPolicyNodemask, std::optional<bool> isCoherent) override;
uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional<bool> isCoherent) override; uint32_t createGem(uint64_t size, uint32_t memoryBanks, std::optional<bool> isCoherent) override;
CacheRegion closAlloc() override; CacheRegion closAlloc(CacheLevel cacheLevel) override;
uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override; uint16_t closAllocWays(CacheRegion closIndex, uint16_t cacheLevel, uint16_t numWays) override;
CacheRegion closFree(CacheRegion closIndex) override; CacheRegion closFree(CacheRegion closIndex) override;
int waitUserFence(uint32_t ctxId, uint64_t address, int waitUserFence(uint32_t ctxId, uint64_t address,

View File

@@ -240,7 +240,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCallIoctlThenProperIoctlRegiste
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocThenReturnCorrectRegion) { TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenClosAllocThenReturnCorrectRegion) {
drm->ioctlCallsCount = 0; drm->ioctlCallsCount = 0;
auto ioctlHelper = drm->getIoctlHelper(); auto ioctlHelper = drm->getIoctlHelper();
auto cacheRegion = ioctlHelper->closAlloc(); auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3);
EXPECT_EQ(CacheRegion::region1, cacheRegion); EXPECT_EQ(CacheRegion::region1, cacheRegion);
EXPECT_EQ(1u, drm->ioctlCallsCount); EXPECT_EQ(1u, drm->ioctlCallsCount);
@@ -250,7 +250,7 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimsAndInvalidIoctlReturnValWhenClosAll
drm->ioctlRetVal = -1; drm->ioctlRetVal = -1;
drm->ioctlCallsCount = 0; drm->ioctlCallsCount = 0;
auto ioctlHelper = drm->getIoctlHelper(); auto ioctlHelper = drm->getIoctlHelper();
auto cacheRegion = ioctlHelper->closAlloc(); auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3);
EXPECT_EQ(CacheRegion::none, cacheRegion); EXPECT_EQ(CacheRegion::none, cacheRegion);
EXPECT_EQ(1u, drm->ioctlCallsCount); EXPECT_EQ(1u, drm->ioctlCallsCount);

View File

@@ -468,7 +468,7 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenClosAllocThenReturnNoneRegion) {
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]); auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = drm->getIoctlHelper(); auto ioctlHelper = drm->getIoctlHelper();
auto cacheRegion = ioctlHelper->closAlloc(); auto cacheRegion = ioctlHelper->closAlloc(NEO::CacheLevel::level3);
EXPECT_EQ(CacheRegion::none, cacheRegion); EXPECT_EQ(CacheRegion::none, cacheRegion);
} }

View File

@@ -304,7 +304,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIsRe
EXPECT_FALSE(xeIoctlHelper->isSetPairAvailable()); EXPECT_FALSE(xeIoctlHelper->isSetPairAvailable());
EXPECT_EQ(CacheRegion::none, xeIoctlHelper->closAlloc()); EXPECT_EQ(CacheRegion::none, xeIoctlHelper->closAlloc(NEO::CacheLevel::level3));
EXPECT_EQ(0u, xeIoctlHelper->closAllocWays(CacheRegion::none, 0u, 0u)); EXPECT_EQ(0u, xeIoctlHelper->closAllocWays(CacheRegion::none, 0u, 0u));