mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Enqueue Read/Write operations with blitter
- Program dependencies from Event and IOQ - Obtain new TimestampPacket - Update output TimestampPacket if needed Change-Id: I4ad020f5c5b05ceca8b096fafe1257523e2bc343 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com> Related-To: NEO-3020
This commit is contained in:
committed by
sys_ocldev
parent
aae31c3c1b
commit
3e88907201
@@ -587,12 +587,20 @@ bool CommandQueue::bufferCpuCopyAllowed(Buffer *buffer, cl_command_type commandT
|
||||
cl_int CommandQueue::enqueueReadWriteBufferWithBlitTransfer(cl_command_type commandType, Buffer *buffer,
|
||||
size_t offset, size_t size, void *ptr, cl_uint numEventsInWaitList,
|
||||
const cl_event *eventWaitList, cl_event *event) {
|
||||
CsrDependencies csrDependencies;
|
||||
auto blitCommandStreamReceiver = context->getCommandStreamReceiverForBlitOperation(*buffer);
|
||||
EventsRequest eventsRequest(numEventsInWaitList, eventWaitList, event);
|
||||
TimestampPacketContainer previousTimestampPacketNodes;
|
||||
CsrDependencies csrDependencies;
|
||||
|
||||
csrDependencies.fillFromEventsRequestAndMakeResident(eventsRequest, *blitCommandStreamReceiver,
|
||||
CsrDependencies::DependenciesType::All);
|
||||
|
||||
obtainNewTimestampPacketNodes(1, previousTimestampPacketNodes, queueDependenciesClearRequired());
|
||||
csrDependencies.push_back(&previousTimestampPacketNodes);
|
||||
|
||||
auto copyDirection = (CL_COMMAND_WRITE_BUFFER == commandType) ? BlitterConstants::BlitWithHostPtrDirection::FromHostPtr
|
||||
: BlitterConstants::BlitWithHostPtrDirection::ToHostPtr;
|
||||
blitCommandStreamReceiver->blitWithHostPtr(*buffer, ptr, true, offset, size, copyDirection, csrDependencies);
|
||||
blitCommandStreamReceiver->blitWithHostPtr(*buffer, ptr, true, offset, size, copyDirection, csrDependencies, *timestampPacketContainer);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -419,7 +419,8 @@ cl_int CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *s
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::blitWithHostPtr(Buffer &buffer, void *hostPtr, bool blocking, size_t bufferOffset, uint64_t copySize,
|
||||
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies) {
|
||||
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies,
|
||||
const TimestampPacketContainer &outputTimestampPacket) {
|
||||
HostPtrSurface hostPtrSurface(hostPtr, static_cast<size_t>(copySize), true);
|
||||
bool success = createAllocationForHostSurface(hostPtrSurface, false);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
@@ -431,9 +432,9 @@ void CommandStreamReceiver::blitWithHostPtr(Buffer &buffer, void *hostPtr, bool
|
||||
true, false, true));
|
||||
|
||||
if (BlitterConstants::BlitWithHostPtrDirection::FromHostPtr == copyDirection) {
|
||||
blitBuffer(buffer, *hostPtrBuffer, blocking, bufferOffset, 0, copySize, csrDependencies);
|
||||
blitBuffer(buffer, *hostPtrBuffer, blocking, bufferOffset, 0, copySize, csrDependencies, outputTimestampPacket);
|
||||
} else {
|
||||
blitBuffer(*hostPtrBuffer, buffer, blocking, 0, bufferOffset, copySize, csrDependencies);
|
||||
blitBuffer(*hostPtrBuffer, buffer, blocking, 0, bufferOffset, copySize, csrDependencies, outputTimestampPacket);
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -177,9 +177,10 @@ class CommandStreamReceiver {
|
||||
}
|
||||
|
||||
void blitWithHostPtr(Buffer &buffer, void *hostPtr, bool blocking, size_t bufferOffset, uint64_t copySize,
|
||||
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies);
|
||||
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies,
|
||||
const TimestampPacketContainer &outputTimestampPacket);
|
||||
virtual void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
|
||||
uint64_t copySize, CsrDependencies &csrDependencies) = 0;
|
||||
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) = 0;
|
||||
|
||||
ScratchSpaceController *getScratchSpaceController() const {
|
||||
return scratchSpaceController.get();
|
||||
|
||||
@@ -71,7 +71,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
|
||||
}
|
||||
|
||||
void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
|
||||
uint64_t copySize, CsrDependencies &csrDependencies) override;
|
||||
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) override;
|
||||
|
||||
protected:
|
||||
using CommandStreamReceiver::osContext;
|
||||
|
||||
@@ -726,14 +726,15 @@ bool CommandStreamReceiverHw<GfxFamily>::detectInitProgrammingFlagsRequired(cons
|
||||
|
||||
template <typename GfxFamily>
|
||||
void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
|
||||
uint64_t copySize, CsrDependencies &csrDependencies) {
|
||||
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) {
|
||||
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
|
||||
using MI_FLUSH_DW = typename GfxFamily::MI_FLUSH_DW;
|
||||
|
||||
UNRECOVERABLE_IF(osContext->getEngineType() != aub_stream::EngineType::ENGINE_BCS);
|
||||
|
||||
auto lock = obtainUniqueOwnership();
|
||||
auto &commandStream = getCS(BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(copySize, csrDependencies));
|
||||
bool updateTimestampPacket = outputTimestampPacket.peekNodes().size() > 0;
|
||||
auto &commandStream = getCS(BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(copySize, csrDependencies, updateTimestampPacket));
|
||||
auto commandStreamStart = commandStream.getUsed();
|
||||
auto newTaskCount = taskCount + 1;
|
||||
latestSentTaskCount = newTaskCount;
|
||||
@@ -744,6 +745,12 @@ void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &s
|
||||
|
||||
HardwareCommandsHelper<GfxFamily>::programMiFlushDw(commandStream, tagAllocation->getGpuAddress(), newTaskCount);
|
||||
|
||||
if (updateTimestampPacket) {
|
||||
UNRECOVERABLE_IF(outputTimestampPacket.peekNodes().size() != 1);
|
||||
auto timestampPacketGpuAddress = outputTimestampPacket.peekNodes().at(0)->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].contextEnd);
|
||||
HardwareCommandsHelper<GfxFamily>::programMiFlushDw(commandStream, timestampPacketGpuAddress, 0);
|
||||
}
|
||||
|
||||
auto batchBufferEnd = reinterpret_cast<MI_BATCH_BUFFER_END *>(commandStream.getSpace(sizeof(MI_BATCH_BUFFER_END)));
|
||||
*batchBufferEnd = GfxFamily::cmdInitBatchBufferEnd;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class LinearStream;
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct BlitCommandsHelper {
|
||||
static size_t estimateBlitCommandsSize(uint64_t copySize, CsrDependencies &csrDependencies);
|
||||
static size_t estimateBlitCommandsSize(uint64_t copySize, CsrDependencies &csrDependencies, bool updateTimestampPacket);
|
||||
static void dispatchBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, LinearStream &linearStream,
|
||||
uint64_t dstOffset, uint64_t srcOffset, uint64_t copySize);
|
||||
static void appendBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, typename GfxFamily::XY_COPY_BLT &blitCmd);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(uint64_t copySize, CsrDependencies &csrDependencies) {
|
||||
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(uint64_t copySize, CsrDependencies &csrDependencies, bool updateTimestampPacket) {
|
||||
size_t numberOfBlits = 0;
|
||||
uint64_t sizeToBlit = copySize;
|
||||
uint64_t width = 1;
|
||||
@@ -33,6 +33,7 @@ size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(uint64_t copySize
|
||||
size_t size = TimestampPacketHelper::getRequiredCmdStreamSize<GfxFamily>(csrDependencies) +
|
||||
(sizeof(typename GfxFamily::XY_COPY_BLT) * numberOfBlits) +
|
||||
sizeof(typename GfxFamily::MI_FLUSH_DW) +
|
||||
(sizeof(typename GfxFamily::MI_FLUSH_DW) * static_cast<size_t>(updateTimestampPacket)) +
|
||||
sizeof(typename GfxFamily::MI_BATCH_BUFFER_END);
|
||||
|
||||
return alignUp(size, MemoryConstants::cacheLineSize);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/string.h"
|
||||
#include "runtime/helpers/timestamp_packet.h"
|
||||
#include "runtime/helpers/validators.h"
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
#include "runtime/memory_manager/host_ptr_manager.h"
|
||||
@@ -286,8 +287,9 @@ Buffer *Buffer::create(Context *context,
|
||||
auto blitCommandStreamReceiver = context->getCommandStreamReceiverForBlitOperation(*pBuffer);
|
||||
if (blitCommandStreamReceiver) {
|
||||
CsrDependencies dependencies;
|
||||
TimestampPacketContainer timestampPacketContainer;
|
||||
blitCommandStreamReceiver->blitWithHostPtr(*pBuffer, hostPtr, true, 0, size, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
|
||||
dependencies);
|
||||
dependencies, timestampPacketContainer);
|
||||
} else {
|
||||
auto cmdQ = context->getSpecialQueue();
|
||||
if (CL_SUCCESS != cmdQ->enqueueWriteBuffer(pBuffer, CL_TRUE, 0, size, hostPtr, nullptr, 0, nullptr, nullptr)) {
|
||||
|
||||
Reference in New Issue
Block a user