mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Refactor SipKernel
- add debug bindless SipKernelType Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d79317da35
commit
2fb8edb69f
@@ -114,14 +114,14 @@ class MockCompilerInterface : public CompilerInterface {
|
||||
return this->fclBaseTranslationCtx.get();
|
||||
}
|
||||
|
||||
TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, bool bindlessSip, std::vector<char> &retBinary,
|
||||
TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector<char> &retBinary,
|
||||
std::vector<char> &stateAreaHeader) override {
|
||||
if (this->sipKernelBinaryOverride.size() > 0) {
|
||||
retBinary = this->sipKernelBinaryOverride;
|
||||
this->requestedSipKernel = type;
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
} else {
|
||||
return CompilerInterface::getSipKernelBinary(device, type, bindlessSip, retBinary, stateAreaHeader);
|
||||
return CompilerInterface::getSipKernelBinary(device, type, retBinary, stateAreaHeader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,21 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenInitSipKernelTwiceThenSipIsLoaded
|
||||
EXPECT_EQ(storedAllocation, secondStoredAllocation);
|
||||
}
|
||||
|
||||
TEST_F(RawBinarySipTest, givenRawBinaryFileWhenGettingBindlessDebugSipThenSipIsLoadedFromFile) {
|
||||
auto sipAllocation = SipKernel::getBindlessDebugSipKernel(*pDevice).getSipAllocation();
|
||||
|
||||
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::DbgBindless);
|
||||
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).getStateSaveAreaHeader();
|
||||
EXPECT_NE(0u, header.size());
|
||||
}
|
||||
|
||||
struct HexadecimalHeaderSipKernel : public SipKernel {
|
||||
using SipKernel::getSipKernelImpl;
|
||||
using SipKernel::initHexadecimalArraySipKernel;
|
||||
@@ -336,3 +351,15 @@ TEST_F(StateSaveAreaSipTest, givenCorrectStateSaveAreaHeaderWhenGetStateSaveArea
|
||||
MockSipData::mockSipKernel->mockStateSaveAreaHeader = MockSipData::createStateSaveAreaHeader();
|
||||
EXPECT_EQ(0x3F1000u, SipKernel::getSipKernel(*pDevice).getStateSaveAreaSize());
|
||||
}
|
||||
TEST(DebugBindlessSip, givenActiveDebuggerAndUseBindlessDebugSipWhenGettingSipTypeThenDebugBindlessTypeIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.UseBindlessDebugSip.set(1);
|
||||
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
EXPECT_NE(nullptr, mockDevice);
|
||||
mockDevice->setDebuggerActive(true);
|
||||
|
||||
auto sipType = NEO::SipKernel::getSipKernelType(*mockDevice);
|
||||
|
||||
EXPECT_EQ(SipKernelType::DbgBindless, sipType);
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenGetSipKernelBinaryFa
|
||||
pCompilerInterface->igcMain.reset();
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::CompilerNotAvailable, err);
|
||||
EXPECT_EQ(0U, sipBinary.size());
|
||||
}
|
||||
@@ -1018,7 +1018,7 @@ TEST_F(CompilerInterfaceTest, whenIgcReturnsErrorThenGetSipKernelBinaryFailsGrac
|
||||
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err);
|
||||
EXPECT_EQ(0U, sipBinary.size());
|
||||
|
||||
@@ -1031,7 +1031,7 @@ TEST_F(CompilerInterfaceTest, whenEverythingIsOkThenGetSipKernelReturnsIgcsOutpu
|
||||
gEnvironment->igcPushDebugVars(igcDebugVars);
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
|
||||
@@ -1043,17 +1043,17 @@ TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperSystemRouti
|
||||
gEnvironment->igcPushDebugVars(igcDebugVars);
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::contextSaveRestore, getIgcDebugVars().typeOfSystemRoutine);
|
||||
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, false, sipBinary, stateAreaHeader);
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine);
|
||||
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, false, sipBinary, stateAreaHeader);
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine);
|
||||
@@ -1061,29 +1061,27 @@ TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperSystemRouti
|
||||
gEnvironment->igcPopDebugVars();
|
||||
}
|
||||
|
||||
TEST_F(CompilerInterfaceTest, givenUseBindlessDebugSipWhenRequestingSipKernelBinaryThenProperSystemRoutineIsSelectedFromCompiler) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.UseBindlessDebugSip.set(true);
|
||||
TEST_F(CompilerInterfaceTest, WhenRequestingBindlessDebugSipThenProperSystemRoutineIsSelectedFromCompiler) {
|
||||
MockCompilerDebugVars igcDebugVars;
|
||||
gEnvironment->igcPushDebugVars(igcDebugVars);
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::contextSaveRestore, getIgcDebugVars().typeOfSystemRoutine);
|
||||
EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindful, getIgcDebugVars().receivedSipAddressingType);
|
||||
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, false, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine);
|
||||
EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindless, getIgcDebugVars().receivedSipAddressingType);
|
||||
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, false, sipBinary, stateAreaHeader);
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine);
|
||||
EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindful, getIgcDebugVars().receivedSipAddressingType);
|
||||
|
||||
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgBindless, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
EXPECT_NE(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine);
|
||||
EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindless, getIgcDebugVars().receivedSipAddressingType);
|
||||
|
||||
gEnvironment->igcPopDebugVars();
|
||||
@@ -1094,7 +1092,7 @@ TEST_F(CompilerInterfaceTest, whenRequestingInvalidSipKernelBinaryThenErrorIsRet
|
||||
gEnvironment->igcPushDebugVars(igcDebugVars);
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateAreaHeader;
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::COUNT, false, sipBinary, stateAreaHeader);
|
||||
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::COUNT, sipBinary, stateAreaHeader);
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err);
|
||||
EXPECT_EQ(0U, sipBinary.size());
|
||||
EXPECT_EQ(IGC::SystemRoutineType::undefined, getIgcDebugVars().typeOfSystemRoutine);
|
||||
|
||||
Reference in New Issue
Block a user