Skip to content

Commit 718e414

Browse files
Add enable-kernel-debug option when debugger is used in L0
- correctly verify debug capabilites in Module Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
1 parent 12669e8 commit 718e414

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
107107
statePreemption = devicePreemption;
108108

109109
if (NEO::Debugger::isDebugEnabled(internalUsage) && !commandQueueDebugCmdsProgrammed) {
110-
debuggerCmdsSize += NEO::PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(neoDevice->isDebuggerActive());
110+
debuggerCmdsSize += NEO::PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(neoDevice->getSourceLevelDebugger() != nullptr);
111111
}
112112

113113
if (devicePreemption == NEO::PreemptionMode::MidThread) {
@@ -227,7 +227,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
227227
programPipelineSelect(child);
228228
}
229229

230-
if (NEO::Debugger::isDebugEnabled(internalUsage) && !commandQueueDebugCmdsProgrammed && neoDevice->isDebuggerActive()) {
230+
if (NEO::Debugger::isDebugEnabled(internalUsage) && !commandQueueDebugCmdsProgrammed && neoDevice->getSourceLevelDebugger()) {
231231
NEO::PreambleHelper<GfxFamily>::programKernelDebugging(&child);
232232
commandQueueDebugCmdsProgrammed = true;
233233
}

level_zero/core/source/device/device_imp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
584584
device->getBuiltinFunctionsLib()->initImageFunctions();
585585
}
586586
auto hwInfo = neoDevice->getHardwareInfo();
587-
if (neoDevice->getPreemptionMode() == NEO::PreemptionMode::MidThread || neoDevice->isDebuggerActive()) {
588-
auto sipType = NEO::SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, neoDevice->isDebuggerActive());
587+
if (neoDevice->getPreemptionMode() == NEO::PreemptionMode::MidThread || neoDevice->getDebugger()) {
588+
auto sipType = NEO::SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, neoDevice->getDebugger());
589589
NEO::initSipKernel(sipType, *neoDevice);
590590
}
591591
}

level_zero/core/source/module/module_imp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ bool ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize
9191
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, BuildOptions::debugKernelEnable);
9292
}
9393

94+
if (device->getL0Debugger()) {
95+
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, BuildOptions::debugKernelEnable);
96+
}
97+
9498
if (NEO::DebugManager.flags.DisableStatelessToStatefulOptimization.get()) {
9599
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired);
96100
}
@@ -349,7 +353,7 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
349353
verifyDebugCapabilities();
350354

351355
this->updateBuildLog(neoDevice);
352-
if (debugEnabled) {
356+
if (debugEnabled && device->getSourceLevelDebugger()) {
353357
for (auto kernelInfo : this->translationUnit->programInfo.kernelInfos) {
354358
device->getSourceLevelDebugger()->notifyKernelDebugData(kernelInfo->kernelDescriptor.external.debugData.get(),
355359
kernelInfo->kernelDescriptor.kernelMetadata.kernelName,
@@ -589,7 +593,7 @@ bool ModuleImp::isDebugEnabled() const {
589593
}
590594

591595
void ModuleImp::verifyDebugCapabilities() {
592-
bool debugCapabilities = device->getNEODevice()->isDebuggerActive();
596+
bool debugCapabilities = device->getNEODevice()->getDebugger() != nullptr;
593597

594598
if (debugCapabilities) {
595599
//verify all kernels are debuggable

level_zero/core/test/unit_tests/sources/debugger/test_module_with_debug.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
1717
#include "level_zero/core/test/unit_tests/mocks/mock_l0_debugger.h"
1818
#include "level_zero/core/test/unit_tests/mocks/mock_module.h"
19+
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
1920

2021
#include "active_debugger_fixture.h"
2122

@@ -169,5 +170,29 @@ HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKerne
169170
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, debugSurfaceState->getCoherencyType());
170171
}
171172

173+
using ModuleWithDebuggerL0Test = Test<L0DebuggerHwFixture>;
174+
TEST_F(ModuleWithDebuggerL0Test, givenDebuggingEnabledWhenModuleIsCreatedThenDebugOptionsAreUsed) {
175+
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
176+
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
177+
178+
uint8_t binary[10];
179+
ze_module_desc_t moduleDesc = {};
180+
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
181+
moduleDesc.pInputModule = binary;
182+
moduleDesc.inputSize = 10;
183+
184+
ModuleBuildLog *moduleBuildLog = nullptr;
185+
186+
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, moduleBuildLog, ModuleType::User));
187+
ASSERT_NE(nullptr, module.get());
188+
module->initialize(&moduleDesc, neoDevice);
189+
190+
EXPECT_TRUE(module->isDebugEnabled());
191+
192+
EXPECT_TRUE(CompilerOptions::contains(cip->buildInternalOptions, L0::BuildOptions::debugKernelEnable));
193+
EXPECT_FALSE(CompilerOptions::contains(cip->buildOptions, NEO::CompilerOptions::generateDebugInfo));
194+
EXPECT_FALSE(CompilerOptions::contains(cip->buildOptions, L0::BuildOptions::optDisable));
195+
};
196+
172197
} // namespace ult
173198
} // namespace L0

0 commit comments

Comments
 (0)