Skip to content

Commit 4ac6548

Browse files
bcheng0127sys_zuul
authored andcommitted
GRF register info dump
Change-Id: I2884d96d91651f7894868fae4ad796b4b28f7641
1 parent 8ca504f commit 4ac6548

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

visa/FlowGraph.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class G4_BB
470470
uint32_t emitBankConflictGen12lp(std::ostream & os_output, G4_INST * inst, int * suppressRegs, int * lastRegs, int & sameConflictTimes, int & twoSrcConflicts, int & simd16RS);
471471
uint32_t countReadModifyWrite(std::ostream& os_output, G4_INST *inst);
472472
uint32_t emitBankConflictGen12(std::ostream & os_output, G4_INST * inst, int * suppressRegs, int & sameConflictTimes, int & twoSrcConflicts, int & simd16RS, bool zeroOne, bool isTGLLP);
473+
void emitRegInfo(std::ostream& output, G4_INST* inst, int offset);
473474
void emitDepInfo(std::ostream& output, G4_INST *inst, int offset);
474475

475476
bool isEndWithCall() const { return getLastOpcode() == G4_call; }
@@ -1552,6 +1553,8 @@ class G4_Kernel
15521553
void setName(const char* n) { name = n; }
15531554
const char* getName() { return name; }
15541555
void emit_asm(std::ostream& output, bool beforeRegAlloc, void * binary, uint32_t binarySize);
1556+
void emit_RegInfo();
1557+
void emit_RegInfoKernel(std::ostream& output);
15551558
void emit_dep(std::ostream& output);
15561559

15571560
void setKernelParameters(void);

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,50 @@ void G4_BB_SB::createAddGRFEdge(SBNode* pred, SBNode* succ, DepType d, SBDepende
58565856
return;
58575857
}
58585858

5859+
void G4_Kernel::emit_RegInfo()
5860+
{
5861+
const char* asmName = nullptr;
5862+
getOptions()->getOption(VISA_AsmFileName, asmName);
5863+
char dumpFileName[MAX_OPTION_STR_LENGTH];
5864+
SNPRINTF(dumpFileName, MAX_OPTION_STR_LENGTH, "%s.regInfo",
5865+
asmName);
5866+
fstream ofile(dumpFileName, ios::out);
5867+
5868+
emit_RegInfoKernel(ofile);
5869+
5870+
ofile.close();
5871+
}
5872+
5873+
void G4_Kernel::emit_RegInfoKernel(std::ostream& output)
5874+
{
5875+
output << "//.platform " << platformString[fg.builder->getPlatform()];
5876+
output << "\n" << "//.stepping " << GetSteppingString();
5877+
output << "\n" << "//.CISA version " << (unsigned int)major_version
5878+
<< "." << (unsigned int)minor_version;
5879+
output << "\n" << "//.kernel ID 0x" << hex << getKernelID() << "\n";
5880+
output << dec << "\n";
5881+
int instOffset = 0;
5882+
5883+
for (BB_LIST_ITER itBB = fg.begin(); itBB != fg.end(); ++itBB)
5884+
{
5885+
for (INST_LIST_ITER itInst = (*itBB)->begin(); itInst != (*itBB)->end(); ++itInst)
5886+
{
5887+
G4_INST* inst = (*itInst);
5888+
if (inst->isLabel())
5889+
{
5890+
continue;
5891+
}
5892+
if (inst->getLexicalId() == -1)
5893+
{
5894+
continue;
5895+
}
5896+
5897+
(*itBB)->emitRegInfo(output, inst, instOffset);
5898+
instOffset += inst->isCompactedInst() ? 8 : 16;
5899+
}
5900+
}
5901+
return;
5902+
}
58595903

58605904
void G4_Kernel::emit_dep(std::ostream& output)
58615905
{
@@ -5891,6 +5935,49 @@ void G4_Kernel::emit_dep(std::ostream& output)
58915935
return;
58925936
}
58935937

5938+
void G4_BB::emitRegInfo(std::ostream& output, G4_INST* inst, int offset)
5939+
{
5940+
output << "#" << inst->getLexicalId() << "|" << offset << ":";
5941+
G4_DstRegRegion* dstOpnd = inst->getDst();
5942+
5943+
if (dstOpnd &&
5944+
!dstOpnd->isIndirect() &&
5945+
dstOpnd->isGreg())
5946+
{
5947+
uint32_t byteAddress = dstOpnd->getLinearizedStart();
5948+
unsigned dstReg0 = byteAddress / GENX_GRF_REG_SIZ;
5949+
output << " {";
5950+
output << "D:" << dstReg0;
5951+
output << "}";
5952+
}
5953+
5954+
for (int i = 0; i < inst->getNumSrc(); i++)
5955+
{
5956+
G4_Operand* srcOpnd = inst->getSrc(i);
5957+
if (srcOpnd)
5958+
{
5959+
if (srcOpnd->isSrcRegRegion() &&
5960+
srcOpnd->asSrcRegRegion()->getBase() &&
5961+
!srcOpnd->asSrcRegRegion()->isIndirect() &&
5962+
srcOpnd->asSrcRegRegion()->getBase()->isRegVar())
5963+
{
5964+
G4_RegVar* baseVar = static_cast<G4_RegVar*>(srcOpnd->asSrcRegRegion()->getBase());
5965+
if (baseVar->isGreg()) {
5966+
uint32_t byteAddress = srcOpnd->getLinearizedStart();
5967+
unsigned srcReg = byteAddress / GENX_GRF_REG_SIZ;
5968+
output << " {";
5969+
output << "S" << i;
5970+
output << ":" << srcReg;
5971+
output << "}";
5972+
}
5973+
}
5974+
}
5975+
}
5976+
5977+
output << std::endl;
5978+
return;
5979+
}
5980+
58945981
void G4_BB::emitDepInfo(std::ostream& output, G4_INST* inst, int offset)
58955982
{
58965983
int tabnum = 0;

visa/VISAKernelImpl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ void* VISAKernelImpl::compilePostOptimize(unsigned int& binarySize)
372372

373373
m_kernel->evalAddrExp();
374374

375+
if (getOptions()->getOption(vISA_DumpRegInfo))
376+
{
377+
m_kernel->dump();
378+
m_kernel->emit_RegInfo();
379+
}
380+
375381
if (getOptions()->getOption(vISA_setStartBreakPoint))
376382
{
377383
auto getFirstNonLabelInst = [this]()

visa/include/VISAOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ DEF_VISA_OPTION(VISA_AsmFileName, ET_CSTR, "-asmNameUser", "USAG
204204
DEF_VISA_OPTION(vISA_DecodeDbg, ET_CSTR, "-decodedbg", "USAGE: -decodedbg <dbg filename>\n", NULL)
205205
DEF_VISA_OPTION(vISA_encoderFile, ET_CSTR, "-encoderStatisticsFile", "USAGE: -encoderStatisticsFile <reloc file>\n", "encoderStatistics.csv")
206206
DEF_VISA_OPTION(vISA_CISAbinary, ET_CSTR, "-CISAbinary", "USAGE: File Name with isaasm paths. ", NULL)
207+
DEF_VISA_OPTION(vISA_DumpRegInfo, ET_BOOL, "-dumpRegInfo", UNUSED, false)
207208

208209
//=== misc options ===
209210
DEF_VISA_OPTION(vISA_PlatformIsSet, ET_BOOL, NULLSTR, UNUSED, false)

0 commit comments

Comments
 (0)