mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
L0Debug fixes for multi tile devices
- notify module allocation for (sub)device used to create module, makeResident called within (sub)device contexts - access ISA with vmHandle specific to device index Related-To: NEO-5784 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
9f2cfc6f9d
commit
ee8af85341
@ -613,7 +613,7 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
||||
|
||||
if (device->getL0Debugger()) {
|
||||
auto allocs = getModuleAllocations();
|
||||
device->getL0Debugger()->notifyModuleLoadAllocations(allocs);
|
||||
device->getL0Debugger()->notifyModuleLoadAllocations(device->getNEODevice(), allocs);
|
||||
notifyModuleCreate();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/core/source/module/module_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_module.h"
|
||||
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
|
||||
@ -419,6 +420,59 @@ TEST_F(KernelInitializeTest, givenDebuggingEnabledWhenKernelsAreInitializedThenA
|
||||
EXPECT_NE(0, memcmp(isa, &kernelHeap, sizeof(kernelHeap)));
|
||||
};
|
||||
|
||||
using ModuleWithDebuggerL0MultiTileTest = Test<SingleRootMultiSubDeviceFixture>;
|
||||
|
||||
HWTEST_F(ModuleWithDebuggerL0MultiTileTest, GivenSubDeviceWhenCreatingModuleThenModuleCreateIsNotifiedWithCorrectDevice) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
neoDevice->getExecutionEnvironment()->setDebuggingEnabled();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->initDebuggerL0(neoDevice);
|
||||
auto memoryOperationsHandler = new NEO::MockMemoryOperations();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->memoryOperationsInterface.reset(memoryOperationsHandler);
|
||||
|
||||
auto subDevice0 = neoDevice->getSubDevice(0)->getSpecializedDevice<Device>();
|
||||
|
||||
uint8_t binary[10];
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
|
||||
moduleDesc.pInputModule = binary;
|
||||
moduleDesc.inputSize = 10;
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
std::unique_ptr<MockModule> moduleMock = std::make_unique<MockModule>(subDevice0, moduleBuildLog, ModuleType::User);
|
||||
moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(subDevice0);
|
||||
|
||||
uint32_t kernelHeap = 0;
|
||||
auto kernelInfo = new KernelInfo();
|
||||
kernelInfo->heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo->heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
Mock<::L0::Kernel> kernelMock;
|
||||
kernelMock.module = moduleMock.get();
|
||||
kernelMock.immutableData.kernelInfo = kernelInfo;
|
||||
kernelInfo->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = 0;
|
||||
|
||||
moduleMock->kernelImmData = &kernelMock.immutableData;
|
||||
moduleMock->translationUnit->programInfo.kernelInfos.push_back(kernelInfo);
|
||||
|
||||
kernelInfo->kernelDescriptor.external.debugData = std::make_unique<NEO::DebugData>();
|
||||
|
||||
auto debugData = MockElfEncoder<>::createRelocateableDebugDataElf();
|
||||
kernelInfo->kernelDescriptor.external.debugData->vIsaSize = static_cast<uint32_t>(debugData.size());
|
||||
kernelInfo->kernelDescriptor.external.debugData->vIsa = reinterpret_cast<char *>(debugData.data());
|
||||
kernelInfo->kernelDescriptor.external.debugData->genIsa = nullptr;
|
||||
kernelInfo->kernelDescriptor.external.debugData->genIsaSize = 0;
|
||||
|
||||
EXPECT_TRUE(moduleMock->initialize(&moduleDesc, subDevice0->getNEODevice()));
|
||||
|
||||
auto debuggerL0Hw = static_cast<MockDebuggerL0Hw<FamilyType> *>(device->getL0Debugger());
|
||||
EXPECT_EQ(1u, debuggerL0Hw->notifyModuleCreateCount);
|
||||
EXPECT_EQ(subDevice0->getNEODevice(), debuggerL0Hw->notifyModuleLoadAllocationsCapturedDevice);
|
||||
|
||||
EXPECT_EQ(1, memoryOperationsHandler->makeResidentCalledCount);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleWithDebuggerL0Test, GivenDebugDataWithRelocationsWhenInitializingModuleThenRegisterElfWithRelocatedElfAndModuleCreateNotified) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
|
@ -1285,9 +1285,9 @@ ze_result_t DebugSessionLinux::interruptImp(uint32_t deviceIndex) {
|
||||
return result == 0 ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t DebugSessionLinux::getISAVMHandle(const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle) {
|
||||
ze_result_t DebugSessionLinux::getISAVMHandle(uint32_t deviceIndex, const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle) {
|
||||
auto accessVA = desc->address;
|
||||
auto &isaMap = clientHandleToConnection[clientHandle]->isaMap[0];
|
||||
auto &isaMap = clientHandleToConnection[clientHandle]->isaMap[deviceIndex];
|
||||
ze_result_t status = ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
vmHandle = invalidHandle;
|
||||
|
||||
@ -1450,7 +1450,7 @@ bool DebugSessionLinux::tryAccessIsa(uint32_t deviceIndex, const zet_debug_memor
|
||||
{
|
||||
std::lock_guard<std::mutex> memLock(asyncThreadMutex);
|
||||
|
||||
status = getISAVMHandle(desc, size, vmHandle);
|
||||
status = getISAVMHandle(deviceIndex, desc, size, vmHandle);
|
||||
if (status == ZE_RESULT_SUCCESS) {
|
||||
isaAccess = true;
|
||||
} else if (status == ZE_RESULT_ERROR_INVALID_ARGUMENT) {
|
||||
|
@ -252,7 +252,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
|
||||
ze_result_t readGpuMemory(uint64_t vmHandle, char *output, size_t size, uint64_t gpuVa) override;
|
||||
ze_result_t writeGpuMemory(uint64_t vmHandle, const char *input, size_t size, uint64_t gpuVa) override;
|
||||
ze_result_t getISAVMHandle(const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle);
|
||||
ze_result_t getISAVMHandle(uint32_t deviceIndex, const zet_debug_memory_space_desc_t *desc, size_t size, uint64_t &vmHandle);
|
||||
ze_result_t getElfOffset(const zet_debug_memory_space_desc_t *desc, size_t size, const char *&elfData, uint64_t &offset);
|
||||
ze_result_t readElfSpace(const zet_debug_memory_space_desc_t *desc, size_t size, void *buffer,
|
||||
const char *&elfData, const uint64_t offset);
|
||||
|
@ -494,7 +494,7 @@ TEST_F(TileAttachTest, GivenTileAndVmBindEventsForIsaWhenReadingEventThenModuleL
|
||||
TEST_F(TileAttachTest, GivenIsaWhenReadingOrWritingMemoryThenMemoryIsReadAndWritten) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
zet_debug_session_handle_t debugSession0 = nullptr;
|
||||
zet_debug_session_handle_t debugSession0 = nullptr, debugSession1 = nullptr;
|
||||
|
||||
zetDebugAttach(neoDevice->getSubDevice(0)->getSpecializedDevice<L0::Device>()->toHandle(), &config, &debugSession0);
|
||||
|
||||
@ -516,6 +516,7 @@ TEST_F(TileAttachTest, GivenIsaWhenReadingOrWritingMemoryThenMemoryIsReadAndWrit
|
||||
ze_result_t result = zetDebugReadMemory(tileSessions[0]->toHandle(), thread, &desc, bufferSize, &output);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(vm0, handler->vmOpen.handle);
|
||||
|
||||
for (int i = 0; i < bufferSize; i++) {
|
||||
EXPECT_EQ(static_cast<char>(0xaa), output[i]);
|
||||
@ -527,6 +528,16 @@ TEST_F(TileAttachTest, GivenIsaWhenReadingOrWritingMemoryThenMemoryIsReadAndWrit
|
||||
result = zetDebugWriteMemory(tileSessions[0]->toHandle(), thread, &desc, bufferSize, &output);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(1u, handler->pwriteCalled);
|
||||
EXPECT_EQ(vm0, handler->vmOpen.handle);
|
||||
|
||||
zetDebugAttach(neoDevice->getSubDevice(0)->getSpecializedDevice<L0::Device>()->toHandle(), &config, &debugSession1);
|
||||
addIsaVmBindEvent(rootSession, vm1, true, true);
|
||||
handler->preadCalled = 0;
|
||||
|
||||
result = zetDebugReadMemory(tileSessions[1]->toHandle(), thread, &desc, bufferSize, &output);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(vm1, handler->vmOpen.handle);
|
||||
EXPECT_EQ(1u, handler->preadCalled);
|
||||
}
|
||||
|
||||
TEST_F(TileAttachTest, GivenElfAddressWhenReadMemoryCalledTheElfMemoryIsRead) {
|
||||
|
@ -136,7 +136,7 @@ void DebuggerL0::captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddres
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerL0::notifyModuleLoadAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs) {
|
||||
void DebuggerL0::notifyModuleLoadAllocations(Device *device, const StackVec<NEO::GraphicsAllocation *, 32> &allocs) {
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = device->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
if (memoryOperationsIface) {
|
||||
for (auto gfxAlloc : allocs) {
|
||||
|
@ -94,7 +94,7 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
|
||||
MOCKABLE_VIRTUAL void registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation);
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueCreated(NEO::Device *device);
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueDestroyed(NEO::Device *device);
|
||||
MOCKABLE_VIRTUAL void notifyModuleLoadAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs);
|
||||
MOCKABLE_VIRTUAL void notifyModuleLoadAllocations(Device *device, const StackVec<NEO::GraphicsAllocation *, 32> &allocs);
|
||||
MOCKABLE_VIRTUAL void notifyModuleCreate(void *module, uint32_t moduleSize, uint64_t moduleLoadAddress);
|
||||
MOCKABLE_VIRTUAL void notifyModuleDestroy(uint64_t moduleLoadAddress);
|
||||
MOCKABLE_VIRTUAL void registerAllocationType(GraphicsAllocation *allocation);
|
||||
|
@ -106,6 +106,11 @@ class MockDebuggerL0Hw : public NEO::DebuggerL0Hw<GfxFamily> {
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyModuleDestroy(moduleLoadAddress);
|
||||
}
|
||||
|
||||
void notifyModuleLoadAllocations(NEO::Device *device, const StackVec<NEO::GraphicsAllocation *, 32> &allocs) override {
|
||||
notifyModuleLoadAllocationsCapturedDevice = device;
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyModuleLoadAllocations(device, allocs);
|
||||
}
|
||||
|
||||
uint32_t captureStateBaseAddressCount = 0;
|
||||
uint32_t programSbaTrackingCommandsCount = 0;
|
||||
uint32_t getSbaTrackingCommandsSizeCount = 0;
|
||||
@ -120,6 +125,7 @@ class MockDebuggerL0Hw : public NEO::DebuggerL0Hw<GfxFamily> {
|
||||
uint32_t segmentCountWithAttachedModuleHandle = 0;
|
||||
uint32_t removedZebinModuleHandle = 0;
|
||||
uint32_t moduleHandleToReturn = std::numeric_limits<uint32_t>::max();
|
||||
NEO::Device *notifyModuleLoadAllocationsCapturedDevice = nullptr;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -218,7 +218,7 @@ HWTEST_F(L0DebuggerTest, givenDebuggerWithoutMemoryOperationsHandlerWhenNotifyin
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
allocs.push_back(&alloc);
|
||||
|
||||
debugger->notifyModuleLoadAllocations(allocs);
|
||||
debugger->notifyModuleLoadAllocations(pDevice, allocs);
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerTest, givenDebuggerWhenCreatedThenModuleHeapDebugAreaIsCreated) {
|
||||
|
Reference in New Issue
Block a user