diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-02-04 09:12:25 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-02-04 09:12:25 +0000 |
| commit | bd84b139b0728c89ee87eaf43e6fae01f5a7c9f6 (patch) | |
| tree | 1b923be929d297d7bd0667849de3627afe2dead1 | |
| parent | 5b94fe96234455ee285caa0774025be9016a1a91 (diff) | |
| download | bcm5719-llvm-bd84b139b0728c89ee87eaf43e6fae01f5a7c9f6.tar.gz bcm5719-llvm-bd84b139b0728c89ee87eaf43e6fae01f5a7c9f6.zip | |
[llvm-exegesis] Cut run time of analysis mode by another -35% (*sic*) (YamlContext::getRegNo())
Summary:
Together with the previous patch, it's an -90% improvement,
or roughly -96% improvement if you look starting with rL347204
```
$ perf stat -r 9 ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=1.0 -benchmarks-file=/tmp/benchmarks-inverse_throughput-onefull.yaml -analysis-clusters-output-file="" -analysis-inconsistencies-output-file=/tmp/clusters-bew.html
no exegesis target for x86_64-unknown-linux-gnu, using default
Parsed 14656 benchmark points
Printing sched class consistency analysis results to file '/tmp/clusters-bew.html'
...
no exegesis target for x86_64-unknown-linux-gnu, using default
Parsed 14656 benchmark points
Printing sched class consistency analysis results to file '/tmp/clusters-bew.html'
Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=1.0 -benchmarks-file=/tmp/benchmarks-inverse_throughput-onefull.yaml -analysis-clusters-output-file= -analysis-inconsistencies-output-file=/tmp/clusters-bew.html' (9 runs):
1483.18 msec task-clock # 0.999 CPUs utilized ( +- 0.10% )
68 context-switches # 46.085 M/sec ( +- 22.62% )
0 cpu-migrations # 0.000 K/sec
11641 page-faults # 7850.880 M/sec ( +- 0.62% )
5943246799 cycles # 4008184.428 GHz ( +- 0.10% ) (83.28%)
442869514 stalled-cycles-frontend # 7.45% frontend cycles idle ( +- 0.41% ) (83.29%)
1443375663 stalled-cycles-backend # 24.29% backend cycles idle ( +- 0.47% ) (33.43%)
7714006752 instructions # 1.30 insn per cycle
# 0.19 stalled cycles per insn ( +- 0.07% ) (50.17%)
1977242936 branches # 1333472193.855 M/sec ( +- 0.07% ) (66.79%)
32624220 branch-misses # 1.65% of all branches ( +- 0.18% ) (83.34%)
1.48438 +- 0.00143 seconds time elapsed ( +- 0.10% )
```
```
$ perf stat -r 9 ./bin/llvm-exegesis -mode=analysis -analysis-epsilon=1.0 -benchmarks-file=/tmp/benchmarks-inverse_throughput-onefull.yaml -analysis-clusters-output-file="" -analysis-inconsistencies-output-file=/tmp/clusters-newer.html
no exegesis target for x86_64-unknown-linux-gnu, using default
Parsed 14656 benchmark points
Printing sched class consistency analysis results to file '/tmp/clusters-newer.html'
...
no exegesis target for x86_64-unknown-linux-gnu, using default
Parsed 14656 benchmark points
Printing sched class consistency analysis results to file '/tmp/clusters-newer.html'
Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=1.0 -benchmarks-file=/tmp/benchmarks-inverse_throughput-onefull.yaml -analysis-clusters-output-file= -analysis-inconsistencies-output-file=/tmp/clusters-newer.html' (9 runs):
963.28 msec task-clock # 0.999 CPUs utilized ( +- 0.37% )
12 context-switches # 12.695 M/sec ( +- 52.79% )
0 cpu-migrations # 0.000 K/sec
11599 page-faults # 12046.971 M/sec ( +- 0.59% )
3860122322 cycles # 4009359.596 GHz ( +- 0.37% ) (83.19%)
380300669 stalled-cycles-frontend # 9.85% frontend cycles idle ( +- 0.34% ) (83.30%)
1071910340 stalled-cycles-backend # 27.77% backend cycles idle ( +- 1.30% ) (33.51%)
4773418224 instructions # 1.24 insn per cycle
# 0.22 stalled cycles per insn ( +- 0.15% ) (50.17%)
1106990316 branches # 1149787979.919 M/sec ( +- 0.11% ) (66.80%)
23632231 branch-misses # 2.13% of all branches ( +- 0.18% ) (83.33%)
0.96389 +- 0.00356 seconds time elapsed ( +- 0.37% )
```
```
$ sha512sum /tmp/clusters-*
db4bbd904fe8840853b589b032c5041bc060b91bcd9c27b914b56581fbc473550eea74b852238c79963b5adf2419f379e9f5db76784048b48e3937f9f3e732bf /tmp/clusters-bew.html
db4bbd904fe8840853b589b032c5041bc060b91bcd9c27b914b56581fbc473550eea74b852238c79963b5adf2419f379e9f5db76784048b48e3937f9f3e732bf /tmp/clusters-newer.html
db4bbd904fe8840853b589b032c5041bc060b91bcd9c27b914b56581fbc473550eea74b852238c79963b5adf2419f379e9f5db76784048b48e3937f9f3e732bf /tmp/clusters-old.html
```
Reviewers: courbet, gchatelet
Reviewed By: courbet
Subscribers: tschuett, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D57658
llvm-svn: 353025
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 1dd413a2912..c7a0c8470bb 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -32,7 +32,8 @@ struct YamlContext { YamlContext(const exegesis::LLVMState &State) : State(&State), ErrorStream(LastError), OpcodeNameToOpcodeIdx( - generateOpcodeNameToOpcodeIdxMapping(State.getInstrInfo())) {} + generateOpcodeNameToOpcodeIdxMapping(State.getInstrInfo())), + RegNameToRegNo(generateRegNameToRegNoMapping(State.getRegInfo())) {} static llvm::StringMap<unsigned> generateOpcodeNameToOpcodeIdxMapping(const llvm::MCInstrInfo &InstrInfo) { @@ -43,6 +44,15 @@ struct YamlContext { return Map; }; + llvm::StringMap<unsigned> + generateRegNameToRegNoMapping(const llvm::MCRegisterInfo &RegInfo) { + llvm::StringMap<unsigned> Map(RegInfo.getNumRegs()); + for (unsigned I = 0, E = RegInfo.getNumRegs(); I < E; ++I) + Map[RegInfo.getName(I)] = I; + assert(Map.size() == RegInfo.getNumRegs() && "Size prediction failed"); + return Map; + }; + void serializeMCInst(const llvm::MCInst &MCInst, llvm::raw_ostream &OS) { OS << getInstrName(MCInst.getOpcode()); for (const auto &Op : MCInst) { @@ -80,10 +90,9 @@ struct YamlContext { } unsigned getRegNo(llvm::StringRef RegName) { - const llvm::MCRegisterInfo &RegInfo = State->getRegInfo(); - for (unsigned E = RegInfo.getNumRegs(), I = 0; I < E; ++I) - if (RegInfo.getName(I) == RegName) - return I; + auto Iter = RegNameToRegNo.find(RegName); + if (Iter != RegNameToRegNo.end()) + return Iter->second; ErrorStream << "No register with name " << RegName; return 0; } @@ -159,6 +168,7 @@ private: std::string LastError; llvm::raw_string_ostream ErrorStream; const llvm::StringMap<unsigned> OpcodeNameToOpcodeIdx; + const llvm::StringMap<unsigned> RegNameToRegNo; }; } // namespace |

