Skip to content

Commit ceb8220

Browse files
daniel-manigcbot
authored andcommitted
Adds vISA option to enable JSON shader dump.
Adds vISA option to enable JSON shader dump.
1 parent d8fd116 commit ceb8220

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

visa/BinaryEncodingIGA.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ SPDX-License-Identifier: MIT
99
#include "BinaryEncodingIGA.h"
1010
#include "GTGPU_RT_ASM_Interface.h"
1111
#include "iga/IGALibrary/api/igaEncoderWrapper.hpp"
12+
#include "iga/IGALibrary/Frontend/FormatterJSON.hpp"
1213
#include "Timer.h"
1314
#include "BuildIR.h"
1415
#include "Common_ISA_framework.h"
1516

17+
#include <fstream>
1618
#include <map>
1719
#include <utility>
1820

19-
2021
using namespace iga;
2122
using namespace vISA;
2223

@@ -45,6 +46,8 @@ class BinaryEncodingIGA
4546
// translates and encodes (formerly "DoAll")
4647
void Encode();
4748

49+
void EmitJSON(int dumpJSON);
50+
4851
///////////////////////////////////////////////////////////////////////////
4952
// these function translate G4 IR to IGA IR
5053
Instruction *translateInstruction(G4_INST *g4inst, Block*& bbNew);
@@ -1034,6 +1037,19 @@ void BinaryEncodingIGA::Encode()
10341037
kernel.fg.builder->getJitInfo()->offsetToSkipSetFFIDGP1 =
10351038
kernel.getComputeFFIDGP1NextOff();
10361039
}
1040+
1041+
int dumpJSON = kernel.fg.builder->getuint32Option(vISA_dumpIgaJson);
1042+
if (dumpJSON) {
1043+
EmitJSON(dumpJSON);
1044+
}
1045+
}
1046+
1047+
void BinaryEncodingIGA::EmitJSON(int dumpJSON) {
1048+
std::string jsonFileName = fileName + ".json";
1049+
std::ofstream ofs(jsonFileName, std::ofstream::out);
1050+
FormatOpts fos(*platformModel);
1051+
fos.printJson = true;
1052+
FormatJSON(ofs, fos, *IGAKernel, nullptr);
10371053
}
10381054

10391055
Instruction *BinaryEncodingIGA::translateInstruction(
@@ -1991,4 +2007,3 @@ bool vISA::InstSupportsSrcModifierIGA(TARGET_PLATFORM p, const G4_INST &i, const
19912007
return false;
19922008
}
19932009
}
1994-

visa/include/VISAOptionsDefs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ DEF_VISA_OPTION(vISA_encoderFile, ET_CSTR, "-encoderStatisticsFile", "USAG
296296
DEF_VISA_OPTION(vISA_CISAbinary, ET_CSTR, "-CISAbinary", "USAGE: File Name with isaasm paths. ", NULL)
297297
DEF_VISA_OPTION(vISA_DumpRegInfo, ET_BOOL, "-dumpRegInfo", UNUSED, false)
298298
DEF_VISA_OPTION(vISA_PrintHexFloatInAsm, ET_BOOL, "-printHexFloatInAsm", UNUSED, false)
299+
DEF_VISA_OPTION(vISA_dumpIgaJson, ET_INT32, "-dumpIgaJson",
300+
"Emits a .json file (peer to .asm) with final IGA output in JSON format; "
301+
"1 enables basic output, 2 enables with def/use dataflow information "
302+
"(may increase compile time significantly for large shaders)", 0)
299303

300304
//=== misc options ===
301305
DEF_VISA_OPTION(vISA_PlatformSet, ET_INT32, NULLSTR, UNUSED, -1 /*GENX_NONE*/)

0 commit comments

Comments
 (0)