void DebugReporter::generateDebugReport( AstTranslationUnit& translationUnit, std::string id, std::string title) { std::stringstream datalogSpec; translationUnit.getProgram()->print(datalogSpec); DebugReportSection datalogSection = getCodeSection(id + "-dl", "Datalog", datalogSpec.str()); std::stringstream precGraphDot; translationUnit.getAnalysis<PrecedenceGraph>()->outputPrecedenceGraph(precGraphDot); DebugReportSection precedenceGraphSection = getDotGraphSection(id + "-prec-graph", "Precedence Graph", precGraphDot.str()); std::stringstream sccGraphDot; translationUnit.getAnalysis<SCCGraph>()->outputSCCGraph(sccGraphDot); DebugReportSection sccGraphSection = getDotGraphSection(id + "-scc-graph", "SCC Graph", sccGraphDot.str()); std::stringstream topsortSCCGraph; translationUnit.getAnalysis<TopologicallySortedSCCGraph>()->outputTopologicallySortedSCCGraph( topsortSCCGraph); DebugReportSection topsortSCCGraphSection = getCodeSection(id + "-topsort-scc-graph", "SCC Topological Sort Order", topsortSCCGraph.str()); std::stringstream adornment; translationUnit.getAnalysis<Adornment>()->outputAdornment(adornment); DebugReportSection adornmentSection = getCodeSection(id + "-adornment-display", "Adornment", adornment.str()); translationUnit.getDebugReport().addSection( DebugReportSection(id, title, {datalogSection, precedenceGraphSection, sccGraphSection, topsortSCCGraphSection, adornmentSection}, "")); }
bool AutoScheduleTransformer::transform(AstTranslationUnit& translationUnit) { bool changed = false; if (!Global::config().get("debug-report").empty()) { std::stringstream report; changed = autotune(translationUnit, &report); translationUnit.getDebugReport().addSection( DebugReporter::getCodeSection("auto-schedule", "Auto Schedule Report", report.str())); } else { changed = autotune(translationUnit, nullptr); } return changed; }
bool DebugReporter::transform(AstTranslationUnit& translationUnit) { auto start = std::chrono::high_resolution_clock::now(); bool changed = applySubtransformer(translationUnit, wrappedTransformer.get()); auto end = std::chrono::high_resolution_clock::now(); std::string runtimeStr = "(" + std::to_string(std::chrono::duration<double>(end - start).count()) + "s)"; if (changed) { generateDebugReport(translationUnit, wrappedTransformer->getName(), "After " + wrappedTransformer->getName() + " " + runtimeStr); } else { translationUnit.getDebugReport().addSection(DebugReportSection(wrappedTransformer->getName(), "After " + wrappedTransformer->getName() + " " + runtimeStr + " (unchanged)", {}, "")); } return changed; }
void DebugReporter::generateDebugReport( AstTranslationUnit& translationUnit, const std::string& id, std::string title) { std::stringstream datalogSpec; translationUnit.getProgram()->print(datalogSpec); DebugReportSection datalogSection = getCodeSection(id + "-dl", "Datalog", datalogSpec.str()); std::stringstream typeAnalysis; translationUnit.getAnalysis<TypeAnalysis>()->print(typeAnalysis); DebugReportSection typeAnalysisSection = getCodeSection(id + "-ta", "Type Analysis", typeAnalysis.str()); std::stringstream typeEnvironmentAnalysis; translationUnit.getAnalysis<TypeEnvironmentAnalysis>()->print(typeEnvironmentAnalysis); DebugReportSection typeEnvironmentAnalysisSection = getCodeSection(id + "-tea", "Type Environment Analysis", typeEnvironmentAnalysis.str()); std::stringstream precGraphDot; translationUnit.getAnalysis<PrecedenceGraph>()->print(precGraphDot); DebugReportSection precedenceGraphSection = getDotGraphSection(id + "-prec-graph", "Precedence Graph", precGraphDot.str()); std::stringstream sccGraphDot; translationUnit.getAnalysis<SCCGraph>()->print(sccGraphDot); DebugReportSection sccGraphSection = getDotGraphSection(id + "-scc-graph", "SCC Graph", sccGraphDot.str()); std::stringstream topsortSCCGraph; translationUnit.getAnalysis<TopologicallySortedSCCGraph>()->print(topsortSCCGraph); DebugReportSection topsortSCCGraphSection = getCodeSection(id + "-topsort-scc-graph", "SCC Topological Sort Order", topsortSCCGraph.str()); translationUnit.getDebugReport().addSection(DebugReportSection(id, std::move(title), {datalogSection, typeAnalysisSection, typeEnvironmentAnalysisSection, precedenceGraphSection, sccGraphSection, topsortSCCGraphSection}, "")); }