mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-20 13:11:34 +08:00
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:
@ -331,6 +331,10 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
|
||||
subCaptureManager->disableSubCapture();
|
||||
}
|
||||
|
||||
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
|
||||
pollForCompletion();
|
||||
}
|
||||
|
||||
getAubStream()->flush();
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user