feature: add debug flag to control graph patch preamble

Related-To: NEO-16434

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2025-10-21 10:06:44 +00:00
committed by Compute-Runtime-Automation
parent 8d8404f59b
commit f2c38ee012
6 changed files with 27 additions and 5 deletions

View File

@@ -1026,7 +1026,8 @@ TEST_F(GraphTestInstantiationTest, WhenInstantiatingGraphThenBakeCommandsIntoCom
EXPECT_EQ(ZE_RESULT_SUCCESS, zeCommandListEndGraphCaptureExp(immCmdListHandle, &srcGraphHandle, nullptr));
ctx.cmdListsToReturn.push_back(new Mock<CommandList>());
ExecutableGraph execGraph;
MockExecutableGraph execGraph;
EXPECT_TRUE(execGraph.usePatchingPreamble);
auto *graphHwCommands = ctx.cmdListsToReturn[0];
EXPECT_EQ(0U, graphHwCommands->appendBarrierCalled);
@@ -1082,6 +1083,16 @@ TEST_F(GraphTestInstantiationTest, WhenInstantiatingGraphThenBakeCommandsIntoCom
EXPECT_EQ(2U, graphHwCommands->appendLaunchKernelWithParametersCalled); // +1 for zeCommandListAppendLaunchKernelWithArguments
}
TEST_F(GraphTestInstantiationTest, GivenGraphPatchPreambleDebugFlagWhenInstantiatingGraphThenUseDebugSettingForPatchPreamble) {
GraphsCleanupGuard graphCleanup;
DebugManagerStateRestore restorer;
debugManager.flags.ForceDisableGraphPatchPreamble.set(1);
MockExecutableGraph execGraph;
EXPECT_FALSE(execGraph.usePatchingPreamble);
}
TEST_F(GraphTestInstantiationTest, givenInOrderCmdListAndRegularCbEventWhenInstantiateToGraphThenDoNotRecordExternalCbEvent) {
GraphsCleanupGuard graphCleanup;

View File

@@ -24,6 +24,7 @@ struct MockExecutableGraph : ExecutableGraph {
using ExecutableGraph::multiEngineGraph;
using ExecutableGraph::myCommandLists;
using ExecutableGraph::submissionChain;
using ExecutableGraph::usePatchingPreamble;
};
} // namespace ult

View File

@@ -7,6 +7,7 @@
#include "level_zero/experimental/source/graph/graph.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "level_zero/core/source/cmdlist/cmdlist.h"
@@ -375,6 +376,13 @@ ze_result_t Closure<CaptureApi::zeCommandListAppendLaunchKernelWithArguments>::i
return result;
}
ExecutableGraph::ExecutableGraph() {
int32_t overrideDisablePatchingPreamble = NEO::debugManager.flags.ForceDisableGraphPatchPreamble.get();
if (overrideDisablePatchingPreamble != -1) {
this->usePatchingPreamble = (overrideDisablePatchingPreamble == 0);
}
}
ExecutableGraph::~ExecutableGraph() = default;
L0::CommandList *ExecutableGraph::allocateAndAddCommandListSubmissionNode() {
@@ -494,7 +502,7 @@ ze_result_t ExecutableGraph::execute(L0::CommandList *executionTarget, void *pNe
auto currSignalEvent = (myLastCommandList == *cmdList) ? hSignalEvent : nullptr;
ze_command_list_handle_t hCmdList = *cmdList;
executionTarget->setPatchingPreamble(true, this->multiEngineGraph);
executionTarget->setPatchingPreamble(this->usePatchingPreamble, this->multiEngineGraph);
auto res = executionTarget->appendCommandLists(1, &hCmdList, currSignalEvent, numWaitEvents, phWaitEvents);
executionTarget->setPatchingPreamble(false, false);
if (ZE_RESULT_SUCCESS != res) {
@@ -506,7 +514,7 @@ ze_result_t ExecutableGraph::execute(L0::CommandList *executionTarget, void *pNe
if (L0::CommandList **cmdList = std::get_if<L0::CommandList *>(&this->submissionChain[submissioNodeId])) {
auto currSignalEvent = (myLastCommandList == *cmdList) ? hSignalEvent : nullptr;
ze_command_list_handle_t hCmdList = *cmdList;
executionTarget->setPatchingPreamble(true, this->multiEngineGraph);
executionTarget->setPatchingPreamble(this->usePatchingPreamble, this->multiEngineGraph);
auto res = executionTarget->appendCommandLists(1, &hCmdList, currSignalEvent, 0, nullptr);
executionTarget->setPatchingPreamble(false, false);
if (ZE_RESULT_SUCCESS != res) {

View File

@@ -251,8 +251,7 @@ struct GraphInstatiateSettings {
};
struct ExecutableGraph : _ze_executable_graph_handle_t {
ExecutableGraph() {
}
ExecutableGraph();
ze_result_t instantiateFrom(Graph &graph, const GraphInstatiateSettings &settings);
ze_result_t instantiateFrom(Graph &graph) {
@@ -297,6 +296,7 @@ struct ExecutableGraph : _ze_executable_graph_handle_t {
GraphSubmissionChain submissionChain;
bool multiEngineGraph = false;
bool usePatchingPreamble = true;
};
constexpr size_t maxVariantSize = 2 * 64;

View File

@@ -320,6 +320,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideCopyOffloadMode, -1, "-1: default, 0: di
DECLARE_DEBUG_VARIABLE(int32_t, UseSingleListForTemporaryAllocations, -1, "-1: default, 0: disabled, 0: enabled. If enabled, use single list, instead of per CSR for tracking temporary allocations")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideMaxMemAllocSizeMb, -1, "-1: default, >=0 override reported max mem alloc size in MB")
DECLARE_DEBUG_VARIABLE(int32_t, DetectIncorrectPointersOnSetArgCalls, -1, "-1: default do not detect, 0: do not detect, 1: detect incorrect pointers and return error")
DECLARE_DEBUG_VARIABLE(int32_t, ForceDisableGraphPatchPreamble, -1, "-1: default, 0: enable patch preamble, 1: disable graph patch preamble. If disabled, do not patch preamble graph internal command lists")
/*LOGGING FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")

View File

@@ -207,6 +207,7 @@ ReturnRawGpuTimestamps = 0
EnableDeviceBasedTimestamps = 1
MaxHwThreadsPercent = 0
MinHwThreadsUnoccupied = 0
ForceDisableGraphPatchPreamble = -1
LimitBlitterMaxWidth = -1
LimitBlitterMaxHeight = -1
LimitBlitterMaxSetWidth = -1