OsAgnosticMemoryManager to call freeMemory on AubManager

Resolves: NEO-3231

Change-Id: I89a3cc9f2a63931c6c87ec70bbedc19716a885c1
Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2019-05-29 16:20:50 +02:00
parent 7cc855cc72
commit 17f9cc006d
6 changed files with 33 additions and 8 deletions

View File

@ -331,6 +331,10 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
subCaptureManager->disableSubCapture();
}
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
pollForCompletion();
}
getAubStream()->flush();
return 0;
}

View File

@ -9,6 +9,7 @@
#include "core/helpers/basic_math.h"
#include "core/helpers/ptr_math.h"
#include "runtime/aub/aub_center.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
@ -199,6 +200,12 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo
if (gfxAllocation->getReservedAddressPtr()) {
releaseReservedCpuAddressRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize());
}
auto aubCenter = executionEnvironment.aubCenter.get();
if (aubCenter && aubCenter->getAubManager()) {
aubCenter->getAubManager()->freeMemory(gfxAllocation->getGpuAddress(), gfxAllocation->getUnderlyingBufferSize());
}
delete gfxAllocation;
}

View File

@ -58,12 +58,12 @@ HWTEST_P(AUBWriteBufferRect, simple3D) {
memset(destMemory, 0x00, bufferSize);
auto retVal = CL_INVALID_VALUE;
auto dstBuffer = Buffer::create(
auto dstBuffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
CL_MEM_USE_HOST_PTR,
bufferSize,
destMemory,
retVal);
retVal));
ASSERT_NE(nullptr, dstBuffer);
uint8_t *pDestMemory = (uint8_t *)dstBuffer->getGraphicsAllocation()->getGpuAddress();
@ -75,7 +75,7 @@ HWTEST_P(AUBWriteBufferRect, simple3D) {
size_t region[] = {rowPitch, rowPitch, 1};
retVal = pCmdQ->enqueueWriteBufferRect(
dstBuffer,
dstBuffer.get(),
blockingWrite,
bufferOrigin,
hostOrigin,
@ -89,8 +89,6 @@ HWTEST_P(AUBWriteBufferRect, simple3D) {
nullptr,
nullptr);
delete dstBuffer;
EXPECT_EQ(CL_SUCCESS, retVal);
char *ptr = new char[slicePitch];

View File

@ -584,8 +584,7 @@ TEST_F(RenderCompressedBuffersSvmTests, givenSvmAllocationWhenCreatingBufferThen
struct RenderCompressedBuffersCopyHostMemoryTests : public RenderCompressedBuffersTests {
void SetUp() override {
RenderCompressedBuffersTests::SetUp();
MockExecutionEnvironment executionEnvironment(*platformDevices);
device->injectMemoryManager(new MockMemoryManager(true, false, executionEnvironment));
device->injectMemoryManager(new MockMemoryManager(true, false, *platformImpl->peekExecutionEnvironment()));
context->setMemoryManager(device->getMemoryManager());
mockCmdQ = new MockCommandQueue();
context->setSpecialQueue(mockCmdQ);

View File

@ -1166,6 +1166,20 @@ TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndAubUsageWhenMemoryMana
EXPECT_EQ(heap32Base, memoryManager.getExternalHeapBaseAddress());
}
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGraphicsAllocationIsDestroyedThenFreeMemoryOnAubManagerShouldBeCalled) {
MockExecutionEnvironment executionEnvironment;
OsAgnosticMemoryManager memoryManager(executionEnvironment);
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
executionEnvironment.aubCenter.reset(mockAubCenter);
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
EXPECT_FALSE(mockManager->freeMemoryCalled);
memoryManager.freeGraphicsMemory(gfxAllocation);
EXPECT_TRUE(mockManager->freeMemoryCalled);
}
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);

View File

@ -89,7 +89,9 @@ class MockAubManager : public aub_stream::AubManager {
hintToWriteMemory = hint;
}
void freeMemory(uint64_t gfxAddress, size_t size) override {}
void freeMemory(uint64_t gfxAddress, size_t size) override {
freeMemoryCalled = true;
}
uint32_t openCalledCnt = 0;
std::string fileName = "";
@ -99,6 +101,7 @@ class MockAubManager : public aub_stream::AubManager {
bool addCommentCalled = false;
std::string receivedComment = "";
bool writeMemoryCalled = false;
bool freeMemoryCalled = false;
uint32_t contextFlags = 0;
int hintToWriteMemory = 0;