Move isl3Capable outside of Graphics Allocation.

Change-Id: If9949f0d6d3405dcdeb221cbee1ce30307166c21
This commit is contained in:
Mrozek, Michal
2019-02-27 14:52:10 +01:00
committed by sys_ocldev
parent 030ba34de5
commit 6cb4732abe
6 changed files with 23 additions and 17 deletions

View File

@@ -103,7 +103,7 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &alloc
void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) {
makeResident(*gfxAllocation);
if (!gfxAllocation->isL3Capable()) {
if (!isL3Capable(*gfxAllocation)) {
setDisableL3Cache(true);
}
}

View File

@@ -8,6 +8,9 @@
#include "runtime/helpers/cache_policy.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/memory_manager/graphics_allocation.h"
namespace OCLRT {
bool isL3Capable(void *ptr, size_t size) {
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr &&
@@ -15,4 +18,11 @@ bool isL3Capable(void *ptr, size_t size) {
return true;
}
return false;
}
}
bool isL3Capable(const OCLRT::GraphicsAllocation &graphicsAllocation) {
auto ptr = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast<size_t>(graphicsAllocation.allocationOffset));
return isL3Capable(ptr, graphicsAllocation.getUnderlyingBufferSize());
}
} // namespace OCLRT

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -14,4 +14,8 @@ constexpr uint32_t l3CacheOff = GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGN
constexpr uint32_t unknownMocs = GMM_RESOURCE_USAGE_UNKNOWN;
} // namespace CacheSettings
bool isL3Capable(void *ptr, size_t size);
namespace OCLRT {
class GraphicsAllocation;
bool isL3Capable(void *ptr, size_t size);
bool isL3Capable(const GraphicsAllocation &graphicsAllocation);
} // namespace OCLRT

View File

@@ -17,14 +17,6 @@ void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
this->allocationType = allocationType;
}
bool GraphicsAllocation::isL3Capable() {
auto ptr = ptrOffset(cpuPtr, static_cast<size_t>(this->allocationOffset));
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && alignUp(this->size, MemoryConstants::cacheLineSize) == this->size) {
return true;
}
return false;
}
GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress,
size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable)
: gpuBaseAddress(baseAddress),

View File

@@ -127,7 +127,6 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
bool isMemObjectsAllocationWithWritableFlags() const { return memObjectsAllocationWithWritableFlags; }
void setMemObjectsAllocationWithWritableFlags(bool newValue) { memObjectsAllocationWithWritableFlags = newValue; }
bool isL3Capable();
void setEvictable(bool evictable) { this->evictable = evictable; }
bool peekEvictable() const { return evictable; }

View File

@@ -7,6 +7,7 @@
#include "runtime/command_stream/preemption.h"
#include "runtime/event/event.h"
#include "runtime/helpers/cache_policy.h"
#include "runtime/helpers/dispatch_info.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/mem_obj/image.h"
@@ -225,7 +226,7 @@ TEST_F(MemoryAllocatorTest, GivenAlignedHostPtrAndCacheAlignedSizeWhenAskedForL3
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(MockAllocationProperties{false, alignedSize}, ptr);
EXPECT_TRUE(graphicsAllocation->isL3Capable());
EXPECT_TRUE(isL3Capable(*graphicsAllocation));
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
@@ -236,7 +237,7 @@ TEST_F(MemoryAllocatorTest, GivenAlignedHostPtrAndNotCacheAlignedSizeWhenAskedFo
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(MockAllocationProperties{false, alignedSize}, ptr);
EXPECT_FALSE(graphicsAllocation->isL3Capable());
EXPECT_FALSE(isL3Capable(*graphicsAllocation));
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
@@ -247,7 +248,7 @@ TEST_F(MemoryAllocatorTest, GivenMisAlignedHostPtrAndNotCacheAlignedSizeWhenAske
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(MockAllocationProperties{false, alignedSize}, ptr);
EXPECT_FALSE(graphicsAllocation->isL3Capable());
EXPECT_FALSE(isL3Capable(*graphicsAllocation));
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
@@ -258,7 +259,7 @@ TEST_F(MemoryAllocatorTest, GivenHostPtrAlignedToCacheLineWhenAskedForL3Allowanc
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(MockAllocationProperties{false, alignedSize}, ptr);
EXPECT_TRUE(graphicsAllocation->isL3Capable());
EXPECT_TRUE(isL3Capable(*graphicsAllocation));
memoryManager->freeGraphicsMemory(graphicsAllocation);
}