refactor: pass InOrderExecInfo to encode method

Related-To: NEO-7966

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-12-11 12:10:56 +00:00
committed by Compute-Runtime-Automation
parent b182917d9d
commit 717bc0c03f
20 changed files with 264 additions and 62 deletions

View File

@@ -171,7 +171,7 @@ struct CommandListCoreFamily : public CommandListImp {
ze_result_t appendSignalEvent(ze_event_handle_t hEvent) override;
ze_result_t appendWaitOnEvents(uint32_t numEvents, ze_event_handle_t *phEvent, bool relaxedOrderingAllowed, bool trackDependencies, bool apiRequest) override;
void appendWaitOnInOrderDependency(std::shared_ptr<InOrderExecInfo> &inOrderExecInfo, uint64_t waitValue, uint32_t offset, bool relaxedOrderingAllowed, bool implicitDependency);
void appendWaitOnInOrderDependency(std::shared_ptr<NEO::InOrderExecInfo> &inOrderExecInfo, uint64_t waitValue, uint32_t offset, bool relaxedOrderingAllowed, bool implicitDependency);
void appendSignalInOrderDependencyCounter(Event *signalEvent);
void handleInOrderDependencyCounter(Event *signalEvent, bool nonWalkerInOrderCmdsChaining);
@@ -340,12 +340,12 @@ struct CommandListCoreFamily : public CommandListImp {
bool isInOrderNonWalkerSignalingRequired(const Event *event) const;
bool hasInOrderDependencies() const;
void addCmdForPatching(std::shared_ptr<InOrderExecInfo> *externalInOrderExecInfo, void *cmd1, void *cmd2, uint64_t counterValue, InOrderPatchCommandHelpers::PatchCmdType patchCmdType);
void addCmdForPatching(std::shared_ptr<NEO::InOrderExecInfo> *externalInOrderExecInfo, void *cmd1, void *cmd2, uint64_t counterValue, NEO::InOrderPatchCommandHelpers::PatchCmdType patchCmdType);
bool inOrderAtomicSignallingEnabled() const override;
uint64_t getInOrderIncrementValue() const;
InOrderPatchCommandsContainer<GfxFamily> inOrderPatchCmds;
NEO::InOrderPatchCommandsContainer<GfxFamily> inOrderPatchCmds;
uint64_t latestHostWaitedInOrderSyncValue = 0;
bool latestOperationRequiredNonWalkerInOrderCmdsChaining = false;

View File

@@ -20,6 +20,7 @@
#include "shared/source/helpers/definitions/command_encoder_args.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/in_order_cmd_helpers.h"
#include "shared/source/helpers/kernel_helpers.h"
#include "shared/source/helpers/pipe_control_args.h"
#include "shared/source/helpers/preamble.h"
@@ -46,7 +47,6 @@
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/core/source/event/event.h"
#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h"
#include "level_zero/core/source/helpers/in_order_cmd_helpers.h"
#include "level_zero/core/source/image/image.h"
#include "level_zero/core/source/kernel/kernel.h"
#include "level_zero/core/source/kernel/kernel_imp.h"
@@ -2408,7 +2408,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::appendWaitOnInOrderDependency(std::shared_ptr<InOrderExecInfo> &inOrderExecInfo, uint64_t waitValue, uint32_t offset, bool relaxedOrderingAllowed, bool implicitDependency) {
void CommandListCoreFamily<gfxCoreFamily>::appendWaitOnInOrderDependency(std::shared_ptr<NEO::InOrderExecInfo> &inOrderExecInfo, uint64_t waitValue, uint32_t offset, bool relaxedOrderingAllowed, bool implicitDependency) {
using COMPARE_OPERATION = typename GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION;
UNRECOVERABLE_IF(waitValue > static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()) && !isQwordInOrderCounter());
@@ -2435,7 +2435,7 @@ void CommandListCoreFamily<gfxCoreFamily>::appendWaitOnInOrderDependency(std::sh
auto lri2 = NEO::LriHelper<GfxFamily>::program(commandContainer.getCommandStream(), RegisterOffsets::csGprR0 + 4, getHighPart(waitValue), true);
if (inOrderExecInfo->isRegularCmdList()) {
addCmdForPatching((implicitDependency ? nullptr : &inOrderExecInfo), lri1, lri2, waitValue, InOrderPatchCommandHelpers::PatchCmdType::Lri64b);
addCmdForPatching((implicitDependency ? nullptr : &inOrderExecInfo), lri1, lri2, waitValue, NEO::InOrderPatchCommandHelpers::PatchCmdType::Lri64b);
}
}
@@ -2445,7 +2445,7 @@ void CommandListCoreFamily<gfxCoreFamily>::appendWaitOnInOrderDependency(std::sh
false, true, isQwordInOrderCounter(), indirectMode);
if (inOrderExecInfo->isRegularCmdList() && !isQwordInOrderCounter()) {
addCmdForPatching((implicitDependency ? nullptr : &inOrderExecInfo), semaphoreCommand, nullptr, waitValue, InOrderPatchCommandHelpers::PatchCmdType::Semaphore);
addCmdForPatching((implicitDependency ? nullptr : &inOrderExecInfo), semaphoreCommand, nullptr, waitValue, NEO::InOrderPatchCommandHelpers::PatchCmdType::Semaphore);
}
}
@@ -2564,7 +2564,7 @@ void CommandListCoreFamily<gfxCoreFamily>::appendSdiInOrderCounterSignalling(uin
NEO::EncodeStoreMemory<GfxFamily>::programStoreDataImm(miStoreCmd, gpuVa, getLowPart(signalValue), getHighPart(signalValue),
isQwordInOrderCounter(), (this->partitionCount > 1));
addCmdForPatching(nullptr, miStoreCmd, nullptr, signalValue, InOrderPatchCommandHelpers::PatchCmdType::Sdi);
addCmdForPatching(nullptr, miStoreCmd, nullptr, signalValue, NEO::InOrderPatchCommandHelpers::PatchCmdType::Sdi);
}
template <GFXCORE_FAMILY gfxCoreFamily>
@@ -3640,7 +3640,7 @@ void CommandListCoreFamily<gfxCoreFamily>::appendWaitOnSingleEvent(Event *event,
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::addCmdForPatching(std::shared_ptr<InOrderExecInfo> *externalInOrderExecInfo, void *cmd1, void *cmd2, uint64_t counterValue, InOrderPatchCommandHelpers::PatchCmdType patchCmdType) {
void CommandListCoreFamily<gfxCoreFamily>::addCmdForPatching(std::shared_ptr<NEO::InOrderExecInfo> *externalInOrderExecInfo, void *cmd1, void *cmd2, uint64_t counterValue, NEO::InOrderPatchCommandHelpers::PatchCmdType patchCmdType) {
if ((NEO::debugManager.flags.EnableInOrderRegularCmdListPatching.get() != 0) && (this->cmdListType == TYPE_REGULAR)) {
this->inOrderPatchCmds.emplace_back(externalInOrderExecInfo, cmd1, cmd2, counterValue, patchCmdType);
}
@@ -3649,7 +3649,7 @@ void CommandListCoreFamily<gfxCoreFamily>::addCmdForPatching(std::shared_ptr<InO
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::patchInOrderCmds() {
if (isInOrderExecutionEnabled()) {
auto implicitAppendCounter = InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo);
auto implicitAppendCounter = NEO::InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo);
for (auto &cmd : inOrderPatchCmds) {
if (cmd.isExternalDependency() || (inOrderExecInfo->getRegularCmdListSubmissionCounter() > 1)) {

View File

@@ -20,6 +20,7 @@
#include "shared/source/helpers/bindless_heaps_helper.h"
#include "shared/source/helpers/blit_commands_helper.h"
#include "shared/source/helpers/completion_stamp.h"
#include "shared/source/helpers/in_order_cmd_helpers.h"
#include "shared/source/helpers/surface_format_info.h"
#include "shared/source/memory_manager/internal_allocation_storage.h"
#include "shared/source/memory_manager/unified_memory_manager.h"
@@ -33,7 +34,6 @@
#include "level_zero/core/source/driver/driver_handle.h"
#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h"
#include "level_zero/core/source/helpers/error_code_helper_l0.h"
#include "level_zero/core/source/helpers/in_order_cmd_helpers.h"
#include "level_zero/core/source/image/image.h"
#include "level_zero/core/source/kernel/kernel_imp.h"

View File

@@ -192,7 +192,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
NEO::EncodeDispatchKernelArgs dispatchKernelArgs{
0, // eventAddress
static_cast<uint64_t>(Event::STATE_SIGNALED), // postSyncImmValue
0, // inOrderCounterValue
neoDevice, // device
nullptr, // inOrderExecInfo
kernel, // dispatchInterface
ssh, // surfaceStateHeap
dsh, // dynamicStateHeap

View File

@@ -275,10 +275,27 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
appendEventForProfilingAllWalkers(compactEvent, true, true);
}
bool inOrderExecSignalRequired = (this->isInOrderExecutionEnabled() && !launchParams.isKernelSplitOperation);
bool inOrderNonWalkerSignalling = isInOrderNonWalkerSignalingRequired(eventForInOrderExec);
uint64_t inOrderCounterValue = 0;
NEO::InOrderExecInfo *inOrderExecInfo = nullptr;
if (inOrderExecSignalRequired) {
if (inOrderNonWalkerSignalling) {
dispatchEventPostSyncOperation(eventForInOrderExec, Event::STATE_CLEARED, false, false, false, false);
} else {
inOrderCounterValue = this->inOrderExecInfo->getCounterValue() + getInOrderIncrementValue();
inOrderExecInfo = this->inOrderExecInfo.get();
}
}
NEO::EncodeDispatchKernelArgs dispatchKernelArgs{
eventAddress, // eventAddress
static_cast<uint64_t>(Event::STATE_SIGNALED), // postSyncImmValue
inOrderCounterValue, // inOrderCounterValue
neoDevice, // device
inOrderExecInfo, // inOrderExecInfo
kernel, // dispatchInterface
ssh, // surfaceStateHeap
dsh, // dynamicStateHeap
@@ -302,21 +319,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
cmdListType == CommandListType::TYPE_IMMEDIATE, // isKernelDispatchedFromImmediateCmdList
engineGroupType == NEO::EngineGroupType::renderCompute, // isRcs
this->dcFlushSupport, // dcFlushEnable
this->heaplessModeEnabled // isHeaplessModeEnabled
this->heaplessModeEnabled, // isHeaplessModeEnabled
};
bool inOrderExecSignalRequired = (this->isInOrderExecutionEnabled() && !launchParams.isKernelSplitOperation);
bool inOrderNonWalkerSignalling = isInOrderNonWalkerSignalingRequired(eventForInOrderExec);
if (inOrderExecSignalRequired) {
if (inOrderNonWalkerSignalling) {
dispatchEventPostSyncOperation(eventForInOrderExec, Event::STATE_CLEARED, false, false, false, false);
} else {
dispatchKernelArgs.eventAddress = inOrderExecInfo->getDeviceCounterAllocation().getGpuAddress() + inOrderExecInfo->getAllocationOffset();
dispatchKernelArgs.postSyncImmValue = inOrderExecInfo->getCounterValue() + 1;
}
}
NEO::EncodeDispatchKernel<GfxFamily>::encodeCommon(commandContainer, dispatchKernelArgs);
if (!this->isFlushTaskSubmissionEnabled) {
@@ -343,7 +348,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(K
}
} else {
UNRECOVERABLE_IF(!dispatchKernelArgs.outWalkerPtr);
addCmdForPatching(nullptr, dispatchKernelArgs.outWalkerPtr, nullptr, dispatchKernelArgs.postSyncImmValue, InOrderPatchCommandHelpers::PatchCmdType::Walker);
addCmdForPatching(nullptr, dispatchKernelArgs.outWalkerPtr, nullptr, inOrderCounterValue, NEO::InOrderPatchCommandHelpers::PatchCmdType::Walker);
}
}

View File

@@ -247,8 +247,8 @@ void CommandListImp::enableInOrderExecution() {
UNRECOVERABLE_IF(!inOrderDependencyCounterAllocation);
inOrderExecInfo = std::make_shared<InOrderExecInfo>(*inOrderDependencyCounterAllocation, hostCounterAllocation, *device->getMemoryManager(), this->partitionCount,
(this->cmdListType == TYPE_REGULAR), inOrderAtomicSignallingEnabled());
inOrderExecInfo = std::make_shared<NEO::InOrderExecInfo>(*inOrderDependencyCounterAllocation, hostCounterAllocation, *device->getMemoryManager(), this->partitionCount,
(this->cmdListType == TYPE_REGULAR), inOrderAtomicSignallingEnabled());
}
void CommandListImp::storeReferenceTsToMappedEvents(bool isClearEnabled) {

View File

@@ -6,10 +6,10 @@
*/
#pragma once
#include "shared/source/helpers/in_order_cmd_helpers.h"
#include "shared/source/os_interface/os_time.h"
#include "level_zero/core/source/cmdlist/cmdlist.h"
#include "level_zero/core/source/helpers/in_order_cmd_helpers.h"
#include <memory>
@@ -39,7 +39,7 @@ struct CommandListImp : public CommandList {
virtual void patchInOrderCmds() = 0;
protected:
std::shared_ptr<InOrderExecInfo> inOrderExecInfo;
std::shared_ptr<NEO::InOrderExecInfo> inOrderExecInfo;
~CommandListImp() override = default;

View File

@@ -423,7 +423,7 @@ void Event::setIsCompleted() {
unsetCmdQueue();
}
void Event::updateInOrderExecState(std::shared_ptr<InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset) {
void Event::updateInOrderExecState(std::shared_ptr<NEO::InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset) {
resetCompletionStatus();
if (this->inOrderExecInfo.get() != newInOrderExecInfo.get()) {
@@ -435,7 +435,7 @@ void Event::updateInOrderExecState(std::shared_ptr<InOrderExecInfo> &newInOrderE
}
uint64_t Event::getInOrderExecSignalValueWithSubmissionCounter() const {
return (inOrderExecSignalValue + InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo));
return (inOrderExecSignalValue + NEO::InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo));
}
void Event::setLatestUsedCmdQueue(CommandQueue *newCmdQ) {

View File

@@ -30,6 +30,7 @@ class CommandStreamReceiver;
class GraphicsAllocation;
class MultiGraphicsAllocation;
struct RootDeviceEnvironment;
class InOrderExecInfo;
} // namespace NEO
namespace L0 {
@@ -43,7 +44,6 @@ struct DriverHandle;
struct DriverHandleImp;
struct Device;
struct Kernel;
class InOrderExecInfo;
#pragma pack(1)
struct IpcEventPoolData {
@@ -238,7 +238,7 @@ struct Event : _ze_event_handle_t {
void setMetricNotification(MetricCollectorEventNotify *metricNotification) {
this->metricNotification = metricNotification;
}
void updateInOrderExecState(std::shared_ptr<InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset);
void updateInOrderExecState(std::shared_ptr<NEO::InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset);
bool isCounterBased() const { return ((counterBasedMode == CounterBasedMode::ExplicitlyEnabled) || (counterBasedMode == CounterBasedMode::ImplicitlyEnabled)); }
bool isCounterBasedExplicitlyEnabled() const { return (counterBasedMode == CounterBasedMode::ExplicitlyEnabled); }
void enableCounterBasedMode(bool apiRequest);
@@ -254,7 +254,7 @@ struct Event : _ze_event_handle_t {
void setReferenceTs(uint64_t currentCpuTimeStamp);
const CommandQueue *getLatestUsedCmdQueue() const { return latestUsedCmdQueue; }
bool hasKerneMappedTsCapability = false;
std::shared_ptr<InOrderExecInfo> &getInOrderExecInfo() { return inOrderExecInfo; }
std::shared_ptr<NEO::InOrderExecInfo> &getInOrderExecInfo() { return inOrderExecInfo; }
void enableKmdWaitMode() { kmdWaitMode = true; }
bool isKmdWaitModeEnabled() const { return kmdWaitMode; }
void unsetInOrderExecInfo();
@@ -296,7 +296,7 @@ struct Event : _ze_event_handle_t {
EventPool *eventPool = nullptr;
std::weak_ptr<Kernel> kernelWithPrintf = std::weak_ptr<Kernel>{};
std::mutex *kernelWithPrintfDeviceMutex = nullptr;
std::shared_ptr<InOrderExecInfo> inOrderExecInfo;
std::shared_ptr<NEO::InOrderExecInfo> inOrderExecInfo;
CommandQueue *latestUsedCmdQueue = nullptr;
uint32_t maxKernelCount = 0;

View File

@@ -11,8 +11,6 @@ target_sources(${L0_STATIC_LIB_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/error_code_helper_l0.cpp
${CMAKE_CURRENT_SOURCE_DIR}/error_code_helper_l0.h
${CMAKE_CURRENT_SOURCE_DIR}/implicit_scaling_l0.cpp
${CMAKE_CURRENT_SOURCE_DIR}/in_order_cmd_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/in_order_cmd_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_factory_init.inl
${CMAKE_CURRENT_SOURCE_DIR}/l0_populate_factory.h
${CMAKE_CURRENT_SOURCE_DIR}/properties_parser.h

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/helpers/in_order_cmd_helpers.h"
#include "shared/source/memory_manager/memory_manager.h"
#include <cstdint>
#include <string.h>
#include <vector>
namespace L0 {
InOrderExecInfo::~InOrderExecInfo() {
memoryManager.freeGraphicsMemory(&deviceCounterAllocation);
memoryManager.freeGraphicsMemory(hostCounterAllocation);
}
InOrderExecInfo::InOrderExecInfo(NEO::GraphicsAllocation &deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling)
: deviceCounterAllocation(deviceCounterAllocation), memoryManager(memoryManager), hostCounterAllocation(hostCounterAllocation), regularCmdList(regularCmdList) {
numDevicePartitionsToWait = atomicDeviceSignalling ? 1 : partitionCount;
numHostPartitionsToWait = partitionCount;
if (hostCounterAllocation) {
hostAddress = reinterpret_cast<uint64_t *>(hostCounterAllocation->getUnderlyingBuffer());
duplicatedHostStorage = true;
} else {
hostAddress = reinterpret_cast<uint64_t *>(deviceCounterAllocation.getUnderlyingBuffer());
}
reset();
}
void InOrderExecInfo::reset() {
counterValue = 0;
regularCmdListSubmissionCounter = 0;
allocationOffset = 0;
memset(deviceCounterAllocation.getUnderlyingBuffer(), 0, deviceCounterAllocation.getUnderlyingBufferSize());
if (hostCounterAllocation) {
memset(hostCounterAllocation->getUnderlyingBuffer(), 0, hostCounterAllocation->getUnderlyingBufferSize());
}
}
} // namespace L0

View File

@@ -1,176 +0,0 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "shared/source/helpers/ptr_math.h"
#include <cstdint>
#include <memory>
#include <vector>
namespace NEO {
class GraphicsAllocation;
class MemoryManager;
} // namespace NEO
namespace L0 {
class InOrderExecInfo : public NEO::NonCopyableClass {
public:
~InOrderExecInfo();
InOrderExecInfo() = delete;
InOrderExecInfo(NEO::GraphicsAllocation &deviceCounterAllocation, NEO::GraphicsAllocation *hostCounterAllocation, NEO::MemoryManager &memoryManager, uint32_t partitionCount, bool regularCmdList, bool atomicDeviceSignalling);
NEO::GraphicsAllocation &getDeviceCounterAllocation() const { return deviceCounterAllocation; }
NEO::GraphicsAllocation *getHostCounterAllocation() const { return hostCounterAllocation; }
uint64_t *getBaseHostAddress() const { return hostAddress; }
uint64_t getCounterValue() const { return counterValue; }
void addCounterValue(uint64_t addValue) { counterValue += addValue; }
void resetCounterValue() { counterValue = 0; }
uint64_t getRegularCmdListSubmissionCounter() const { return regularCmdListSubmissionCounter; }
void addRegularCmdListSubmissionCounter(uint64_t addValue) { regularCmdListSubmissionCounter += addValue; }
bool isRegularCmdList() const { return regularCmdList; }
bool isHostStorageDuplicated() const { return duplicatedHostStorage; }
uint32_t getNumDevicePartitionsToWait() const { return numDevicePartitionsToWait; }
uint32_t getNumHostPartitionsToWait() const { return numHostPartitionsToWait; }
void addAllocationOffset(uint32_t addValue) { allocationOffset += addValue; }
uint32_t getAllocationOffset() const { return allocationOffset; }
void reset();
protected:
NEO::GraphicsAllocation &deviceCounterAllocation;
NEO::MemoryManager &memoryManager;
NEO::GraphicsAllocation *hostCounterAllocation = nullptr;
uint64_t counterValue = 0;
uint64_t regularCmdListSubmissionCounter = 0;
uint64_t *hostAddress = nullptr;
uint32_t numDevicePartitionsToWait = 0;
uint32_t numHostPartitionsToWait = 0;
uint32_t allocationOffset = 0;
bool regularCmdList = false;
bool duplicatedHostStorage = false;
};
namespace InOrderPatchCommandHelpers {
inline uint64_t getAppendCounterValue(const InOrderExecInfo &inOrderExecInfo) {
if (inOrderExecInfo.isRegularCmdList() && inOrderExecInfo.getRegularCmdListSubmissionCounter() > 1) {
return inOrderExecInfo.getCounterValue() * (inOrderExecInfo.getRegularCmdListSubmissionCounter() - 1);
}
return 0;
}
enum class PatchCmdType {
None,
Lri64b,
Sdi,
Semaphore,
Walker
};
template <typename GfxFamily>
struct PatchCmd {
PatchCmd(std::shared_ptr<InOrderExecInfo> *inOrderExecInfo, void *cmd1, void *cmd2, uint64_t baseCounterValue, PatchCmdType patchCmdType)
: cmd1(cmd1), cmd2(cmd2), baseCounterValue(baseCounterValue), patchCmdType(patchCmdType) {
if (inOrderExecInfo) {
this->inOrderExecInfo = *inOrderExecInfo;
}
}
void patch(uint64_t appendCounterValue) {
switch (patchCmdType) {
case PatchCmdType::Sdi:
patchSdi(appendCounterValue);
break;
case PatchCmdType::Semaphore:
patchSemaphore(appendCounterValue);
break;
case PatchCmdType::Walker:
patchComputeWalker(appendCounterValue);
break;
case PatchCmdType::Lri64b:
patchLri64b(appendCounterValue);
break;
default:
UNRECOVERABLE_IF(true);
break;
}
}
bool isExternalDependency() const { return inOrderExecInfo.get(); }
std::shared_ptr<InOrderExecInfo> inOrderExecInfo;
void *cmd1 = nullptr;
void *cmd2 = nullptr;
const uint64_t baseCounterValue = 0;
const PatchCmdType patchCmdType = PatchCmdType::None;
protected:
void patchSdi(uint64_t appendCounterValue) {
auto sdiCmd = reinterpret_cast<typename GfxFamily::MI_STORE_DATA_IMM *>(cmd1);
sdiCmd->setDataDword0(getLowPart(baseCounterValue + appendCounterValue));
sdiCmd->setDataDword1(getHighPart(baseCounterValue + appendCounterValue));
}
void patchSemaphore(uint64_t appendCounterValue) {
if (isExternalDependency()) {
appendCounterValue = InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo);
if (appendCounterValue == 0) {
return;
}
}
auto semaphoreCmd = reinterpret_cast<typename GfxFamily::MI_SEMAPHORE_WAIT *>(cmd1);
semaphoreCmd->setSemaphoreDataDword(static_cast<uint32_t>(baseCounterValue + appendCounterValue));
}
void patchComputeWalker(uint64_t appendCounterValue) {
if constexpr (GfxFamily::walkerPostSyncSupport) {
auto walkerCmd = reinterpret_cast<typename GfxFamily::COMPUTE_WALKER *>(cmd1);
auto &postSync = walkerCmd->getPostSync();
postSync.setImmediateData(baseCounterValue + appendCounterValue);
} else {
UNRECOVERABLE_IF(true);
}
}
void patchLri64b(uint64_t appendCounterValue) {
if (isExternalDependency()) {
appendCounterValue = InOrderPatchCommandHelpers::getAppendCounterValue(*inOrderExecInfo);
if (appendCounterValue == 0) {
return;
}
}
const uint64_t counterValue = baseCounterValue + appendCounterValue;
auto lri1 = reinterpret_cast<typename GfxFamily::MI_LOAD_REGISTER_IMM *>(cmd1);
lri1->setDataDword(getLowPart(counterValue));
auto lri2 = reinterpret_cast<typename GfxFamily::MI_LOAD_REGISTER_IMM *>(cmd2);
lri2->setDataDword(getHighPart(counterValue));
}
PatchCmd() = delete;
};
} // namespace InOrderPatchCommandHelpers
template <typename GfxFamily>
using InOrderPatchCommandsContainer = std::vector<InOrderPatchCommandHelpers::PatchCmd<GfxFamily>>;
} // namespace L0

View File

@@ -186,7 +186,9 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenNotEnoughSpaceInCommandStreamWhenA
NEO::EncodeDispatchKernelArgs dispatchKernelArgs{
0, // eventAddress
0, // postSyncImmValue
0, // inOrderCounterValue
device->getNEODevice(), // device
nullptr, // inOrderExecInfo
kernel.get(), // dispatchInterface
nullptr, // surfaceStateHeap
nullptr, // dynamicStateHeap

View File

@@ -637,7 +637,9 @@ HWTEST2_F(CommandListAppendLaunchKernel, givenNotEnoughSpaceInCommandStreamWhenA
NEO::EncodeDispatchKernelArgs dispatchKernelArgs{
0, // eventAddress
0, // postSyncImmValue
0, // inOrderCounterValue
device->getNEODevice(), // device
nullptr, // inOrderExecInfo
kernel.get(), // dispatchInterface
nullptr, // surfaceStateHeap
nullptr, // dynamicStateHeap
@@ -2628,11 +2630,11 @@ HWTEST2_F(InOrderCmdListTests, givenEmptyTempAllocationsStorageWhenCallingSynchr
using NonPostSyncWalkerMatcher = IsWithinGfxCore<IGFX_GEN9_CORE, IGFX_GEN12LP_CORE>;
HWTEST2_F(InOrderCmdListTests, givenNonPostSyncWalkerWhenPatchingThenThrow, NonPostSyncWalkerMatcher) {
InOrderPatchCommandHelpers::PatchCmd<FamilyType> incorrectCmd(nullptr, nullptr, nullptr, 1, InOrderPatchCommandHelpers::PatchCmdType::None);
InOrderPatchCommandHelpers::PatchCmd<FamilyType> incorrectCmd(nullptr, nullptr, nullptr, 1, NEO::InOrderPatchCommandHelpers::PatchCmdType::None);
EXPECT_ANY_THROW(incorrectCmd.patch(1));
InOrderPatchCommandHelpers::PatchCmd<FamilyType> walkerCmd(nullptr, nullptr, nullptr, 1, InOrderPatchCommandHelpers::PatchCmdType::Walker);
InOrderPatchCommandHelpers::PatchCmd<FamilyType> walkerCmd(nullptr, nullptr, nullptr, 1, NEO::InOrderPatchCommandHelpers::PatchCmdType::Walker);
EXPECT_ANY_THROW(walkerCmd.patch(1));
}
@@ -3022,9 +3024,9 @@ HWTEST2_F(InOrderCmdListTests, givenImmediateEventWhenWaitingFromRegularCmdListT
ASSERT_EQ(1u, regularCmdList->inOrderPatchCmds.size());
if (NonPostSyncWalkerMatcher::isMatched<productFamily>()) {
EXPECT_EQ(InOrderPatchCommandHelpers::PatchCmdType::Sdi, regularCmdList->inOrderPatchCmds[0].patchCmdType);
EXPECT_EQ(NEO::InOrderPatchCommandHelpers::PatchCmdType::Sdi, regularCmdList->inOrderPatchCmds[0].patchCmdType);
} else {
EXPECT_EQ(InOrderPatchCommandHelpers::PatchCmdType::Walker, regularCmdList->inOrderPatchCmds[0].patchCmdType);
EXPECT_EQ(NEO::InOrderPatchCommandHelpers::PatchCmdType::Walker, regularCmdList->inOrderPatchCmds[0].patchCmdType);
}
GenCmdList cmdList;

View File

@@ -3274,7 +3274,7 @@ HWTEST_F(EventTests, givenInOrderEventWhenHostSynchronizeIsCalledThenAllocationI
auto syncAllocation = new NEO::MockGraphicsAllocation(&storage, sizeof(storage));
auto inOrderExecInfo = std::make_shared<InOrderExecInfo>(*syncAllocation, nullptr, *neoDevice->getMemoryManager(), 1, false, false);
auto inOrderExecInfo = std::make_shared<NEO::InOrderExecInfo>(*syncAllocation, nullptr, *neoDevice->getMemoryManager(), 1, false, false);
*inOrderExecInfo->getBaseHostAddress() = 1;
event->enableCounterBasedMode(true);
@@ -3330,7 +3330,7 @@ HWTEST_F(EventTests, givenInOrderEventWithHostAllocWhenHostSynchronizeIsCalledTh
auto deviceSyncAllocation = new NEO::MockGraphicsAllocation(&storage1, sizeof(storage1));
auto hostSyncAllocation = new NEO::MockGraphicsAllocation(&storage2, sizeof(storage2));
auto inOrderExecInfo = std::make_shared<InOrderExecInfo>(*deviceSyncAllocation, hostSyncAllocation, *neoDevice->getMemoryManager(), 1, false, false);
auto inOrderExecInfo = std::make_shared<NEO::InOrderExecInfo>(*deviceSyncAllocation, hostSyncAllocation, *neoDevice->getMemoryManager(), 1, false, false);
*inOrderExecInfo->getBaseHostAddress() = 1;
event->enableCounterBasedMode(true);