fix: change getBindlessDebugSipKernel to also get heapless sip

Rename function to getDebugSipKernel and select either bindless
or heapless depending on mode

Related-to: NEO-8396

Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
Brandon Yates
2024-10-01 20:53:41 +00:00
committed by Compute-Runtime-Automation
parent 0e2b400554
commit 013c49db02
7 changed files with 77 additions and 29 deletions

View File

@@ -1268,7 +1268,7 @@ ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pD
ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) { ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) {
bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable(); bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable();
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*this->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*this->getNEODevice()).getStateSaveAreaHeader();
if (stateSaveAreaHeader.size() == 0) { if (stateSaveAreaHeader.size() == 0) {
PRINT_DEBUGGER_INFO_LOG("Context state save area header missing", ""); PRINT_DEBUGGER_INFO_LOG("Context state save area header missing", "");

View File

@@ -1109,7 +1109,7 @@ const SIP::regset_desc *DebugSessionImp::typeToRegsetDesc(uint32_t type) {
case ZET_DEBUG_REGSET_TYPE_MSG_INTEL_GPU: case ZET_DEBUG_REGSET_TYPE_MSG_INTEL_GPU:
return &pStateSaveAreaHeader->regHeaderV3.msg; return &pStateSaveAreaHeader->regHeaderV3.msg;
case ZET_DEBUG_REGSET_TYPE_SBA_INTEL_GPU: { case ZET_DEBUG_REGSET_TYPE_SBA_INTEL_GPU: {
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader();
auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data()); auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
return DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea); return DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea);
} }
@@ -1143,7 +1143,7 @@ const SIP::regset_desc *DebugSessionImp::typeToRegsetDesc(uint32_t type) {
case ZET_DEBUG_REGSET_TYPE_FC_INTEL_GPU: case ZET_DEBUG_REGSET_TYPE_FC_INTEL_GPU:
return &pStateSaveAreaHeader->regHeader.fc; return &pStateSaveAreaHeader->regHeader.fc;
case ZET_DEBUG_REGSET_TYPE_SBA_INTEL_GPU: { case ZET_DEBUG_REGSET_TYPE_SBA_INTEL_GPU: {
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader();
auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data()); auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
return DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea); return DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea);
} }
@@ -1207,7 +1207,7 @@ ze_result_t DebugSessionImp::readModeFlags(uint32_t start, uint32_t count, void
if (start != 0 || count != 1) { if (start != 0 || count != 1) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT; return ZE_RESULT_ERROR_INVALID_ARGUMENT;
} }
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader();
auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data()); auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
const size_t size = 4; const size_t size = 4;
memcpy_s(pRegisterValues, size, &pStateSaveArea->regHeaderV3.sip_flags, size); memcpy_s(pRegisterValues, size, &pStateSaveArea->regHeaderV3.sip_flags, size);
@@ -1239,7 +1239,7 @@ ze_result_t DebugSessionImp::readDebugScratchRegisters(uint32_t start, uint32_t
ze_result_t DebugSessionImp::readSbaRegisters(EuThread::ThreadId threadId, uint32_t start, uint32_t count, void *pRegisterValues) { ze_result_t DebugSessionImp::readSbaRegisters(EuThread::ThreadId threadId, uint32_t start, uint32_t count, void *pRegisterValues) {
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*connectedDevice->getNEODevice()).getStateSaveAreaHeader();
auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data()); auto pStateSaveArea = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
auto sbaRegDesc = DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea); auto sbaRegDesc = DebugSessionImp::getSbaRegsetDesc(*pStateSaveArea);
@@ -1391,7 +1391,7 @@ ze_result_t DebugSession::getRegisterSetProperties(Device *device, uint32_t *pCo
return ZE_RESULT_ERROR_INVALID_NULL_POINTER; return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
} }
auto &stateSaveAreaHeader = NEO::SipKernel::getBindlessDebugSipKernel(*device->getNEODevice()).getStateSaveAreaHeader(); auto &stateSaveAreaHeader = NEO::SipKernel::getDebugSipKernel(*device->getNEODevice()).getStateSaveAreaHeader();
if (stateSaveAreaHeader.size() == 0) { if (stateSaveAreaHeader.size() == 0) {
*pCount = 0; *pCount = 0;

View File

@@ -304,8 +304,14 @@ const SipKernel &SipKernel::getSipKernelImpl(Device &device) {
} }
} }
const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device) { const SipKernel &SipKernel::getDebugSipKernel(Device &device) {
auto debugSipType = SipKernelType::dbgBindless; SipKernelType debugSipType;
auto &compilerProductHelper = device.getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
if (compilerProductHelper.isHeaplessModeEnabled()) {
debugSipType = SipKernelType::dbgHeapless;
} else {
debugSipType = SipKernelType::dbgBindless;
}
SipKernel::initSipKernelImpl(debugSipType, device, nullptr); SipKernel::initSipKernelImpl(debugSipType, device, nullptr);
switch (SipKernel::classType) { switch (SipKernel::classType) {
@@ -316,8 +322,14 @@ const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device) {
} }
} }
const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device, OsContext *context) { const SipKernel &SipKernel::getDebugSipKernel(Device &device, OsContext *context) {
auto debugSipType = SipKernelType::dbgBindless; SipKernelType debugSipType;
auto &compilerProductHelper = device.getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
if (compilerProductHelper.isHeaplessModeEnabled()) {
debugSipType = SipKernelType::dbgHeapless;
} else {
debugSipType = SipKernelType::dbgBindless;
}
SipKernel::initSipKernelImpl(debugSipType, device, context); SipKernel::initSipKernelImpl(debugSipType, device, context);
switch (SipKernel::classType) { switch (SipKernel::classType) {

View File

@@ -55,8 +55,8 @@ class SipKernel {
static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager); static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager);
static const SipKernel &getSipKernel(Device &device, OsContext *context); static const SipKernel &getSipKernel(Device &device, OsContext *context);
static const SipKernel &getBindlessDebugSipKernel(Device &device); static const SipKernel &getDebugSipKernel(Device &device);
static const SipKernel &getBindlessDebugSipKernel(Device &device, OsContext *context); static const SipKernel &getDebugSipKernel(Device &device, OsContext *context);
static SipKernelType getSipKernelType(Device &device); static SipKernelType getSipKernelType(Device &device);
static SipKernelType getSipKernelType(Device &device, bool debuggingEnable); static SipKernelType getSipKernelType(Device &device, bool debuggingEnable);
static SipClassType classType; static SipClassType classType;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021-2023 Intel Corporation * Copyright (C) 2021-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -17,7 +17,7 @@ bool SipKernel::initSipKernel(SipKernelType type, Device &device) {
const SipKernel &SipKernel::getSipKernel(Device &device, OsContext *context) { const SipKernel &SipKernel::getSipKernel(Device &device, OsContext *context) {
if (context && device.getExecutionEnvironment()->getDebuggingMode() == NEO::DebuggingMode::offline) { if (context && device.getExecutionEnvironment()->getDebuggingMode() == NEO::DebuggingMode::offline) {
return SipKernel::getBindlessDebugSipKernel(device, context); return SipKernel::getDebugSipKernel(device, context);
} else { } else {
return SipKernel::getSipKernelImpl(device); return SipKernel::getSipKernelImpl(device);
} }

View File

@@ -251,7 +251,7 @@ const SipKernel &SipKernel::getSipKernel(Device &device, OsContext *context) {
return *MockSipData::mockSipKernel.get(); return *MockSipData::mockSipKernel.get();
} else { } else {
if (context && device.getExecutionEnvironment()->getDebuggingMode() == NEO::DebuggingMode::offline) { if (context && device.getExecutionEnvironment()->getDebuggingMode() == NEO::DebuggingMode::offline) {
return SipKernel::getBindlessDebugSipKernel(device, context); return SipKernel::getDebugSipKernel(device, context);
} }
auto sipType = SipKernel::getSipKernelType(device); auto sipType = SipKernel::getSipKernelType(device);
SipKernel::initSipKernel(sipType, device); SipKernel::initSipKernel(sipType, device);

View File

@@ -289,9 +289,34 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenInitSipKernelTwiceThenSipIsLoaded
EXPECT_EQ(storedAllocation, secondStoredAllocation); EXPECT_EQ(storedAllocation, secondStoredAllocation);
} }
TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipThenSipIsLoadedFromFile) { TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingHeaplessDebugSipThenSipIsLoadedFromFile) {
auto sipAllocation = SipKernel::getBindlessDebugSipKernel(*pDevice).getSipAllocation();
auto compilerHelper = std::unique_ptr<MockCompilerProductHelper>(new MockCompilerProductHelper());
auto releaseHelper = std::unique_ptr<MockReleaseHelper>(new MockReleaseHelper());
compilerHelper->isHeaplessModeEnabledResult = true;
pDevice->getRootDeviceEnvironmentRef().compilerProductHelper.reset(compilerHelper.release());
pDevice->getRootDeviceEnvironmentRef().releaseHelper.reset(releaseHelper.release());
auto sipAllocation = SipKernel::getDebugSipKernel(*pDevice).getSipAllocation();
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::dbgHeapless);
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, sipKernel);
auto storedAllocation = sipKernel->getSipAllocation();
EXPECT_NE(nullptr, storedAllocation);
EXPECT_EQ(storedAllocation, sipAllocation);
auto header = SipKernel::getSipKernel(*pDevice, nullptr).getStateSaveAreaHeader();
EXPECT_NE(0u, header.size());
}
TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipThenSipIsLoadedFromFile) {
auto compilerHelper = std::unique_ptr<MockCompilerProductHelper>(new MockCompilerProductHelper());
auto releaseHelper = std::unique_ptr<MockReleaseHelper>(new MockReleaseHelper());
compilerHelper->isHeaplessModeEnabledResult = false;
pDevice->getRootDeviceEnvironmentRef().compilerProductHelper.reset(compilerHelper.release());
pDevice->getRootDeviceEnvironmentRef().releaseHelper.reset(releaseHelper.release());
auto sipAllocation = SipKernel::getDebugSipKernel(*pDevice).getSipAllocation();
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::dbgBindless); uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::dbgBindless);
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get(); auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, sipKernel); ASSERT_NE(nullptr, sipKernel);
@@ -304,7 +329,7 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipThenSipIsL
EXPECT_NE(0u, header.size()); EXPECT_NE(0u, header.size());
} }
TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipWithContextThenSipIsLoadedFromFile) { TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingDebugSipWithContextThenSipIsLoadedFromFile) {
auto executionEnvironment = pDevice->getExecutionEnvironment(); auto executionEnvironment = pDevice->getExecutionEnvironment();
const uint32_t contextId = 0u; const uint32_t contextId = 0u;
std::unique_ptr<OsContext> osContext(OsContext::create(executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(), std::unique_ptr<OsContext> osContext(OsContext::create(executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(),
@@ -312,9 +337,15 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipWithContex
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield())));
osContext->setDefaultContext(true); osContext->setDefaultContext(true);
auto sipAllocation = NEO::SipKernel::getBindlessDebugSipKernel(*pDevice, osContext.get()).getSipAllocation(); auto sipAllocation = NEO::SipKernel::getDebugSipKernel(*pDevice, osContext.get()).getSipAllocation();
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::dbgBindless); uint32_t sipIndex;
auto &compilerProductHelper = pDevice->getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
if (compilerProductHelper.isHeaplessModeEnabled()) {
sipIndex = static_cast<uint32_t>(SipKernelType::dbgHeapless);
} else {
sipIndex = static_cast<uint32_t>(SipKernelType::dbgBindless);
}
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get(); auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, sipKernel); ASSERT_NE(nullptr, sipKernel);
auto storedAllocation = sipKernel->getSipAllocation(); auto storedAllocation = sipKernel->getSipAllocation();
@@ -523,14 +554,19 @@ TEST(DebugSip, givenBuiltInsWhenDbgCsrSipIsRequestedThenCorrectSipKernelIsReturn
EXPECT_EQ(SipKernelType::dbgCsr, sipKernel.getType()); EXPECT_EQ(SipKernelType::dbgCsr, sipKernel.getType());
} }
TEST(DebugBindlessSip, givenBindlessDebugSipIsRequestedThenCorrectSipKernelIsReturned) { TEST(DebugSip, givenDebugSipIsRequestedThenCorrectSipKernelIsReturned) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice); auto &sipKernel = NEO::SipKernel::getDebugSipKernel(*mockDevice);
EXPECT_NE(nullptr, &sipKernel); EXPECT_NE(nullptr, &sipKernel);
EXPECT_EQ(SipKernelType::dbgBindless, sipKernel.getType()); auto &compilerProductHelper = mockDevice->getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
if (compilerProductHelper.isHeaplessModeEnabled()) {
EXPECT_EQ(SipKernelType::dbgHeapless, sipKernel.getType());
} else {
EXPECT_EQ(SipKernelType::dbgBindless, sipKernel.getType());
}
EXPECT_FALSE(sipKernel.getStateSaveAreaHeader().empty()); EXPECT_FALSE(sipKernel.getStateSaveAreaHeader().empty());
} }
@@ -553,7 +589,7 @@ TEST(DebugBindlessSip, givenContextWhenBindlessDebugSipIsRequestedThenCorrectSip
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, &csr->getOsContext()); auto &sipKernel = NEO::SipKernel::getDebugSipKernel(*mockDevice, &csr->getOsContext());
EXPECT_NE(nullptr, &sipKernel); EXPECT_NE(nullptr, &sipKernel);
auto contextSip = builtIns->perContextSipKernels[contextId].first.get(); auto contextSip = builtIns->perContextSipKernels[contextId].first.get();
@@ -614,8 +650,8 @@ TEST(DebugBindlessSip, givenTwoContextsWhenBindlessDebugSipIsRequestedThenEachSi
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, PreemptionMode::ThreadGroup, mockDevice->getDeviceBitfield()))); EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, PreemptionMode::ThreadGroup, mockDevice->getDeviceBitfield())));
osContext1->setDefaultContext(true); osContext1->setDefaultContext(true);
auto &sipKernel1 = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, osContext1.get()); auto &sipKernel1 = NEO::SipKernel::getDebugSipKernel(*mockDevice, osContext1.get());
auto &sipKernel0 = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, osContext0.get()); auto &sipKernel0 = NEO::SipKernel::getDebugSipKernel(*mockDevice, osContext0.get());
EXPECT_NE(sipKernel0.getSipAllocation(), sipKernel1.getSipAllocation()); EXPECT_NE(sipKernel0.getSipAllocation(), sipKernel1.getSipAllocation());
auto context0SipKernel = builtIns->perContextSipKernels[context0Id].first.get(); auto context0SipKernel = builtIns->perContextSipKernels[context0Id].first.get();
@@ -651,7 +687,7 @@ TEST(DebugBindlessSip, givenFailingSipAllocationWhenBindlessDebugSipWithContextI
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, &csr->getOsContext()); auto &sipKernel = NEO::SipKernel::getDebugSipKernel(*mockDevice, &csr->getOsContext());
EXPECT_NE(nullptr, &sipKernel); EXPECT_NE(nullptr, &sipKernel);
auto contextSip = builtIns->perContextSipKernels[contextId].first.get(); auto contextSip = builtIns->perContextSipKernels[contextId].first.get();
@@ -680,7 +716,7 @@ TEST(DebugBindlessSip, givenCorrectSipKernelWhenReleasingAllocationManuallyThenF
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
[[maybe_unused]] auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, &csr->getOsContext()); [[maybe_unused]] auto &sipKernel = NEO::SipKernel::getDebugSipKernel(*mockDevice, &csr->getOsContext());
mockDevice->getMemoryManager()->freeGraphicsMemory(builtIns->perContextSipKernels[contextId].first.get()->getSipAllocation()); mockDevice->getMemoryManager()->freeGraphicsMemory(builtIns->perContextSipKernels[contextId].first.get()->getSipAllocation());
builtIns->perContextSipKernels[contextId].first.reset(nullptr); builtIns->perContextSipKernels[contextId].first.reset(nullptr);
@@ -793,7 +829,7 @@ TEST(DebugBindlessSip, givenOfflineDebuggingModeWhenDebugSipForContextIsCreatedT
} }
builtIns->perContextSipKernels.erase(contextId); builtIns->perContextSipKernels.erase(contextId);
auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice, &csr->getOsContext()); auto &sipKernel = NEO::SipKernel::getDebugSipKernel(*mockDevice, &csr->getOsContext());
EXPECT_NE(nullptr, &sipKernel); EXPECT_NE(nullptr, &sipKernel);