Improve TimestampPackets handling in blocked path

Change-Id: Idf381a8750cebec6196eb299661dda892e11144d
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-11-16 11:59:18 +01:00
parent 46b5513028
commit 8e945e7919
6 changed files with 25 additions and 23 deletions

View File

@@ -345,7 +345,7 @@ class CommandQueueHw : public CommandQueue {
Surface **surfacesForResidency, Surface **surfacesForResidency,
size_t surfacesCount, size_t surfacesCount,
const MultiDispatchInfo &multiDispatchInfo, const MultiDispatchInfo &multiDispatchInfo,
TimestampPacketContainer &previousTimestampPacketNodes, TimestampPacketDependencies &timestampPacketDependencies,
std::unique_ptr<KernelOperation> &blockedCommandsData, std::unique_ptr<KernelOperation> &blockedCommandsData,
const EnqueueProperties &enqueueProperties, const EnqueueProperties &enqueueProperties,
EventsRequest &eventsRequest, EventsRequest &eventsRequest,

View File

@@ -354,7 +354,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
surfacesForResidency, surfacesForResidency,
numSurfaceForResidency, numSurfaceForResidency,
multiDispatchInfo, multiDispatchInfo,
timestampPacketDependencies.previousEnqueueNodes, timestampPacketDependencies,
blockedCommandsData, blockedCommandsData,
enqueueProperties, enqueueProperties,
eventsRequest, eventsRequest,
@@ -796,7 +796,7 @@ void CommandQueueHw<GfxFamily>::enqueueBlocked(
Surface **surfaces, Surface **surfaces,
size_t surfaceCount, size_t surfaceCount,
const MultiDispatchInfo &multiDispatchInfo, const MultiDispatchInfo &multiDispatchInfo,
TimestampPacketContainer &previousTimestampPacketNodes, TimestampPacketDependencies &timestampPacketDependencies,
std::unique_ptr<KernelOperation> &blockedCommandsData, std::unique_ptr<KernelOperation> &blockedCommandsData,
const EnqueueProperties &enqueueProperties, const EnqueueProperties &enqueueProperties,
EventsRequest &eventsRequest, EventsRequest &eventsRequest,
@@ -875,7 +875,7 @@ void CommandQueueHw<GfxFamily>::enqueueBlocked(
auto event = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]); auto event = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]);
event->incRefInternal(); event->incRefInternal();
} }
command->setTimestampPacketNode(*timestampPacketContainer, std::move(previousTimestampPacketNodes)); command->setTimestampPacketNode(*timestampPacketContainer, std::move(timestampPacketDependencies));
command->setEventsRequest(eventsRequest); command->setEventsRequest(eventsRequest);
} }
outEvent->setCommand(std::move(command)); outEvent->setCommand(std::move(command));

View File

@@ -252,14 +252,14 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate
return completionStamp; return completionStamp;
} }
void CommandWithoutKernel::dispatchBlitOperation(TimestampPacketContainer &barrierTimestampPacketNodes) { void CommandWithoutKernel::dispatchBlitOperation() {
auto bcsCsr = commandQueue.getBcsCommandStreamReceiver(); auto bcsCsr = commandQueue.getBcsCommandStreamReceiver();
UNRECOVERABLE_IF(kernelOperation->blitPropertiesContainer.size() != 1); UNRECOVERABLE_IF(kernelOperation->blitPropertiesContainer.size() != 1);
auto &blitProperties = *kernelOperation->blitPropertiesContainer.begin(); auto &blitProperties = *kernelOperation->blitPropertiesContainer.begin();
blitProperties.csrDependencies.fillFromEventsRequest(eventsRequest, *bcsCsr, CsrDependencies::DependenciesType::All); blitProperties.csrDependencies.fillFromEventsRequest(eventsRequest, *bcsCsr, CsrDependencies::DependenciesType::All);
blitProperties.csrDependencies.push_back(previousTimestampPacketNodes.get()); blitProperties.csrDependencies.push_back(&timestampPacketDependencies->previousEnqueueNodes);
blitProperties.csrDependencies.push_back(&barrierTimestampPacketNodes); blitProperties.csrDependencies.push_back(&timestampPacketDependencies->barrierNodes);
blitProperties.outputTimestampPacket = currentTimestampPacketNodes->peekNodes()[0]; blitProperties.outputTimestampPacket = currentTimestampPacketNodes->peekNodes()[0];
auto bcsTaskCount = bcsCsr->blitBuffer(kernelOperation->blitPropertiesContainer, false); auto bcsTaskCount = bcsCsr->blitBuffer(kernelOperation->blitPropertiesContainer, false);
@@ -283,18 +283,17 @@ CompletionStamp &CommandWithoutKernel::submit(uint32_t taskLevel, bool terminate
} }
auto lockCSR = commandStreamReceiver.obtainUniqueOwnership(); auto lockCSR = commandStreamReceiver.obtainUniqueOwnership();
TimestampPacketContainer barrierTimestampPacketNodes;
if (kernelOperation->blitEnqueue) { if (kernelOperation->blitEnqueue) {
if (commandStreamReceiver.isStallingPipeControlOnNextFlushRequired()) { if (commandStreamReceiver.isStallingPipeControlOnNextFlushRequired()) {
barrierTimestampPacketNodes.add(commandStreamReceiver.getTimestampPacketAllocator()->getTag()); timestampPacketDependencies->barrierNodes.add(commandStreamReceiver.getTimestampPacketAllocator()->getTag());
} }
dispatchBlitOperation(barrierTimestampPacketNodes); dispatchBlitOperation();
} }
DispatchFlags dispatchFlags( DispatchFlags dispatchFlags(
{}, //csrDependencies {}, //csrDependencies
&barrierTimestampPacketNodes, //barrierTimestampPacketNodes &timestampPacketDependencies->barrierNodes, //barrierTimestampPacketNodes
{}, //pipelineSelectArgs {}, //pipelineSelectArgs
commandQueue.flushStamp->getStampReference(), //flushStampReference commandQueue.flushStamp->getStampReference(), //flushStampReference
commandQueue.getThrottle(), //throttle commandQueue.getThrottle(), //throttle
@@ -345,12 +344,12 @@ void Command::setEventsRequest(EventsRequest &eventsRequest) {
} }
} }
void Command::setTimestampPacketNode(TimestampPacketContainer &current, TimestampPacketContainer &&previous) { void Command::setTimestampPacketNode(TimestampPacketContainer &current, TimestampPacketDependencies &&dependencies) {
currentTimestampPacketNodes = std::make_unique<TimestampPacketContainer>(); currentTimestampPacketNodes = std::make_unique<TimestampPacketContainer>();
currentTimestampPacketNodes->assignAndIncrementNodesRefCounts(current); currentTimestampPacketNodes->assignAndIncrementNodesRefCounts(current);
previousTimestampPacketNodes = std::make_unique<TimestampPacketContainer>(); timestampPacketDependencies = std::make_unique<TimestampPacketDependencies>();
*previousTimestampPacketNodes = std::move(previous); *timestampPacketDependencies = std::move(dependencies);
} }
Command::~Command() { Command::~Command() {
@@ -376,8 +375,8 @@ void Command::makeTimestampPacketsResident(CommandStreamReceiver &commandStreamR
if (currentTimestampPacketNodes) { if (currentTimestampPacketNodes) {
currentTimestampPacketNodes->makeResident(commandStreamReceiver); currentTimestampPacketNodes->makeResident(commandStreamReceiver);
} }
if (previousTimestampPacketNodes) { if (timestampPacketDependencies) {
previousTimestampPacketNodes->makeResident(commandStreamReceiver); timestampPacketDependencies->previousEnqueueNodes.makeResident(commandStreamReceiver);
} }
} }

View File

@@ -94,7 +94,7 @@ class Command : public IFNode<Command> {
virtual LinearStream *getCommandStream() { virtual LinearStream *getCommandStream() {
return nullptr; return nullptr;
} }
void setTimestampPacketNode(TimestampPacketContainer &current, TimestampPacketContainer &&previous); void setTimestampPacketNode(TimestampPacketContainer &current, TimestampPacketDependencies &&dependencies);
void setEventsRequest(EventsRequest &eventsRequest); void setEventsRequest(EventsRequest &eventsRequest);
void makeTimestampPacketsResident(CommandStreamReceiver &commandStreamReceiver); void makeTimestampPacketsResident(CommandStreamReceiver &commandStreamReceiver);
@@ -105,7 +105,7 @@ class Command : public IFNode<Command> {
CommandQueue &commandQueue; CommandQueue &commandQueue;
std::unique_ptr<KernelOperation> kernelOperation; std::unique_ptr<KernelOperation> kernelOperation;
std::unique_ptr<TimestampPacketContainer> currentTimestampPacketNodes; std::unique_ptr<TimestampPacketContainer> currentTimestampPacketNodes;
std::unique_ptr<TimestampPacketContainer> previousTimestampPacketNodes; std::unique_ptr<TimestampPacketDependencies> timestampPacketDependencies;
EventsRequest eventsRequest = {0, nullptr, nullptr}; EventsRequest eventsRequest = {0, nullptr, nullptr};
std::vector<cl_event> eventsWaitlist; std::vector<cl_event> eventsWaitlist;
}; };
@@ -152,6 +152,6 @@ class CommandWithoutKernel : public Command {
public: public:
using Command::Command; using Command::Command;
CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; CompletionStamp &submit(uint32_t taskLevel, bool terminated) override;
void dispatchBlitOperation(TimestampPacketContainer &barrierTimestampPacketNodes); void dispatchBlitOperation();
}; };
} // namespace NEO } // namespace NEO

View File

@@ -61,7 +61,7 @@ HWTEST_F(EnqueueHandlerTest, givenNonBlitPropertyWhenEnqueueIsBlockedThenDontReg
auto blockedCommandsDataForDependencyFlush = new KernelOperation(commandStream, *csr.getInternalAllocationStorage()); auto blockedCommandsDataForDependencyFlush = new KernelOperation(commandStream, *csr.getInternalAllocationStorage());
TimestampPacketContainer previousTimestampPacketNodes; TimestampPacketDependencies timestampPacketDependencies;
MultiDispatchInfo multiDispatchInfo; MultiDispatchInfo multiDispatchInfo;
EventsRequest eventsRequest(0, nullptr, nullptr); EventsRequest eventsRequest(0, nullptr, nullptr);
EventBuilder eventBuilder; EventBuilder eventBuilder;
@@ -70,7 +70,7 @@ HWTEST_F(EnqueueHandlerTest, givenNonBlitPropertyWhenEnqueueIsBlockedThenDontReg
auto blockedCommandsData = std::unique_ptr<KernelOperation>(blockedCommandsDataForDependencyFlush); auto blockedCommandsData = std::unique_ptr<KernelOperation>(blockedCommandsDataForDependencyFlush);
Surface *surfaces[] = {nullptr}; Surface *surfaces[] = {nullptr};
mockCmdQ->enqueueBlocked(CL_COMMAND_MARKER, surfaces, size_t(0), multiDispatchInfo, previousTimestampPacketNodes, mockCmdQ->enqueueBlocked(CL_COMMAND_MARKER, surfaces, size_t(0), multiDispatchInfo, timestampPacketDependencies,
blockedCommandsData, enqueuePropertiesForDependencyFlush, eventsRequest, blockedCommandsData, enqueuePropertiesForDependencyFlush, eventsRequest,
eventBuilder, std::unique_ptr<PrintfHandler>(nullptr)); eventBuilder, std::unique_ptr<PrintfHandler>(nullptr));
EXPECT_FALSE(blockedCommandsDataForDependencyFlush->blitEnqueue); EXPECT_FALSE(blockedCommandsDataForDependencyFlush->blitEnqueue);
@@ -85,7 +85,7 @@ HWTEST_F(EnqueueHandlerTest, givenBlitPropertyWhenEnqueueIsBlockedThenRegisterBl
auto blockedCommandsDataForBlitEnqueue = new KernelOperation(commandStream, *csr.getInternalAllocationStorage()); auto blockedCommandsDataForBlitEnqueue = new KernelOperation(commandStream, *csr.getInternalAllocationStorage());
TimestampPacketContainer previousTimestampPacketNodes; TimestampPacketDependencies timestampPacketDependencies;
MultiDispatchInfo multiDispatchInfo; MultiDispatchInfo multiDispatchInfo;
EventsRequest eventsRequest(0, nullptr, nullptr); EventsRequest eventsRequest(0, nullptr, nullptr);
EventBuilder eventBuilder; EventBuilder eventBuilder;
@@ -99,7 +99,7 @@ HWTEST_F(EnqueueHandlerTest, givenBlitPropertyWhenEnqueueIsBlockedThenRegisterBl
auto blockedCommandsData = std::unique_ptr<KernelOperation>(blockedCommandsDataForBlitEnqueue); auto blockedCommandsData = std::unique_ptr<KernelOperation>(blockedCommandsDataForBlitEnqueue);
Surface *surfaces[] = {nullptr}; Surface *surfaces[] = {nullptr};
mockCmdQ->enqueueBlocked(CL_COMMAND_READ_BUFFER, surfaces, size_t(0), multiDispatchInfo, previousTimestampPacketNodes, mockCmdQ->enqueueBlocked(CL_COMMAND_READ_BUFFER, surfaces, size_t(0), multiDispatchInfo, timestampPacketDependencies,
blockedCommandsData, enqueuePropertiesForBlitEnqueue, eventsRequest, blockedCommandsData, enqueuePropertiesForBlitEnqueue, eventsRequest,
eventBuilder, std::unique_ptr<PrintfHandler>(nullptr)); eventBuilder, std::unique_ptr<PrintfHandler>(nullptr));
EXPECT_TRUE(blockedCommandsDataForBlitEnqueue->blitEnqueue); EXPECT_TRUE(blockedCommandsDataForBlitEnqueue->blitEnqueue);

View File

@@ -258,7 +258,9 @@ HWTEST_F(DispatchFlagsTests, givenCommandWithoutKernelWhenSubmitThenPassCorrectD
auto mockCsr = static_cast<CsrType *>(&mockCmdQ->getGpgpuCommandStreamReceiver()); auto mockCsr = static_cast<CsrType *>(&mockCmdQ->getGpgpuCommandStreamReceiver());
mockCsr->timestampPacketWriteEnabled = true; mockCsr->timestampPacketWriteEnabled = true;
mockCmdQ->timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr; IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr;
TimestampPacketDependencies timestampPacketDependencies;
mockCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1); mockCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
mockCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2); mockCmdQ->allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
mockCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3); mockCmdQ->allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
@@ -267,6 +269,7 @@ HWTEST_F(DispatchFlagsTests, givenCommandWithoutKernelWhenSubmitThenPassCorrectD
auto kernelOperation = std::make_unique<KernelOperation>(cmdStream, *mockCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage()); auto kernelOperation = std::make_unique<KernelOperation>(cmdStream, *mockCmdQ->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
kernelOperation->setHeaps(ih1, ih2, ih3); kernelOperation->setHeaps(ih1, ih2, ih3);
std::unique_ptr<Command> command(new CommandWithoutKernel(*mockCmdQ, kernelOperation)); std::unique_ptr<Command> command(new CommandWithoutKernel(*mockCmdQ, kernelOperation));
command->setTimestampPacketNode(*mockCmdQ->timestampPacketContainer, std::move(timestampPacketDependencies));
command->submit(20, false); command->submit(20, false);