Use MI_SEMAPHORE_WAIT command for event synchronization

Related-To: NEO-5508
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2021-03-11 13:48:04 +00:00
committed by Compute-Runtime-Automation
parent 2b956651a7
commit b01b8ba5ac
17 changed files with 395 additions and 165 deletions

View File

@@ -327,7 +327,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
auto &commandStreamCSR = this->getCS(getRequiredCmdStreamSizeAligned(dispatchFlags, device));
auto commandStreamStartCSR = commandStreamCSR.getUsed();
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStreamCSR, dispatchFlags.csrDependencies, getOsContext().getNumSupportedDevices());
TimestampPacketHelper::programCsrDependenciesForTimestampPacketContainer<GfxFamily>(commandStreamCSR, dispatchFlags.csrDependencies, getOsContext().getNumSupportedDevices());
if (stallingPipeControlOnNextFlushRequired) {
programStallingPipeControlForBarrier(commandStreamCSR, dispatchFlags);
@@ -1016,7 +1016,7 @@ uint32_t CommandStreamReceiverHw<GfxFamily>::blitBuffer(const BlitPropertiesCont
programEnginePrologue(commandStream);
for (auto &blitProperties : blitPropertiesContainer) {
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStream, blitProperties.csrDependencies, getOsContext().getNumSupportedDevices());
TimestampPacketHelper::programCsrDependenciesForTimestampPacketContainer<GfxFamily>(commandStream, blitProperties.csrDependencies, getOsContext().getNumSupportedDevices());
if (blitProperties.outputTimestampPacket && profilingEnabled) {
BlitCommandsHelper<GfxFamily>::encodeProfilingStartMmios(commandStream, *blitProperties.outputTimestampPacket);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,7 +12,7 @@
namespace NEO {
void CsrDependencies::makeResident(CommandStreamReceiver &commandStreamReceiver) const {
for (auto &timestampPacketContainer : *this) {
for (auto &timestampPacketContainer : timestampPacketContainer) {
timestampPacketContainer->makeResident(commandStreamReceiver);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,7 +13,7 @@ namespace NEO {
class TimestampPacketContainer;
class CommandStreamReceiver;
class CsrDependencies : public StackVec<TimestampPacketContainer *, 32> {
class CsrDependencies {
public:
enum class DependenciesType {
OnCsr,
@@ -21,6 +21,9 @@ class CsrDependencies : public StackVec<TimestampPacketContainer *, 32> {
All
};
StackVec<std::pair<uint32_t, uint64_t>, 32> taskCountContainer;
StackVec<TimestampPacketContainer *, 32> timestampPacketContainer;
void makeResident(CommandStreamReceiver &commandStreamReceiver) const;
};
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -144,15 +144,15 @@ void BlitProperties::setupDependenciesForAuxTranslation(BlitPropertiesContainer
timestampPacketDependencies.barrierNodes.add(nodesAllocator->getTag());
// wait for barrier and events before AuxToNonAux
blitPropertiesContainer[0].csrDependencies.push_back(&timestampPacketDependencies.barrierNodes);
blitPropertiesContainer[0].csrDependencies.timestampPacketContainer.push_back(&timestampPacketDependencies.barrierNodes);
for (auto dep : depsFromEvents) {
blitPropertiesContainer[0].csrDependencies.push_back(dep);
for (auto dep : depsFromEvents.timestampPacketContainer) {
blitPropertiesContainer[0].csrDependencies.timestampPacketContainer.push_back(dep);
}
// wait for NDR before NonAuxToAux
blitPropertiesContainer[numObjects].csrDependencies.push_back(&timestampPacketDependencies.cacheFlushNodes);
blitPropertiesContainer[numObjects].csrDependencies.push_back(&kernelTimestamps);
blitPropertiesContainer[numObjects].csrDependencies.timestampPacketContainer.push_back(&timestampPacketDependencies.cacheFlushNodes);
blitPropertiesContainer[numObjects].csrDependencies.timestampPacketContainer.push_back(&kernelTimestamps);
}
} // namespace NEO

View File

@@ -6,8 +6,8 @@
*/
#pragma once
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/command_stream/csr_deps.h"
#include "shared/source/helpers/aux_translation.h"
#include "shared/source/helpers/hw_helper.h"
@@ -183,14 +183,29 @@ struct TimestampPacketHelper {
}
template <typename GfxFamily>
static void programCsrDependencies(LinearStream &cmdStream, const CsrDependencies &csrDependencies, uint32_t numSupportedDevices) {
for (auto timestampPacketContainer : csrDependencies) {
static void programCsrDependenciesForTimestampPacketContainer(LinearStream &cmdStream, const CsrDependencies &csrDependencies, uint32_t numSupportedDevices) {
for (auto timestampPacketContainer : csrDependencies.timestampPacketContainer) {
for (auto &node : timestampPacketContainer->peekNodes()) {
TimestampPacketHelper::programSemaphoreWithImplicitDependency<GfxFamily>(cmdStream, *node, numSupportedDevices);
}
}
}
template <typename GfxFamily>
static void programCsrDependenciesForForTaskCountContainer(LinearStream &cmdStream, const CsrDependencies &csrDependencies) {
auto taskCountContainer = csrDependencies.taskCountContainer;
for (auto &[taskCountPreviousRootDevice, tagAddressPreviousRootDevice] : taskCountContainer) {
using COMPARE_OPERATION = typename GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION;
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
EncodeSempahore<GfxFamily>::addMiSemaphoreWaitCommand(cmdStream,
static_cast<uint64_t>(tagAddressPreviousRootDevice),
taskCountPreviousRootDevice,
COMPARE_OPERATION::COMPARE_OPERATION_SAD_GREATER_THAN_OR_EQUAL_SDD);
}
}
template <typename GfxFamily, AuxTranslationDirection auxTranslationDirection>
static void programSemaphoreWithImplicitDependencyForAuxTranslation(LinearStream &cmdStream,
const TimestampPacketDependencies *timestampPacketDependencies,
@@ -241,7 +256,7 @@ struct TimestampPacketHelper {
template <typename GfxFamily>
static size_t getRequiredCmdStreamSize(const CsrDependencies &csrDependencies) {
size_t totalCommandsSize = 0;
for (auto timestampPacketContainer : csrDependencies) {
for (auto timestampPacketContainer : csrDependencies.timestampPacketContainer) {
for (auto &node : timestampPacketContainer->peekNodes()) {
totalCommandsSize += getRequiredCmdStreamSizeForNodeDependency<GfxFamily>(*node);
}
@@ -249,6 +264,11 @@ struct TimestampPacketHelper {
return totalCommandsSize;
}
template <typename GfxFamily>
static size_t getRequiredCmdStreamSizeForTaskCountContainer(const CsrDependencies &csrDependencies) {
return csrDependencies.taskCountContainer.size() * sizeof(typename GfxFamily::MI_SEMAPHORE_WAIT);
}
};
} // namespace NEO