Add new functionality to load SIP from file

Related-To: NEO-5718

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-04-16 12:52:30 +00:00
committed by Compute-Runtime-Automation
parent f83b51e628
commit 902cce597a
53 changed files with 534 additions and 211 deletions

View File

@@ -286,7 +286,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
}
if (sipKernelUsed) {
auto sipIsa = NEO::SipKernel::getSipKernelAllocation(*neoDevice);
auto sipIsa = NEO::SipKernel::getSipKernel(*neoDevice).getSipAllocation();
residencyContainer.push_back(sipIsa);
}

View File

@@ -14,7 +14,6 @@
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/built_ins_helper.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/engine_node_helper.h"
#include "shared/source/helpers/hw_helper.h"
@@ -646,10 +645,10 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
if (neoDevice->getCompilerInterface()) {
auto hwInfo = neoDevice->getHardwareInfo();
if (neoDevice->getPreemptionMode() == NEO::PreemptionMode::MidThread || neoDevice->getDebugger()) {
auto sipType = NEO::SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, neoDevice->getDebugger());
NEO::initSipKernel(sipType, *neoDevice);
bool ret = NEO::SipKernel::initSipKernel(NEO::SipKernel::getSipKernelType(*neoDevice), *neoDevice);
UNRECOVERABLE_IF(!ret);
auto stateSaveAreaHeader = NEO::SipKernel::getSipStateSaveAreaHeader(*neoDevice);
auto &stateSaveAreaHeader = NEO::SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
if (debugSurface && stateSaveAreaHeader.size() > 0) {
auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
NEO::MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *debugSurface),

View File

@@ -306,7 +306,7 @@ HWTEST_F(CommandQueueExecuteCommandLists, givenMidThreadPreemptionWhenCommandsAr
if (preemptionMode == NEO::PreemptionMode::MidThread) {
EXPECT_NE(cmdList.end(), itorSip);
auto sipAllocation = SipKernel::getSipKernelAllocation(*neoDevice);
auto sipAllocation = SipKernel::getSipKernel(*neoDevice).getSipAllocation();
STATE_SIP *stateSipCmd = reinterpret_cast<STATE_SIP *>(*itorSip);
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
} else {
@@ -361,7 +361,7 @@ HWTEST2_F(CommandQueueExecuteCommandLists, givenMidThreadPreemptionWhenCommandsA
if (preemptionMode == NEO::PreemptionMode::MidThread) {
EXPECT_NE(cmdList.end(), itorSip);
auto sipAllocation = SipKernel::getSipKernelAllocation(*neoDevice);
auto sipAllocation = SipKernel::getSipKernel(*neoDevice).getSipAllocation();
STATE_SIP *stateSipCmd = reinterpret_cast<STATE_SIP *>(*itorSip);
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer());
} else {

View File

@@ -39,20 +39,21 @@ TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingL0DebuggerThenValidDebuggerInst
}
TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingSipAllocationThenValidSipTypeIsReturned) {
auto systemRoutine = SipKernel::getSipKernelAllocation(*neoDevice);
neoDevice->setDebuggerActive(true);
auto systemRoutine = SipKernel::getSipKernel(*neoDevice).getSipAllocation();
ASSERT_NE(nullptr, systemRoutine);
auto sipType = SipKernel::getSipKernelType(neoDevice->getHardwareInfo().platform.eRenderCoreFamily, true);
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto expectedSipAllocation = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getSipAllocation();
EXPECT_EQ(expectedSipAllocation, systemRoutine);
}
TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingStateSaveAreaHeaderThenValidSipTypeIsReturned) {
auto stateSaveAreaHeader = SipKernel::getSipStateSaveAreaHeader(*neoDevice);
auto &stateSaveAreaHeader = SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
auto sipType = SipKernel::getSipKernelType(neoDevice->getHardwareInfo().platform.eRenderCoreFamily, true);
auto expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto &expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
}
@@ -75,10 +76,10 @@ TEST(Debugger, givenL0DebuggerOFFWhenGettingStateSaveAreaHeaderThenValidSipTypeI
driverHandle->initialize(std::move(devices));
auto stateSaveAreaHeader = SipKernel::getSipStateSaveAreaHeader(*neoDevice);
auto &stateSaveAreaHeader = SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
auto sipType = SipKernel::getSipKernelType(neoDevice->getHardwareInfo().platform.eRenderCoreFamily, false);
auto expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto &expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
}
@@ -181,7 +182,7 @@ HWTEST_F(L0DebuggerTest, givenDebuggingEnabledWhenCommandListIsExecutedThenValid
STATE_SIP *stateSip = genCmdCast<STATE_SIP *>(*stateSipCmds[0]);
auto systemRoutine = SipKernel::getSipKernelAllocation(*neoDevice);
auto systemRoutine = SipKernel::getSipKernel(*neoDevice).getSipAllocation();
ASSERT_NE(nullptr, systemRoutine);
EXPECT_EQ(systemRoutine->getGpuAddress(), stateSip->getSystemInstructionPointer());
}
@@ -512,7 +513,7 @@ HWTEST2_F(L0DebuggerInternalUsageTest, givenDebuggingEnabledWhenInternalCmdQIsUs
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
auto sbaBuffer = device->getL0Debugger()->getSbaTrackingBuffer(neoDevice->getDefaultEngine().commandStreamReceiver->getOsContext().getContextId());
auto sipIsa = NEO::SipKernel::getSipKernelAllocation(*neoDevice);
auto sipIsa = NEO::SipKernel::getSipKernel(*neoDevice).getSipAllocation();
auto debugSurface = device->getDebugSurface();
bool sbaFound = false;
bool sipFound = false;

View File

@@ -219,7 +219,7 @@ HWTEST2_F(SLDebuggerInternalUsageTest, givenDebuggingEnabledWhenInternalCmdQIsUs
EXPECT_EQ(0u, stateSip.size());
}
auto sipIsa = NEO::SipKernel::getSipKernelAllocation(*device);
auto sipIsa = NEO::SipKernel::getSipKernel(*device).getSipAllocation();
auto debugSurface = deviceL0->getDebugSurface();
bool sipFound = false;
bool debugSurfaceFound = false;

View File

@@ -11,6 +11,7 @@
#include "shared/source/os_interface/os_time.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "opencl/source/os_interface/os_inc_base.h"
@@ -31,13 +32,6 @@
using ::testing::Return;
namespace NEO {
namespace MockSipData {
extern SipKernelType calledType;
extern bool called;
} // namespace MockSipData
} // namespace NEO
namespace L0 {
namespace ult {
@@ -66,6 +60,7 @@ TEST(L0DeviceTest, givenMidThreadPreemptionWhenCreatingDeviceThenSipKernelIsInit
ze_result_t returnValue = ZE_RESULT_SUCCESS;
VariableBackup<bool> mockSipCalled(&NEO::MockSipData::called, false);
VariableBackup<NEO::SipKernelType> mockSipCalledType(&NEO::MockSipData::calledType, NEO::SipKernelType::COUNT);
VariableBackup<bool> backupSipInitType(&MockSipData::useMockSip, true);
std::unique_ptr<DriverHandleImp> driverHandle(new DriverHandleImp);
auto hwInfo = *NEO::defaultHwInfo;
@@ -103,7 +98,8 @@ TEST(L0DeviceTest, givenDebuggerEnabledButIGCNotReturnsSSAHThenSSAHIsNotCopied)
driverHandle->enableProgramDebugging = true;
driverHandle->initialize(std::move(devices));
auto stateSaveAreaHeader = NEO::SipKernel::getSipStateSaveAreaHeader(*neoDevice);
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto &stateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
EXPECT_EQ(static_cast<size_t>(0), stateSaveAreaHeader.size());
}
@@ -111,6 +107,7 @@ TEST(L0DeviceTest, givenDisabledPreemptionWhenCreatingDeviceThenSipKernelIsNotIn
ze_result_t returnValue = ZE_RESULT_SUCCESS;
VariableBackup<bool> mockSipCalled(&NEO::MockSipData::called, false);
VariableBackup<NEO::SipKernelType> mockSipCalledType(&NEO::MockSipData::calledType, NEO::SipKernelType::COUNT);
VariableBackup<bool> backupSipInitType(&MockSipData::useMockSip, true);
std::unique_ptr<DriverHandleImp> driverHandle(new DriverHandleImp);
auto hwInfo = *NEO::defaultHwInfo;