Skip to content

Commit 112f2f2

Browse files
iwwusys_zuul
authored andcommitted
Enable timestats through regkey
Add 3 regkeys to turn on timestats DumpTimeStats DumpTimeStatsCoarse DumpTimeStatsPerPass Change-Id: I41d735416b6ad470ba9499de730695019ef95bb6
1 parent 14b6625 commit 112f2f2

File tree

7 files changed

+53
-15
lines changed

7 files changed

+53
-15
lines changed

IGC/Compiler/CISACodeGen/CheckInstrTypes.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace IGC
4545

4646
public:
4747
static char ID;
48-
CheckInstrTypes() : FunctionPass(ID), g_InstrTypes(nullptr)
48+
CheckInstrTypes() : FunctionPass(ID), g_InstrTypes(nullptr), LI(nullptr)
4949
{
5050
};
5151
CheckInstrTypes(IGC::SInstrTypes* instrList);
@@ -88,7 +88,8 @@ namespace IGC
8888
{
8989
public:
9090
static char ID;
91-
InstrStatistic() : FunctionPass(ID), m_ctx(nullptr), m_type(InstrStatTypes(0)), m_stage(InstrStatStage::BEGIN), m_threshold(0)
91+
InstrStatistic() : FunctionPass(ID), m_ctx(nullptr), m_type(InstrStatTypes(0)),
92+
m_stage(InstrStatStage::BEGIN), m_threshold(0), m_LI(nullptr)
9293
{
9394
};
9495
InstrStatistic(CodeGenContext* ctx, InstrStatTypes type, InstrStatStage stage, int threshold);
@@ -121,4 +122,4 @@ namespace IGC
121122
bool parseLoop(llvm::Loop* loop);
122123
};
123124

124-
} // namespace IGC
125+
} // namespace IGC

IGC/common/LLVMUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ void IGCPassManager::add(Pass *P)
9292
return;
9393
}
9494

95-
if (IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_PASS))
95+
if (IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsPerPass, TIME_STATS_PER_PASS))
9696
{
9797
PassManager::add(createTimeStatsIGCPass(m_pContext, m_name + '_' + std::string(P->getPassName()), STATS_COUNTER_START));
9898
}
9999

100100
PassManager::add(P);
101101

102-
if (IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_PASS))
102+
if (IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsPerPass, TIME_STATS_PER_PASS))
103103
{
104104
PassManager::add(createTimeStatsIGCPass(m_pContext, m_name + '_' + std::string(P->getPassName()), STATS_COUNTER_END));
105105
}

IGC/common/Stats.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void TimeStats::sumWith( const TimeStats* pOther )
623623

624624
m_PassTotalTicks += pOther->m_PassTotalTicks;
625625

626-
if (IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_PASS))
626+
if (IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsPerPass, TIME_STATS_PER_PASS))
627627
{
628628
if (m_PassTimeStatsMap.empty())
629629
{
@@ -681,9 +681,17 @@ void TimeStats::printTime( ShaderType type, ShaderHash hash, void* context ) con
681681

682682
void TimeStats::printSumTime() const
683683
{
684+
// If using regkey to turn on timestats, CorpusName is not initialized properly
685+
if (strlen(IGC::Debug::GetShaderCorpusName()) == 0)
686+
{
687+
std::stringstream corpusName;
688+
corpusName << m_totalShaderCount << " shaders";
689+
IGC::Debug::SetShaderCorpusName(corpusName.str().c_str());
690+
}
691+
684692
TimeStats pp = postProcess();
685693

686-
bool dumpCoarse = IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_COARSE );
694+
bool dumpCoarse = IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsCoarse, TIME_STATS_COARSE);
687695

688696
if ( dumpCoarse )
689697
{
@@ -694,7 +702,7 @@ void TimeStats::printSumTime() const
694702
pp.printSumTimeCSV("c:\\Intel\\TimeStatSum.csv");
695703
}
696704

697-
if (IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_PASS))
705+
if (IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsPerPass, TIME_STATS_PER_PASS))
698706
{
699707
pp.printPerPassSumTime(llvm::dbgs());
700708
pp.printPerPassSumTimeCSV("c:\\Intel\\TimeStatPerPassSum.csv");
@@ -706,7 +714,7 @@ void TimeStats::printSumTime() const
706714
bool TimeStats::skipTimer( int i ) const
707715
{
708716
const COMPILE_TIME_INTERVALS interval = static_cast<COMPILE_TIME_INTERVALS>(i);
709-
if( IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_COARSE ) && !isCoarseTimer( interval ) )
717+
if( IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsCoarse, TIME_STATS_COARSE ) && !isCoarseTimer( interval ) )
710718
{
711719
return true;
712720
}
@@ -759,7 +767,7 @@ void TimeStats::printSumTimeCSV(const char* outputFile) const
759767
}
760768
fprintf(fileName, "\n");
761769

762-
if( !IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_COARSE ) )
770+
if( !IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsCoarse, TIME_STATS_COARSE))
763771
{
764772
// print secs
765773
fprintf(fileName, "seconds,," );
@@ -934,7 +942,7 @@ void TimeStats::printSumTimeTable( llvm::raw_ostream & OS ) const
934942
FS << "\n";
935943

936944
// table body
937-
if (IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_COARSE))
945+
if (IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStatsCoarse, TIME_STATS_COARSE))
938946
{
939947
uint64_t timeNotInCoarse = getCompileTime(TIME_TOTAL);
940948
for (int i = 0; i < MAX_COMPILE_TIME_INTERVALS; i++)
@@ -1049,7 +1057,12 @@ void TimeStats::printTimeCSV( std::string const& corpusName ) const
10491057
{
10501058
IGC_ASSERT_MESSAGE(m_isPostProcessed, "Print functions should only be called on a Post-Processed TimeStats object");
10511059

1052-
const std::string outputFilePath = std::string("c:\\Intel\\") + "TimeStat_" + IGC::Debug::GetShaderCorpusName() + ".csv";
1060+
std::string subFile = "TimeStat_";
1061+
if (strlen(IGC::Debug::GetShaderCorpusName()) == 0)
1062+
subFile += "Shaders";
1063+
else
1064+
subFile += IGC::Debug::GetShaderCorpusName();
1065+
const std::string outputFilePath = std::string("c:\\Intel\\") + subFile + ".csv";
10531066
const char *outputFile = outputFilePath.c_str();
10541067

10551068
bool fileExist = false;
@@ -1103,7 +1116,12 @@ void TimeStats::printPerPassTimeCSV(std::string const& corpusName) const
11031116
return;
11041117
}
11051118

1106-
const std::string outputFilePath = std::string("c:\\Intel\\") + "TimeStatPerPass_" + IGC::Debug::GetShaderCorpusName() + ".csv";
1119+
std::string subFile = "TimeStatPerPass_";
1120+
if (strlen(IGC::Debug::GetShaderCorpusName()) == 0)
1121+
subFile += "Shaders";
1122+
else
1123+
subFile += IGC::Debug::GetShaderCorpusName();
1124+
const std::string outputFilePath = std::string("c:\\Intel\\") + subFile + ".csv";
11071125
const char* outputFile = outputFilePath.c_str();
11081126
bool fileExist = false;
11091127

IGC/common/Stats.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class TimeStats
369369
{ \
370370
if( (pointer) && (pointer)->m_sumCompilerTimeStats ) \
371371
{ \
372-
if ( IGC::Debug::GetDebugFlag( IGC::Debug::DebugFlag::TIME_STATS_SUM ) ) \
372+
if ( IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStats, TIME_STATS_SUM ) ) \
373373
{ \
374374
(pointer)->m_sumCompilerTimeStats->printSumTime(); \
375375
} \
@@ -381,7 +381,7 @@ class TimeStats
381381
{ \
382382
if( (pointer) && (pointer)->m_sumCompilerTimeStats ) \
383383
{ \
384-
if ( IGC::Debug::GetDebugFlag( IGC::Debug::DebugFlag::TIME_STATS_SUM ) ) \
384+
if ( IGC_REGKEY_OR_FLAG_ENABLED(DumpTimeStats, TIME_STATS_SUM ) ) \
385385
{ \
386386
for(int i = 1; i < size; i++) \
387387
{ \

IGC/common/igc_flags.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ DECLARE_IGC_REGKEY(bool, DumpPatchTokens, false, "Enable dumping o
244244
DECLARE_IGC_REGKEY(bool, DumpVariableAlias, false, "Dump variable alias info, valid if EnableVariableAlias is on)", true)
245245
DECLARE_IGC_REGKEY(bool, DumpDeSSA, false, "dump DeSSA info into file.", true)
246246
DECLARE_IGC_REGKEY(bool, EnableScalarizerDebugLog, false, "print step by step scalarizer debug info.", true)
247+
DECLARE_IGC_REGKEY(bool, DumpTimeStats, false, "Timing of translation, code generation, finalizer, etc", true)
248+
DECLARE_IGC_REGKEY(bool, DumpTimeStatsCoarse, false, "Only collect/dump coarse level time stats, i.e. skip opt detail timer for now", true)
249+
DECLARE_IGC_REGKEY(bool, DumpTimeStatsPerPass, false, "Collect Timing of IGC/LLVM passes", true)
247250

248251
DECLARE_IGC_GROUP("Debugging features")
249252
DECLARE_IGC_REGKEY(bool, InitializeUndefValueEnable, false, "Setting this to 1/true initializes all undefs in URB payload to 0", false)

IGC/common/igc_regkeys.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3434
#include "3d/common/iStdLib/File.h"
3535
#include "secure_mem.h"
3636
#include "secure_string.h"
37+
#include "AdaptorCommon/customApi.hpp"
3738

3839
#if defined(_WIN64) || defined(_WIN32)
3940
#include <devguid.h> // for GUID_DEVCLASS_DISPLAY
@@ -897,6 +898,18 @@ void LoadRegistryKeys(const std::string& options, bool *RegFlagNameError)
897898
IGC_SET_FLAG_VALUE(DumpPatchTokens, true);
898899
}
899900

901+
if (IGC_IS_FLAG_ENABLED(DumpTimeStatsPerPass) ||
902+
IGC_IS_FLAG_ENABLED(DumpTimeStatsCoarse))
903+
{
904+
IGC_SET_FLAG_VALUE(DumpTimeStats, true);
905+
IGC::Debug::SetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_SHADER, true);
906+
}
907+
908+
if (IGC_IS_FLAG_ENABLED(DumpTimeStats))
909+
{
910+
// Need to turn on this setting so per-shader .csv is generated
911+
IGC::Debug::SetDebugFlag(IGC::Debug::DebugFlag::TIME_STATS_PER_SHADER, true);
912+
}
900913

901914
switch(IGC_GET_FLAG_VALUE(ForceOCLSIMDWidth))
902915
{

IGC/common/igc_regkeys.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ extern SRegKeysList g_RegKeyList;
125125
( CheckHashRange(g_RegKeyList.name.hashes) ? g_RegKeyList.name.m_string : "" )
126126
#endif
127127

128+
#define IGC_REGKEY_OR_FLAG_ENABLED( name, flag ) ( IGC_IS_FLAG_ENABLED(name) || IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::flag))
129+
128130
#if defined(_WIN64) || defined(_WIN32)
129131
struct DEVICE_INFO
130132
{
@@ -167,4 +169,5 @@ namespace IGC
167169
#define IGC_IS_FLAG_DISABLED( name ) (IGC::DebugVariable::name##default == 0)
168170
#define IGC_GET_FLAG_VALUE( name ) (IGC::DebugVariable::name##default)
169171
#define IGC_GET_REGKEYSTRING( name ) ("")
172+
#define IGC_REGKEY_OR_FLAG_ENABLED( name, flag ) ( IGC_IS_FLAG_ENABLED(name) || IGC::Debug::GetDebugFlag(IGC::Debug::DebugFlag::flag))
170173
#endif

0 commit comments

Comments
 (0)