performance: enable staging read for images

Related-To: NEO-12968

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2024-12-20 13:15:56 +00:00
committed by Compute-Runtime-Automation
parent 363f2becd4
commit 6aeb8dffa0
2 changed files with 46 additions and 14 deletions

View File

@@ -2892,19 +2892,22 @@ cl_int CL_API_CALL clEnqueueReadImage(cl_command_queue commandQueue,
TRACING_EXIT(ClEnqueueReadImage, &retVal);
return retVal;
}
retVal = pCommandQueue->enqueueReadImage(
pImage,
blockingRead,
origin,
region,
rowPitch,
slicePitch,
ptr,
nullptr,
numEventsInWaitList,
eventWaitList,
event);
if (pCommandQueue->isValidForStagingTransferImage(pImage, ptr, numEventsInWaitList > 0)) {
retVal = pCommandQueue->enqueueStagingReadImage(pImage, blockingRead, origin, region, rowPitch, slicePitch, ptr, event);
} else {
retVal = pCommandQueue->enqueueReadImage(
pImage,
blockingRead,
origin,
region,
rowPitch,
slicePitch,
ptr,
nullptr,
numEventsInWaitList,
eventWaitList,
event);
}
}
DBG_LOG_INPUTS("event", getClFileLogger().getEvents(reinterpret_cast<const uintptr_t *>(event), 1u));
TRACING_EXIT(ClEnqueueReadImage, &retVal);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -205,4 +205,33 @@ TEST_F(ClEnqueueReadImageYuv, GivenInvalidRegionWhenReadingYuvImageThenInvalidVa
retVal = clReleaseMemObject(image);
EXPECT_EQ(CL_SUCCESS, retVal);
}
TEST_F(ClEnqueueReadImageTests, givenStagingEnabledWhenEnqueueReadImageCalledThenReadSuccesfullAndStagingBufferAllocated) {
DebugManagerStateRestore restorer;
debugManager.flags.EnableCopyWithStagingBuffers.set(1);
imageFormat.image_channel_order = CL_RGBA;
auto image = Image::validateAndCreateImage(pContext, nullptr, CL_MEM_READ_WRITE, 0, &imageFormat, &imageDesc, nullptr, retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, image);
const size_t origin[] = {2, 2, 0};
const size_t region[] = {2, 2, 1};
char nonUsmPtr[1024];
auto retVal = clEnqueueReadImage(
pCommandQueue,
image,
false,
origin,
region,
0,
0,
nonUsmPtr,
0,
nullptr,
nullptr);
auto unifiedMemoryManager = pContext->getSVMAllocsManager();
EXPECT_EQ(1u, unifiedMemoryManager->getNumAllocs());
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clReleaseMemObject(image);
EXPECT_EQ(CL_SUCCESS, retVal);
}
} // namespace ULT