Move residency and eviction allocations from MemoryManager to CSR

Change-Id: I44185b35375f4cc9d58cac14cac1edefaacde652
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2018-09-13 15:49:38 +02:00
committed by sys_ocldev
parent fa30e0dc1f
commit 8df30ceac1
6 changed files with 50 additions and 88 deletions

View File

@@ -39,6 +39,8 @@ CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]
CommandStreamReceiver::CommandStreamReceiver(ExecutionEnvironment &executionEnvironment)
: executionEnvironment(executionEnvironment) {
residencyAllocations.reserve(20);
latestSentStatelessMocsConfig = CacheSettings::unknownMocs;
submissionAggregator.reset(new SubmissionAggregator());
if (DebugManager.flags.CsrDispatchMode.get()) {
@@ -265,27 +267,27 @@ void CommandStreamReceiver::initProgrammingFlags() {
}
ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() {
return this->memoryManager->getResidencyAllocations();
return this->residencyAllocations;
}
void CommandStreamReceiver::pushAllocationForResidency(GraphicsAllocation *gfxAllocation) {
this->memoryManager->pushAllocationForResidency(gfxAllocation);
this->residencyAllocations.push_back(gfxAllocation);
}
void CommandStreamReceiver::clearResidencyAllocations() {
this->memoryManager->clearResidencyAllocations();
this->residencyAllocations.clear();
}
ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() {
return this->memoryManager->getEvictionAllocations();
return this->evictionAllocations;
}
void CommandStreamReceiver::pushAllocationForEviction(GraphicsAllocation *gfxAllocation) {
this->memoryManager->pushAllocationForEviction(gfxAllocation);
this->evictionAllocations.push_back(gfxAllocation);
}
void CommandStreamReceiver::clearEvictionAllocations() {
this->memoryManager->clearEvictionAllocations();
this->evictionAllocations.clear();
}
void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {}

View File

@@ -211,6 +211,9 @@ class CommandStreamReceiver {
OSInterface *osInterface = nullptr;
std::unique_ptr<SubmissionAggregator> submissionAggregator;
ResidencyContainer residencyAllocations;
ResidencyContainer evictionAllocations;
bool nTo1SubmissionModelEnabled = false;
DispatchMode dispatchMode = DispatchMode::ImmediateDispatch;
bool disableL3Cache = false;

View File

@@ -73,9 +73,7 @@ GraphicsAllocation *AllocationsList::detachAllocationImpl(GraphicsAllocation *,
}
MemoryManager::MemoryManager(bool enable64kbpages, bool enableLocalMemory) : allocator32Bit(nullptr), enable64kbpages(enable64kbpages),
localMemorySupported(enableLocalMemory) {
residencyAllocations.reserve(20);
};
localMemorySupported(enableLocalMemory){};
MemoryManager::~MemoryManager() {
freeAllocationsList(-1, graphicsAllocations);
@@ -294,22 +292,6 @@ TagAllocator<TimestampPacket> *MemoryManager::getTimestampPacketAllocator() {
return timestampPacketAllocator.get();
}
void MemoryManager::pushAllocationForResidency(GraphicsAllocation *gfxAllocation) {
residencyAllocations.push_back(gfxAllocation);
}
void MemoryManager::clearResidencyAllocations() {
residencyAllocations.clear();
}
void MemoryManager::pushAllocationForEviction(GraphicsAllocation *gfxAllocation) {
evictionAllocations.push_back(gfxAllocation);
}
void MemoryManager::clearEvictionAllocations() {
evictionAllocations.clear();
}
void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
freeGraphicsMemoryImpl(gfxAllocation);
}

View File

@@ -227,17 +227,6 @@ class MemoryManager {
void setVirtualPaddingSupport(bool virtualPaddingSupport) { virtualPaddingAvailable = virtualPaddingSupport; }
GraphicsAllocation *peekPaddingAllocation() { return paddingAllocation; }
void pushAllocationForResidency(GraphicsAllocation *gfxAllocation);
void clearResidencyAllocations();
ResidencyContainer &getResidencyAllocations() {
return residencyAllocations;
}
void pushAllocationForEviction(GraphicsAllocation *gfxAllocation);
void clearEvictionAllocations();
ResidencyContainer &getEvictionAllocations() {
return evictionAllocations;
}
DeferredDeleter *getDeferredDeleter() const {
return deferredDeleter.get();
}
@@ -274,8 +263,6 @@ class MemoryManager {
bool virtualPaddingAvailable = false;
GraphicsAllocation *paddingAllocation = nullptr;
void applyCommonCleanup();
ResidencyContainer residencyAllocations;
ResidencyContainer evictionAllocations;
std::unique_ptr<DeferredDeleter> deferredDeleter;
bool asyncDeleterEnabled = false;
bool enable64kbpages = false;

View File

@@ -56,6 +56,44 @@ struct CommandStreamReceiverTest : public DeviceFixture,
CommandStreamReceiver *commandStreamReceiver;
};
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForResidencyThanAllocationsCountIsIncreated) {
ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
GraphicsAllocation allocation(nullptr, 0);
commandStreamReceiver->pushAllocationForResidency(&allocation);
EXPECT_EQ(1u, commandStreamReceiver->getResidencyAllocations().size());
}
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForResidencyThenAllAllocationsAreRemoved) {
GraphicsAllocation allocation1(nullptr, 0);
GraphicsAllocation allocation2(nullptr, 0);
commandStreamReceiver->pushAllocationForResidency(&allocation1);
commandStreamReceiver->pushAllocationForResidency(&allocation2);
ASSERT_EQ(2u, commandStreamReceiver->getResidencyAllocations().size());
commandStreamReceiver->clearResidencyAllocations();
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
}
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenPushingAllocationForEvictionThanAllocationsCountIsIncreated) {
ASSERT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
GraphicsAllocation allocation(nullptr, 0);
commandStreamReceiver->pushAllocationForEviction(&allocation);
EXPECT_EQ(1u, commandStreamReceiver->getEvictionAllocations().size());
}
TEST_F(CommandStreamReceiverTest, givenValidCsrWhenClearingAllocationsForEvictionThenAllAllocationsAreRemoved) {
GraphicsAllocation allocation1(nullptr, 0);
GraphicsAllocation allocation2(nullptr, 0);
commandStreamReceiver->pushAllocationForEviction(&allocation1);
commandStreamReceiver->pushAllocationForEviction(&allocation2);
ASSERT_EQ(2u, commandStreamReceiver->getEvictionAllocations().size());
commandStreamReceiver->clearEvictionAllocations();
EXPECT_EQ(0u, commandStreamReceiver->getEvictionAllocations().size());
}
HWTEST_F(CommandStreamReceiverTest, testCtor) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(0u, csr.peekTaskLevel());

View File

@@ -1072,56 +1072,6 @@ TEST(OsAgnosticMemoryManager, pleaseDetectLeak) {
MemoryManagement::fastLeaksDetectionMode = MemoryManagement::LeakDetectionMode::EXPECT_TO_LEAK;
}
TEST(OsAgnosticMemoryManager, pushAllocationForResidency) {
OsAgnosticMemoryManager memoryManager;
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
EXPECT_EQ(0u, memoryManager.getResidencyAllocations().size());
memoryManager.pushAllocationForResidency(graphicsAllocation);
EXPECT_EQ(1u, memoryManager.getResidencyAllocations().size());
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
TEST(OsAgnosticMemoryManager, clearResidencyAllocations) {
OsAgnosticMemoryManager memoryManager;
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
memoryManager.pushAllocationForResidency(graphicsAllocation);
EXPECT_EQ(1u, memoryManager.getResidencyAllocations().size());
memoryManager.clearResidencyAllocations();
EXPECT_EQ(0u, memoryManager.getResidencyAllocations().size());
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
TEST(OsAgnosticMemoryManager, pushAllocationForEviction) {
OsAgnosticMemoryManager memoryManager;
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
EXPECT_EQ(0u, memoryManager.getEvictionAllocations().size());
memoryManager.pushAllocationForEviction(graphicsAllocation);
EXPECT_EQ(1u, memoryManager.getEvictionAllocations().size());
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
TEST(OsAgnosticMemoryManager, clearEvictionAllocations) {
OsAgnosticMemoryManager memoryManager;
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
memoryManager.pushAllocationForEviction(graphicsAllocation);
EXPECT_EQ(1u, memoryManager.getEvictionAllocations().size());
memoryManager.clearEvictionAllocations();
EXPECT_EQ(0u, memoryManager.getEvictionAllocations().size());
memoryManager.freeGraphicsMemory(graphicsAllocation);
}
TEST(OsAgnosticMemoryManager, alignmentIsCorrect) {
OsAgnosticMemoryManager memoryManager;
const size_t alignment = 0;