summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/PerfMonitor.cpp
diff options
context:
space:
mode:
authorSiddharth Bhat <siddu.druid@gmail.com>2017-06-02 11:36:52 +0000
committerSiddharth Bhat <siddu.druid@gmail.com>2017-06-02 11:36:52 +0000
commit726c28f8c4951b5852c92afca329bb7b683c1ab3 (patch)
treebc24bd8165e0966835baeb7d57fdbb269584c429 /polly/lib/CodeGen/PerfMonitor.cpp
parent01bf58d6ecd9304a7ab5180ff78f3c78187282f4 (diff)
downloadbcm5719-llvm-726c28f8c4951b5852c92afca329bb7b683c1ab3.tar.gz
bcm5719-llvm-726c28f8c4951b5852c92afca329bb7b683c1ab3.zip
[CodeGen] Track trip counts per-scop for performance measurement.
- Add a counter that is incremented once on exit from a scop. - Test cases got split into two: one to test the cycles, and another one to test trip counts. - Sample output: ```name=sample-output.txt scop function, entry block name, exit block name, total time, trip count warmup, %entry.split, %polly.merge_new_and_old, 5180, 1 f, %entry.split, %polly.merge_new_and_old, 409944, 500 g, %entry.split, %polly.merge_new_and_old, 1226, 1 ``` Differential Revision: https://reviews.llvm.org/D33822 llvm-svn: 304543
Diffstat (limited to 'polly/lib/CodeGen/PerfMonitor.cpp')
-rw-r--r--polly/lib/CodeGen/PerfMonitor.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/polly/lib/CodeGen/PerfMonitor.cpp b/polly/lib/CodeGen/PerfMonitor.cpp
index 5423d5a4fa6..0829934a07d 100644
--- a/polly/lib/CodeGen/PerfMonitor.cpp
+++ b/polly/lib/CodeGen/PerfMonitor.cpp
@@ -87,15 +87,18 @@ static std::string GetScopUniqueVarname(const Scop &S) {
std::string EntryString, ExitString;
std::tie(EntryString, ExitString) = S.getEntryExitStr();
- Name << "__polly_perf_cycles_in_" << std::string(S.getFunction().getName())
+ Name << "__polly_perf_in_" << std::string(S.getFunction().getName())
<< "_from__" << EntryString << "__to__" << ExitString;
return Name.str();
}
void PerfMonitor::addScopCounter() {
const std::string varname = GetScopUniqueVarname(S);
- TryRegisterGlobal(M, varname.c_str(), Builder.getInt64(0),
+ TryRegisterGlobal(M, (varname + "_cycles").c_str(), Builder.getInt64(0),
&CyclesInCurrentScopPtr);
+
+ TryRegisterGlobal(M, (varname + "_trip_count").c_str(), Builder.getInt64(0),
+ &TripCountForCurrentScopPtr);
}
void PerfMonitor::addGlobalVariables() {
@@ -160,7 +163,7 @@ Function *PerfMonitor::insertFinalReporting() {
RuntimeDebugBuilder::createCPUPrinter(
Builder, "scop function, "
- "entry block name, exit block name, total time\n");
+ "entry block name, exit block name, total time, trip count\n");
ReturnFromFinal = Builder.CreateRetVoid();
return ExitFn;
}
@@ -179,13 +182,17 @@ void PerfMonitor::AppendScopReporting() {
Value *CyclesInCurrentScop =
Builder.CreateLoad(this->CyclesInCurrentScopPtr, true);
+
+ Value *TripCountForCurrentScop =
+ Builder.CreateLoad(this->TripCountForCurrentScopPtr, true);
+
std::string EntryName, ExitName;
std::tie(EntryName, ExitName) = S.getEntryExitStr();
// print in CSV for easy parsing with other tools.
- RuntimeDebugBuilder::createCPUPrinter(Builder, S.getFunction().getName(),
- ", ", EntryName, ", ", ExitName, ", ",
- CyclesInCurrentScop, "\n");
+ RuntimeDebugBuilder::createCPUPrinter(
+ Builder, S.getFunction().getName(), ", ", EntryName, ", ", ExitName, ", ",
+ CyclesInCurrentScop, ", ", TripCountForCurrentScop, "\n");
ReturnFromFinal = Builder.CreateRetVoid();
}
@@ -288,4 +295,11 @@ void PerfMonitor::insertRegionEnd(Instruction *InsertBefore) {
Value *CyclesInCurrentScop = Builder.CreateLoad(CyclesInCurrentScopPtr, true);
CyclesInCurrentScop = Builder.CreateAdd(CyclesInCurrentScop, CyclesInScop);
Builder.CreateStore(CyclesInCurrentScop, CyclesInCurrentScopPtr, true);
+
+ Value *TripCountForCurrentScop =
+ Builder.CreateLoad(TripCountForCurrentScopPtr, true);
+ TripCountForCurrentScop =
+ Builder.CreateAdd(TripCountForCurrentScop, Builder.getInt64(1));
+ Builder.CreateStore(TripCountForCurrentScop, TripCountForCurrentScopPtr,
+ true);
}
OpenPOWER on IntegriCloud