Skip to content

Commit d9a4eee

Browse files
fix(zebin): fix module load/unload events while debugging
- do not trigger incorrect / spurious events from internal modules for debugger - do not register Elf for internal modules Related-To: NEO-7605 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com> Source: ee499d6
1 parent 4e9c10e commit d9a4eee

File tree

5 files changed

+274
-117
lines changed

5 files changed

+274
-117
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 Intel Corporation
2+
* Copyright (C) 2020-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -613,6 +613,7 @@ ze_result_t ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neo
613613
}
614614

615615
registerElfInDebuggerL0();
616+
616617
this->maxGroupSize = static_cast<uint32_t>(neoDevice->getDeviceInfo().maxWorkGroupSize);
617618

618619
checkIfPrivateMemoryPerDispatchIsNeeded();
@@ -1276,7 +1277,7 @@ ze_result_t ModuleImp::destroy() {
12761277
void ModuleImp::registerElfInDebuggerL0() {
12771278
auto debuggerL0 = device->getL0Debugger();
12781279

1279-
if (!debuggerL0) {
1280+
if (this->type != ModuleType::User || !debuggerL0) {
12801281
return;
12811282
}
12821283

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 Intel Corporation
2+
* Copyright (C) 2020-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -518,6 +518,48 @@ HWTEST_F(ModuleWithDebuggerL0Test, GivenDebugDataWithRelocationsWhenInitializing
518518
EXPECT_EQ(reinterpret_cast<char *>(kernelInfo->kernelDescriptor.external.relocatedDebugData.get()), getMockDebuggerL0Hw<FamilyType>()->lastReceivedElf);
519519
}
520520

521+
HWTEST_F(ModuleWithDebuggerL0Test, GivenBuiltinModuleWhenInitializingModuleThenModuleAndElfNOtificationsAreNotCalled) {
522+
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
523+
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
524+
525+
uint8_t binary[10];
526+
ze_module_desc_t moduleDesc = {};
527+
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
528+
moduleDesc.pInputModule = binary;
529+
moduleDesc.inputSize = 10;
530+
ModuleBuildLog *moduleBuildLog = nullptr;
531+
532+
std::unique_ptr<MockModule> moduleMock = std::make_unique<MockModule>(device, moduleBuildLog, ModuleType::Builtin);
533+
moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(device);
534+
535+
uint32_t kernelHeap = 0;
536+
auto kernelInfo = new KernelInfo();
537+
kernelInfo->heapInfo.KernelHeapSize = 1;
538+
kernelInfo->heapInfo.pKernelHeap = &kernelHeap;
539+
540+
Mock<::L0::Kernel> kernelMock;
541+
kernelMock.module = moduleMock.get();
542+
kernelMock.immutableData.kernelInfo = kernelInfo;
543+
kernelInfo->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = 0;
544+
moduleMock->kernelImmData = &kernelMock.immutableData;
545+
moduleMock->translationUnit->programInfo.kernelInfos.push_back(kernelInfo);
546+
kernelInfo->kernelDescriptor.external.debugData = std::make_unique<NEO::DebugData>();
547+
548+
auto debugData = MockElfEncoder<>::createRelocateableDebugDataElf();
549+
kernelInfo->kernelDescriptor.external.debugData->vIsaSize = static_cast<uint32_t>(debugData.size());
550+
kernelInfo->kernelDescriptor.external.debugData->vIsa = reinterpret_cast<char *>(debugData.data());
551+
kernelInfo->kernelDescriptor.external.debugData->genIsa = nullptr;
552+
kernelInfo->kernelDescriptor.external.debugData->genIsaSize = 0;
553+
554+
EXPECT_EQ(0u, getMockDebuggerL0Hw<FamilyType>()->registerElfCount);
555+
EXPECT_EQ(moduleMock->initialize(&moduleDesc, neoDevice), ZE_RESULT_SUCCESS);
556+
EXPECT_EQ(0u, getMockDebuggerL0Hw<FamilyType>()->registerElfAndLinkCount);
557+
EXPECT_EQ(0u, getMockDebuggerL0Hw<FamilyType>()->notifyModuleCreateCount);
558+
559+
EXPECT_NE(nullptr, kernelInfo->kernelDescriptor.external.relocatedDebugData.get());
560+
EXPECT_EQ(nullptr, getMockDebuggerL0Hw<FamilyType>()->lastReceivedElf);
561+
}
562+
521563
HWTEST_F(ModuleWithDebuggerL0Test, GivenDebugDataWithoutRelocationsWhenInitializingModuleThenRegisterElfWithUnrelocatedElfAndModuleCreateNotified) {
522564

523565
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();

0 commit comments

Comments
 (0)