mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
OsAgnosticMemoryManager to call freeMemory on AubManager for hostPtr
Related-To: NEO-3231 Change-Id: I83d5c9036d7f5531c1e7290058b8e2635e42ec18 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
576005f7bb
commit
92a29a3e86
@@ -185,6 +185,11 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo
|
||||
return;
|
||||
}
|
||||
|
||||
auto aubCenter = executionEnvironment.aubCenter.get();
|
||||
if (aubCenter && aubCenter->getAubManager()) {
|
||||
aubCenter->getAubManager()->freeMemory(gfxAllocation->getGpuAddress(), gfxAllocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
if (gfxAllocation->fragmentsStorage.fragmentCount) {
|
||||
cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation);
|
||||
delete gfxAllocation;
|
||||
@@ -201,11 +206,6 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo
|
||||
releaseReservedCpuAddressRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize());
|
||||
}
|
||||
|
||||
auto aubCenter = executionEnvironment.aubCenter.get();
|
||||
if (aubCenter && aubCenter->getAubManager()) {
|
||||
aubCenter->getAubManager()->freeMemory(gfxAllocation->getGpuAddress(), gfxAllocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
delete gfxAllocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,10 @@ HWTEST_P(AUBCopyImage, simple) {
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth};
|
||||
|
||||
pCmdQ->enqueueReadImage(dstImage, CL_TRUE, imgOrigin, imgRegion, 0, 0, dstOutMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(dstImage, CL_FALSE, imgOrigin, imgRegion, 0, 0, dstOutMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// Offset the source memory
|
||||
|
||||
@@ -207,7 +207,10 @@ HWTEST_P(AubFillImage, simple) {
|
||||
size_t imgRegion[] = {testWidth, testHeight, testDepth};
|
||||
|
||||
auto dstMemory = new uint8_t[sizeMemory];
|
||||
pCmdQ->enqueueReadImage(image, CL_TRUE, imgOrigin, imgRegion, 0, 0, dstMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(image, CL_FALSE, imgOrigin, imgRegion, 0, 0, dstMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
size_t slicePitch = image->getHostPtrSlicePitch();
|
||||
|
||||
@@ -68,7 +68,10 @@ HWTEST_F(AUBMapBuffer, MapUpdateUnmapVerify) {
|
||||
std::unique_ptr<uint8_t[]> readMemory(new uint8_t[bufferSize]);
|
||||
buffer->forceDisallowCPUCopy = true;
|
||||
|
||||
retVal = pCmdQ->enqueueReadBuffer(buffer.get(), CL_TRUE, 0, bufferSize, readMemory.get(), nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, bufferSize, readMemory.get(), nullptr, 0, nullptr, nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
for (size_t i = 0; i < bufferSize; i++) {
|
||||
|
||||
@@ -182,7 +182,10 @@ HWTEST_P(AUBMapImage, MapUpdateUnmapVerify) {
|
||||
uint8_t *readMemory = new uint8_t[srcImage->getSize()];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {testWidth, testHeight, testDepth};
|
||||
retVal = pCmdQ->enqueueReadImage(srcImage, CL_TRUE, imgOrigin, imgRegion, inputRowPitch, inputSlicePitch, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(srcImage, CL_FALSE, imgOrigin, imgRegion, inputRowPitch, inputSlicePitch, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
srcMemoryStart = srcMemory;
|
||||
|
||||
@@ -136,7 +136,7 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
|
||||
|
||||
srcBuffer->forceDisallowCPUCopy = true;
|
||||
auto retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(),
|
||||
CL_TRUE,
|
||||
CL_FALSE,
|
||||
0,
|
||||
sizeof(dstMemory),
|
||||
dstMemory,
|
||||
@@ -146,6 +146,9 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
GraphicsAllocation *dstAllocation = createResidentAllocationAndStoreItInCsr(dstMemory, sizeof(dstMemory));
|
||||
cl_float *dstGpuAddress = reinterpret_cast<cl_float *>(dstAllocation->getGpuAddress());
|
||||
|
||||
@@ -191,7 +194,7 @@ struct AUBReadBufferUnaligned
|
||||
// Do unaligned read
|
||||
retVal = pCmdQ->enqueueReadBuffer(
|
||||
buffer.get(),
|
||||
CL_TRUE,
|
||||
CL_FALSE,
|
||||
offset,
|
||||
size,
|
||||
ptrOffset(dstMemory, offset),
|
||||
@@ -201,6 +204,9 @@ struct AUBReadBufferUnaligned
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// Check the memory
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(ptrOffset(dstMemoryGPUPtr, offset), ptrOffset(srcMemory, offset), size);
|
||||
}
|
||||
|
||||
@@ -57,15 +57,15 @@ HWTEST_P(AUBReadBufferRect, simple3D) {
|
||||
memset(destMemory, 0x00, bufferSize);
|
||||
|
||||
auto retVal = CL_INVALID_VALUE;
|
||||
auto srcBuffer = Buffer::create(
|
||||
auto srcBuffer = std::unique_ptr<Buffer>(Buffer::create(
|
||||
&context,
|
||||
CL_MEM_USE_HOST_PTR,
|
||||
bufferSize,
|
||||
srcMemory,
|
||||
retVal);
|
||||
retVal));
|
||||
ASSERT_NE(nullptr, srcBuffer);
|
||||
|
||||
cl_bool blockingRead = CL_TRUE;
|
||||
cl_bool blockingRead = CL_FALSE;
|
||||
|
||||
createResidentAllocationAndStoreItInCsr(destMemory, bufferSize);
|
||||
|
||||
@@ -74,7 +74,7 @@ HWTEST_P(AUBReadBufferRect, simple3D) {
|
||||
size_t region[] = {rowPitch, rowPitch, 1};
|
||||
|
||||
retVal = pCmdQ->enqueueReadBufferRect(
|
||||
srcBuffer,
|
||||
srcBuffer.get(),
|
||||
blockingRead,
|
||||
bufferOrigin,
|
||||
hostOrigin,
|
||||
@@ -87,9 +87,9 @@ HWTEST_P(AUBReadBufferRect, simple3D) {
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
delete srcBuffer;
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
char *ptr = new char[slicePitch];
|
||||
@@ -151,7 +151,7 @@ struct AUBReadBufferRectUnaligned
|
||||
GraphicsAllocation *allocation = createResidentAllocationAndStoreItInCsr(dstMemory, bufferSize);
|
||||
auto dstMemoryGPUPtr = reinterpret_cast<char *>(allocation->getGpuAddress());
|
||||
|
||||
cl_bool blockingRead = CL_TRUE;
|
||||
cl_bool blockingRead = CL_FALSE;
|
||||
|
||||
size_t rowPitch = bufferSize / 4;
|
||||
size_t slicePitch = 4 * rowPitch;
|
||||
@@ -173,7 +173,9 @@ struct AUBReadBufferRectUnaligned
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(dstMemoryGPUPtr, referenceMemory, offset);
|
||||
|
||||
@@ -158,7 +158,7 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
|
||||
|
||||
retVal = pCmdQ->enqueueReadImage(
|
||||
srcImage,
|
||||
CL_TRUE,
|
||||
CL_FALSE,
|
||||
origin,
|
||||
region,
|
||||
inputRowPitch,
|
||||
@@ -170,6 +170,9 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto imageMemory = srcMemory;
|
||||
|
||||
if (!srcImage->isMemObjZeroCopy() && !srcImage->allowTiling()) {
|
||||
@@ -208,6 +211,9 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
|
||||
ptrOffset(dstMemoryUnaligned, testWidth * testHeight * elementSize);
|
||||
}
|
||||
|
||||
retVal = pCmdQ->finish(true); //FixMe - not all test cases verified with expects
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
alignedFree(dstMemoryAligned);
|
||||
delete[] srcMemory;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,6 @@ struct AUBImageUnaligned
|
||||
imageDesc.num_samples = 0;
|
||||
imageDesc.mem_object = NULL;
|
||||
|
||||
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(dstMemory, bufferSize);
|
||||
auto dstMemoryGPUPtr = reinterpret_cast<char *>(graphicsAllocation->getGpuAddress());
|
||||
|
||||
cl_mem_flags flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);
|
||||
auto retVal = CL_INVALID_VALUE;
|
||||
@@ -89,6 +86,9 @@ struct AUBImageUnaligned
|
||||
ASSERT_NE(nullptr, image);
|
||||
EXPECT_FALSE(image->isMemObjZeroCopy());
|
||||
|
||||
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(dstMemory, bufferSize);
|
||||
auto dstMemoryGPUPtr = reinterpret_cast<char *>(graphicsAllocation->getGpuAddress());
|
||||
|
||||
const size_t origin[3] = {0, 1, 0};
|
||||
const size_t region[3] = {size, 1, 1};
|
||||
|
||||
@@ -97,7 +97,7 @@ struct AUBImageUnaligned
|
||||
|
||||
retVal = pCmdQ->enqueueReadImage(
|
||||
image.get(),
|
||||
CL_TRUE,
|
||||
CL_FALSE,
|
||||
origin,
|
||||
region,
|
||||
inputRowPitch,
|
||||
@@ -109,7 +109,8 @@ struct AUBImageUnaligned
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
pCmdQ->finish(true);
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(dstMemoryGPUPtr, referenceMemory, offset);
|
||||
AUBCommandStreamFixture::expectMemory<FamilyType>(ptrOffset(dstMemoryGPUPtr, offset), &imageMemory[inputRowPitch * origin[1] * pixelSize], size * pixelSize);
|
||||
|
||||
@@ -169,7 +169,11 @@ HWTEST_P(AUBWriteImage, simpleUnalignedMemory) {
|
||||
auto readMemory = new uint8_t[dstImage->getSize()];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {testWidth, testHeight, testDepth};
|
||||
pCmdQ->enqueueReadImage(dstImage, CL_TRUE, imgOrigin, imgRegion, 0, 0, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(dstImage, CL_FALSE, imgOrigin, imgRegion, 0, 0, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto pDstMemory = readMemory;
|
||||
auto pSrc = pSrcMemory;
|
||||
|
||||
@@ -242,7 +242,9 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithDoubledRowPitchThatIsCreatedWithCopyHos
|
||||
readMemory = new uint8_t[testImageDimensions * testImageDimensions * elementSize * 4];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth ? imageDesc.image_depth : 1};
|
||||
retVal = pCmdQ->enqueueReadImage(image, CL_TRUE, imgOrigin, imgRegion, 0, 0, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(image, CL_FALSE, imgOrigin, imgRegion, 0, 0, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
imageStorage = readMemory;
|
||||
}
|
||||
@@ -312,7 +314,7 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithRowPitchCreatedWithUseHostPtrFlagCopied
|
||||
size_t imageSlicePitch = 0;
|
||||
auto ptr = pCmdQ->enqueueMapImage(
|
||||
image,
|
||||
true,
|
||||
false,
|
||||
mapFlags,
|
||||
origin,
|
||||
region,
|
||||
@@ -327,6 +329,7 @@ HWTEST_P(AUBCreateImageHostPtr, imageWithRowPitchCreatedWithUseHostPtrFlagCopied
|
||||
} else {
|
||||
EXPECT_NE(image->getCpuAddress(), ptr);
|
||||
}
|
||||
pCmdQ->flush();
|
||||
size_t imageRowPitchRef = 0;
|
||||
image->getImageInfo(CL_IMAGE_ROW_PITCH, sizeof(imageRowPitchRef), &imageRowPitchRef, nullptr);
|
||||
|
||||
@@ -403,7 +406,9 @@ HWTEST_F(AUBCreateImage, image3DCreatedWithDoubledSlicePitchWhenQueriedForDataRe
|
||||
readMemory = new uint8_t[imageSize];
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth};
|
||||
retVal = pCmdQ->enqueueReadImage(image, CL_TRUE, imgOrigin, imgRegion, 0, computedSlicePitch, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
retVal = pCmdQ->enqueueReadImage(image, CL_FALSE, imgOrigin, imgRegion, 0, computedSlicePitch, readMemory, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = pCmdQ->flush();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
imageStorage = readMemory;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user