[polly] r304533 - [CodeGen] Print performance counter information in CSV.

Siddharth Bhat via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 02:20:03 PDT 2017


Author: bollu
Date: Fri Jun  2 04:20:02 2017
New Revision: 304533

URL: http://llvm.org/viewvc/llvm-project?rev=304533&view=rev
Log:
[CodeGen] Print performance counter information in CSV.

This ensures that tools can parse performance information which Polly
generates easily.

- Sample output:
```name=out.csv
scop function, entry block name, exit block name, total time
warmup, %entry.split, %polly.merge_new_and_old, 1960
f, %entry.split, %polly.merge_new_and_old, 1238
g, %entry.split, %polly.merge_new_and_old, 1218
```

- Example code to parse output:
```lang=python, name=example-parse.py
import asciitable
import sys

table = asciitable.read('out.csv', delimiter=',')
asciitable.write(table, sys.stdout, delimiter=',')
```

Modified:
    polly/trunk/lib/CodeGen/PerfMonitor.cpp
    polly/trunk/test/Isl/CodeGen/perf_monitoring_per_scop.ll

Modified: polly/trunk/lib/CodeGen/PerfMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PerfMonitor.cpp?rev=304533&r1=304532&r2=304533&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PerfMonitor.cpp (original)
+++ polly/trunk/lib/CodeGen/PerfMonitor.cpp Fri Jun  2 04:20:02 2017
@@ -152,6 +152,15 @@ Function *PerfMonitor::insertFinalReport
   RuntimeDebugBuilder::createCPUPrinter(Builder, "Total: ", CyclesTotal, "\n");
   RuntimeDebugBuilder::createCPUPrinter(Builder, "Scops: ", CyclesInScops,
                                         "\n");
+
+  // Print the preamble for per-scop information.
+  RuntimeDebugBuilder::createCPUPrinter(Builder, "\n");
+  RuntimeDebugBuilder::createCPUPrinter(Builder, "Per SCoP information\n");
+  RuntimeDebugBuilder::createCPUPrinter(Builder, "--------------------\n");
+
+  RuntimeDebugBuilder::createCPUPrinter(
+      Builder, "scop function, "
+               "entry block name, exit block name, total time\n");
   ReturnFromFinal = Builder.CreateRetVoid();
   return ExitFn;
 }
@@ -173,9 +182,10 @@ void PerfMonitor::AppendScopReporting()
   std::string EntryName, ExitName;
   std::tie(EntryName, ExitName) = S.getEntryExitStr();
 
-  RuntimeDebugBuilder::createCPUPrinter(
-      Builder, "Scop(", S.getFunction().getName(), " |from: ", EntryName,
-      " |to: ", ExitName, "): ", CyclesInCurrentScop, "\n");
+  // print in CSV for easy parsing with other tools.
+  RuntimeDebugBuilder::createCPUPrinter(Builder, S.getFunction().getName(),
+                                        ", ", EntryName, ", ", ExitName, ", ",
+                                        CyclesInCurrentScop, "\n");
 
   ReturnFromFinal = Builder.CreateRetVoid();
 }

Modified: polly/trunk/test/Isl/CodeGen/perf_monitoring_per_scop.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/perf_monitoring_per_scop.ll?rev=304533&r1=304532&r2=304533&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/perf_monitoring_per_scop.ll (original)
+++ polly/trunk/test/Isl/CodeGen/perf_monitoring_per_scop.ll Fri Jun  2 04:20:02 2017
@@ -91,10 +91,8 @@ return:
 ; CHECK-NEXT:   br label %return
 
 ; Final reporting prints
-; CHECK:       %12 = load volatile i64, i64* @"__polly_perf_cycles_in_f_from__%next__to__%polly.merge_new_and_old"
-; CHECK-NEXT:  %13 = call i32 (...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @18, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @10, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @11, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([9 x i8], [9 x i8] addrspace(4)* @12, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @13, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @14, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([25 x i8], [25 x i8] addrspace(4)* @15, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([4 x i8], [4 x i8] addrspace(4)* @16, i32 0, i32 0), i64 %12, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @17, i32 0, i32 0))
-; CHECK-NEXT:  %14 = call i32 @fflush(i8* null)
-; CHECK-NEXT:  %15 = load volatile i64, i64* @"__polly_perf_cycles_in_g_from__%next__to__%polly.merge_new_and_old"
-; CHECK-NEXT:  %16 = call i32 (...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @27, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @19, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @20, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([9 x i8], [9 x i8] addrspace(4)* @21, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @22, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @23, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([25 x i8], [25 x i8] addrspace(4)* @24, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([4 x i8], [4 x i8] addrspace(4)* @25, i32 0, i32 0), i64 %15, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @26, i32 0, i32 0))
-; CHECK-NEXT:  %17 = call i32 @fflush(i8* null)
-; CHECK-NEXT:  ret void
+; CHECK:        %20 = load volatile i64, i64* @"__polly_perf_cycles_in_f_from__%next__to__%polly.merge_new_and_old"
+; CHECK-NEXT:   %21 = call i32 (...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @25, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @18, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @19, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @20, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @21, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([25 x i8], [25 x i8] addrspace(4)* @22, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @23, i32 0, i32 0), i64 %20, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @24, i32 0, i32 0))
+; CHECK-NEXT:   %22 = call i32 @fflush(i8* null)
+; CHECK-NEXT:   %23 = load volatile i64, i64* @"__polly_perf_cycles_in_g_from__%next__to__%polly.merge_new_and_old"
+; CHECK-NEXT:   %24 = call i32 (...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @33, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @26, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @27, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(4)* @28, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @29, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([25 x i8], [25 x i8] addrspace(4)* @30, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @31, i32 0, i32 0), i64 %23, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @32, i32 0, i32 0))




More information about the llvm-commits mailing list