Skip to content

Commit 0ca7df9

Browse files
houjenkoigcbot
authored andcommitted
Force declared variables to physical registers through
compiler options Force declared variables to physical registers through compiler options
1 parent eb7d3be commit 0ca7df9

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,6 +4432,11 @@ namespace IGC
44324432
SaveOption(vISA_ShaderDumpFilter, regex);
44334433
}
44344434

4435+
if (auto *str = IGC_GET_REGKEYSTRING(ForceAssignRhysicalReg))
4436+
{
4437+
SaveOption(vISA_ForceAssignRhysicalReg, str);
4438+
}
4439+
44354440
// In Vulkan and OGL buffer variable memory reads and writes within
44364441
// a single shader invocation must be processed in order.
44374442
if (m_program->m_DriverInfo->DisableDpSendReordering())

IGC/common/igc_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ DECLARE_IGC_REGKEY(bool, AddExtraIntfInfo, false, "Will add extra
353353
DECLARE_IGC_REGKEY(bool, SimdEarlyOut_9, false, "Force compiler simd early out for dx9", true)
354354

355355
DECLARE_IGC_GROUP("Debugging features")
356+
DECLARE_IGC_REGKEY(debugString, ForceAssignRhysicalReg, 0, "Force assigning dclId to phyiscal reg.", true)
356357
DECLARE_IGC_REGKEY(bool, InitializeUndefValueEnable, false, "Setting this to 1/true initializes all undefs in URB payload to 0", false)
357358
DECLARE_IGC_REGKEY(bool, InitializeRegistersEnable, false, "Setting this to 1/true initializes all GRFs, Flag and address registers to 0 at the beginning of the shader", false)
358359
DECLARE_IGC_REGKEY(bool, InitializeAddressRegistersBeforeUse, false, "Setting this to 1 (true) initializes address register to 0 before each use", false)

visa/BuildCISAIRImpl.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,40 @@ int CISA_IR_Builder::Compile(const char* nameInput, std::ostream* os, bool emit_
16431643
m_options.getuInt32Option(vISA_Linker));
16441644
}
16451645
}
1646+
const char* rawStr = m_options.getOptionCstr(vISA_ForceAssignRhysicalReg);
1647+
if (rawStr && *rawStr != '\0')
1648+
{
1649+
std::vector<int> token;
1650+
std::map<int, int> forceAssign;
1651+
const char* DELIMITERS = ":, ";
1652+
std::string line(rawStr);
1653+
std::size_t pos = 0;
1654+
std::size_t found;
1655+
for (; (found = line.find_first_of(DELIMITERS, pos)) != std::string::npos; ++pos) {
1656+
// Skip consecutive whitespaces.
1657+
if (found == pos)
1658+
continue;
1659+
token.push_back(std::stoi(line.substr(pos, found - pos)));
1660+
pos = found;
1661+
}
1662+
if (pos < line.length())
1663+
token.push_back(std::stoi(line.substr(pos)));
1664+
1665+
for (unsigned int i = 0; i < token.size() - 1; i += 2)
1666+
{
1667+
forceAssign[token[i]] = token[i+1];
1668+
}
16461669

1670+
for (G4_Declare* dcl : m_kernelsAndFunctions.front()->getKernel()->Declares)
1671+
{
1672+
if (forceAssign.find(dcl->getDeclId()) != forceAssign.end())
1673+
{
1674+
std::cerr << "Force assigning DeclId : " << dcl->getDeclId() << " to r" << forceAssign[dcl->getDeclId()] << "\n";
1675+
dcl->getRegVar()->setPhyReg(m_kernelsAndFunctions.front()->getIRBuilder()->phyregpool.getGreg(forceAssign[dcl->getDeclId()]), 0);
1676+
dcl->dump();
1677+
}
1678+
}
1679+
}
16471680

16481681

16491682
VISAKernelImpl* oldMainKernel = nullptr;

visa/include/VISAOptionsDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ DEF_VISA_OPTION(vISA_removeInstrinsics, ET_BOOL, "-removeInstrinsics", U
5252
DEF_VISA_OPTION(vISA_addSWSBInfo, ET_BOOL, "-addSWSBInfo", UNUSED, true)
5353
DEF_VISA_OPTION(vISA_DumpRAIntfGraph, ET_BOOL, "-dumpintf", UNUSED, false)
5454
DEF_VISA_OPTION(vISA_DumpGenOffset, ET_BOOL, "-dumpgenoffset", UNUSED, false)
55+
DEF_VISA_OPTION(vISA_ForceAssignRhysicalReg,ET_CSTR, "-forceAssignRhysicalReg", UNUSED, NULL)
5556

5657
//=== Optimization options ===
5758
DEF_VISA_OPTION(vISA_EnableAlways, ET_BOOL, NULLSTR, UNUSED, true)

0 commit comments

Comments
 (0)