fix: assign CSR once for staging image write

Related-To: NEO-13330

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2024-11-28 09:53:52 +00:00
committed by Compute-Runtime-Automation
parent 92ebbe75c0
commit 53da277bc1
5 changed files with 62 additions and 26 deletions

View File

@@ -1606,7 +1606,7 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC
size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, cl_event *event) { size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, cl_event *event) {
constexpr cl_command_type cmdType = CL_COMMAND_WRITE_IMAGE; constexpr cl_command_type cmdType = CL_COMMAND_WRITE_IMAGE;
CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, this->getDevice().getRootDeviceIndex(), globalRegion, nullptr, globalOrigin}; CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, this->getDevice().getRootDeviceIndex(), globalRegion, nullptr, globalOrigin};
auto csr = &selectCsrForBuiltinOperation(csrSelectionArgs); auto &csr = selectCsrForBuiltinOperation(csrSelectionArgs);
Event profilingEvent{this, CL_COMMAND_WRITE_IMAGE, CompletionStamp::notReady, CompletionStamp::notReady}; Event profilingEvent{this, CL_COMMAND_WRITE_IMAGE, CompletionStamp::notReady, CompletionStamp::notReady};
if (isProfilingEnabled()) { if (isProfilingEnabled()) {
@@ -1625,7 +1625,7 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC
} }
memcpy(stagingBuffer, chunkPtr, bufferSize); memcpy(stagingBuffer, chunkPtr, bufferSize);
if (isSingleTransfer) { if (isSingleTransfer) {
return this->enqueueWriteImage(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, event); return this->enqueueWriteImageImpl(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, event, csr);
} }
if (isFirstTransfer && isProfilingEnabled()) { if (isFirstTransfer && isProfilingEnabled()) {
@@ -1636,13 +1636,13 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC
if (isLastTransfer && !this->isOOQEnabled()) { if (isLastTransfer && !this->isOOQEnabled()) {
outEvent = event; outEvent = event;
} }
auto ret = this->enqueueWriteImage(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, outEvent); auto ret = this->enqueueWriteImageImpl(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, outEvent, csr);
return ret; return ret;
}; };
auto bytesPerPixel = dstImage->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes; auto bytesPerPixel = dstImage->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
auto dstRowPitch = inputRowPitch ? inputRowPitch : globalRegion[0] * bytesPerPixel; auto dstRowPitch = inputRowPitch ? inputRowPitch : globalRegion[0] * bytesPerPixel;
auto stagingBufferManager = this->context->getStagingBufferManager(); auto stagingBufferManager = this->context->getStagingBufferManager();
auto ret = stagingBufferManager->performImageWrite(ptr, globalOrigin, globalRegion, dstRowPitch, chunkWrite, csr); auto ret = stagingBufferManager->performImageWrite(ptr, globalOrigin, globalRegion, dstRowPitch, chunkWrite, &csr);
if (ret != CL_SUCCESS) { if (ret != CL_SUCCESS) {
return ret; return ret;
} }

View File

@@ -156,6 +156,11 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, cl_event *event) = 0; const cl_event *eventWaitList, cl_event *event) = 0;
virtual cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin,
const size_t *region, size_t inputRowPitch, size_t inputSlicePitch,
const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, cl_event *event, CommandStreamReceiver &csr) = 0;
virtual cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, virtual cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin,
const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch, const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;

View File

@@ -305,6 +305,11 @@ class CommandQueueHw : public CommandQueue {
const cl_event *eventWaitList, const cl_event *eventWaitList,
cl_event *event) override; cl_event *event) override;
cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin,
const size_t *region, size_t inputRowPitch, size_t inputSlicePitch,
const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, cl_event *event, CommandStreamReceiver &csr) override;
cl_int enqueueCopyBufferToImage(Buffer *srcBuffer, cl_int enqueueCopyBufferToImage(Buffer *srcBuffer,
Image *dstImage, Image *dstImage,
size_t srcOffset, size_t srcOffset,

View File

@@ -39,6 +39,25 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, device->getRootDeviceIndex(), region, nullptr, origin}; CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, device->getRootDeviceIndex(), region, nullptr, origin};
CommandStreamReceiver &csr = selectCsrForBuiltinOperation(csrSelectionArgs); CommandStreamReceiver &csr = selectCsrForBuiltinOperation(csrSelectionArgs);
return enqueueWriteImageImpl(dstImage, blockingWrite, origin, region, inputRowPitch, inputSlicePitch, ptr, mapAllocation, numEventsInWaitList, eventWaitList, event, csr);
}
template <typename GfxFamily>
cl_int CommandQueueHw<GfxFamily>::enqueueWriteImageImpl(
Image *dstImage,
cl_bool blockingWrite,
const size_t *origin,
const size_t *region,
size_t inputRowPitch,
size_t inputSlicePitch,
const void *ptr,
GraphicsAllocation *mapAllocation,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event,
CommandStreamReceiver &csr) {
constexpr cl_command_type cmdType = CL_COMMAND_WRITE_IMAGE;
CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, device->getRootDeviceIndex(), region, nullptr, origin};
auto isMemTransferNeeded = true; auto isMemTransferNeeded = true;

View File

@@ -193,6 +193,11 @@ class MockCommandQueue : public CommandQueue {
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_uint numEventsInWaitList, const cl_event *eventWaitList,
cl_event *event) override { return CL_SUCCESS; } cl_event *event) override { return CL_SUCCESS; }
cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin, const size_t *region,
size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, GraphicsAllocation *mapAllocation,
cl_uint numEventsInWaitList, const cl_event *eventWaitList,
cl_event *event, CommandStreamReceiver &csr) override { return CL_SUCCESS; }
cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin,
const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch,
size_t dstSlicePitch, cl_uint numEventsInWaitList, size_t dstSlicePitch, cl_uint numEventsInWaitList,
@@ -345,30 +350,32 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
return reinterpret_cast<UltCommandStreamReceiver<GfxFamily> &>(BaseClass::getGpgpuCommandStreamReceiver()); return reinterpret_cast<UltCommandStreamReceiver<GfxFamily> &>(BaseClass::getGpgpuCommandStreamReceiver());
} }
cl_int enqueueWriteImage(Image *dstImage, cl_int enqueueWriteImageImpl(Image *dstImage,
cl_bool blockingWrite, cl_bool blockingWrite,
const size_t *origin, const size_t *origin,
const size_t *region, const size_t *region,
size_t inputRowPitch, size_t inputRowPitch,
size_t inputSlicePitch, size_t inputSlicePitch,
const void *ptr, const void *ptr,
GraphicsAllocation *mapAllocation, GraphicsAllocation *mapAllocation,
cl_uint numEventsInWaitList, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, const cl_event *eventWaitList,
cl_event *event) override { cl_event *event,
CommandStreamReceiver &csr) override {
enqueueWriteImageCounter++; enqueueWriteImageCounter++;
if (enqueueWriteImageCallBase) { if (enqueueWriteImageCallBase) {
return BaseClass::enqueueWriteImage(dstImage, return BaseClass::enqueueWriteImageImpl(dstImage,
blockingWrite, blockingWrite,
origin, origin,
region, region,
inputRowPitch, inputRowPitch,
inputSlicePitch, inputSlicePitch,
ptr, ptr,
mapAllocation, mapAllocation,
numEventsInWaitList, numEventsInWaitList,
eventWaitList, eventWaitList,
event); event,
csr);
} }
return CL_INVALID_OPERATION; return CL_INVALID_OPERATION;
} }