@@ -229,207 +229,6 @@ void ShaderStats::printShaderStats( ShaderHash hash, ShaderType shaderType, cons
229229 fclose (fileName);
230230}
231231
232- void ShaderStats::printOpcodeStats (ShaderHash hash, ShaderType shaderType, const std::string &postFix)
233- {
234- /* const std::string opcodeFilePath = IGC::Debug::GetShaderOutputFolder() + std::string("\\SQM\\") + IGC::Debug::GetShaderCorpusName() + "OpcodeShaderStats.csv";
235- const char *opcodeFile = opcodeFilePath.c_str();
236-
237- const std::string targetUnitFilePath = IGC::Debug::GetShaderOutputFolder() + std::string("\\SQM\\") + IGC::Debug::GetShaderCorpusName() + "TargetUnitShaderStats.csv";
238- const char *targetUnitFile = targetUnitFilePath.c_str();
239-
240- const std::string listFilePath = IGC::Debug::GetShaderOutputFolder() + std::string("\\SQM\\") + IGC::Debug::GetShaderCorpusName() + "ShadersList.txt";
241- const char *listUnitFile = listFilePath.c_str();
242-
243- FILE* opcodeFileName = fopen(opcodeFile, "a");
244- FILE* targetUnitFileName = fopen(targetUnitFile, "a");
245- FILE* listUnitFileName = fopen(listUnitFile, "a");
246-
247- std::string asmFileName;
248- if (shaderType == ShaderType::OPENCL_SHADER)
249- {
250- asmFileName =
251- IGC::Debug::DumpName(IGC::Debug::GetShaderOutputName())
252- .Type(shaderType)
253- .Hash(hash)
254- .PostFix(postFix)
255- .Extension("asm")
256- .str();
257- if (asmFileName.find_last_of("\\") != std::string::npos)
258- {
259- asmFileName = asmFileName.substr(asmFileName.find_last_of("\\") + 1, asmFileName.size());
260- }
261- }
262- else
263- {
264- asmFileName =
265- IGC::Debug::DumpName(IGC::Debug::GetShaderOutputName())
266- .Type(shaderType)
267- .Hash(hash)
268- .Extension("asm")
269- .str();
270- if (asmFileName.find_last_of("\\") != std::string::npos)
271- {
272- asmFileName = asmFileName.substr(asmFileName.find_last_of("\\") + 1, asmFileName.size());
273- }
274- }
275-
276-
277- fprintf(opcodeFileName, "%s","");
278- fclose(opcodeFileName);
279-
280- fprintf(targetUnitFileName, "%s","");
281- fclose(targetUnitFileName);
282-
283- fprintf(listUnitFileName, "%s\n", asmFileName.c_str());
284- fclose(listUnitFileName);
285- ?*/
286- }
287-
288- void ShaderStats::parseIsaShader ( ShaderHash hash, ShaderType shaderType, SIMDMode simd )
289- {
290-
291- std::string line, instStr;
292-
293- std::string asmFileName =
294- IGC::Debug::DumpName (IGC::Debug::GetShaderOutputName ())
295- .Type (shaderType)
296- .Hash (hash)
297- .SIMDSize (simd)
298- .Extension (" asm" )
299- .str ();
300- if (asmFileName.find_last_of (" \\ " ) != std::string::npos)
301- {
302- asmFileName = asmFileName.substr (asmFileName.find_last_of (" \\ " ) + 1 , asmFileName.size ());
303- }
304-
305- std::ifstream asmFile (asmFileName.c_str ());
306-
307- while ( getline (asmFile, line) )
308- {
309- if ( line == " .code" )
310- {
311- break ;
312- }
313- }
314-
315- while ( getline (asmFile, line) )
316- {
317- if ( line == " " || line.find ( " //" , 0 ) == 0 || line == " main:" || line.find ( " label" , 0 ) == 0 )
318- {
319- continue ;
320- }
321- else if (line.find (" " , 0 ) == std::string::npos && line.find (" :" , 0 ) == line.size () - 1 )
322- {
323- continue ;
324- }
325- else if ( line == " .end_code" )
326- {
327- break ;
328- }
329-
330- if ( line.find (" (" ,0 ) == 0 )
331- {
332- line = line.substr ( line.find (" )" ,0 ) + 2 , line.length () );
333- }
334-
335- instStr = line.substr ( 0 , line.find (" " , 0 ) );
336-
337- auto hasDot = instStr.find (" ." ,0 );
338- if (hasDot != std::string::npos)
339- {
340- instStr = instStr.substr ( 0 , hasDot );
341- }
342-
343- if ( line.find (" L" ,0 ) == 0 || line.find (" _AUTO_LABEL" , 0 ) == 0 )
344- {
345- m_CompileShaderStats[STATS_ISA_BASIC_BLOCKS]++;
346- }
347- else if ( instStr == " add" || instStr == " addc" || instStr == " avg" || instStr == " dp2" ||
348- instStr == " dp3" || instStr == " dp4" || instStr == " dph" || instStr == " frc" ||
349- instStr == " line" || instStr == " lrp" || instStr == " mac" || instStr == " mach" ||
350- instStr == " mad" || instStr == " madm" || instStr == " math" || instStr == " mul" ||
351- instStr == " pln" || instStr == " rndd" || instStr == " rnde" || instStr == " rndu" ||
352- instStr == " rndz" || instStr == " sad2" || instStr == " sada2" || instStr == " subb" )
353- {
354- m_CompileShaderStats[STATS_ISA_ALU]++;
355- }
356- else if ( instStr == " and" || instStr == " asr" || instStr == " bfe" || instStr == " bfi1" ||
357- instStr == " bfi2" || instStr == " bfrev" || instStr == " cbit" || instStr == " fbh" ||
358- instStr == " fbl" || instStr == " lzd" || instStr == " not" || instStr == " or" ||
359- instStr == " shl" || instStr == " shr" || instStr == " xor" )
360- {
361- m_CompileShaderStats[STATS_ISA_LOGIC]++;
362- }
363- else if ( instStr == " brc" || instStr == " brd" || instStr == " jumpi" )
364- {
365- m_CompileShaderStats[STATS_ISA_THREADCF]++;
366- }
367- else if (instStr == " break" || instStr == " cont" || instStr == " while" ||
368- instStr == " else" || instStr == " endif" || instStr == " if" )
369- {
370- m_CompileShaderStats[STATS_ISA_STRUCTCF]++;
371- }
372- else if ( instStr == " goto" || instStr == " join" )
373- {
374- m_CompileShaderStats[STATS_ISA_GOTOJOIN]++;
375- }
376- else if ( instStr == " call" || instStr == " calla" )
377- {
378- m_CompileShaderStats[STATS_ISA_CALL]++;
379- }
380- else if ( instStr == " cmp" || instStr == " cmpn" || instStr == " csel" || instStr == " sel" )
381- {
382- m_CompileShaderStats[STATS_ISA_SEL_CMP]++;
383- }
384- else if ( instStr == " mov" || instStr == " movi" || instStr == " smov" )
385- {
386- m_CompileShaderStats[STATS_ISA_MOV]++;
387- }
388- else if ( instStr == " send" || instStr == " sendc" || instStr == " sends" )
389- {
390- m_CompileShaderStats[STATS_ISA_SEND]++;
391- }
392- else if ( instStr == " halt" || instStr == " illegal" || instStr == " nop" || instStr == " wait" ||
393- instStr == " ret" )
394- {
395- m_CompileShaderStats[STATS_ISA_OTHERS]++;
396- }
397- else if ( line.find ( " _GOTO_TARGET" , 0 ) == 0 )
398- {
399- ;
400- }
401- else
402- {
403- IGC_ASSERT (0 );
404- }
405- }
406-
407- int statsIndex = STATS_ISA_INST_COUNT;
408- if ( simd == SIMDMode::SIMD16 )
409- {
410- statsIndex = STATS_ISA_INST_COUNT_SIMD16;
411- }
412- else if ( simd == SIMDMode::SIMD32 )
413- {
414- statsIndex = STATS_ISA_INST_COUNT_SIMD32;
415- }
416-
417- for ( int i=STATS_ISA_ALU; i<STATS_MAX_SHADER_STATS_ITEMS; i++)
418- {
419- m_CompileShaderStats[statsIndex] += m_CompileShaderStats[i];
420- }
421-
422- if ( simd == SIMDMode::SIMD16 )
423- {
424- m_CompileShaderStats[STATS_ISA_INST_COUNT_SIMD16] -= m_CompileShaderStats[STATS_ISA_INST_COUNT];
425- }
426- else if ( simd == SIMDMode::SIMD32 )
427- {
428- m_CompileShaderStats[STATS_ISA_INST_COUNT_SIMD32] -= m_CompileShaderStats[STATS_ISA_INST_COUNT];
429- }
430- asmFile.close ();
431- }
432-
433232void ShaderStats::sumShaderStat ( SHADER_STATS_ITEMS compileInterval, int count )
434233{
435234 IGC_ASSERT (0 <= compileInterval);
0 commit comments