[PATCH] D57658: [llvm-exegesis] Cut run time of analysis mode by another -52% (*sic*) (YamlContext::getRegNo())

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 3 10:04:05 PST 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: courbet, gchatelet.
lebedev.ri added a project: LLVM.
Herald added a subscriber: tschuett.
lebedev.ri added a parent revision: D57657: [llvm-exegesis] Cut run time of analysis mode by -84% (*sic*) (YamlContext::getInstrOpcode()).

  $ 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


Repository:
  rL LLVM

https://reviews.llvm.org/D57658

Files:
  tools/llvm-exegesis/lib/BenchmarkResult.cpp


Index: tools/llvm-exegesis/lib/BenchmarkResult.cpp
===================================================================
--- tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -31,7 +31,8 @@
 struct YamlContext {
   YamlContext(const exegesis::LLVMState &State)
       : State(&State), ErrorStream(LastError),
-        OpcodeNameToOpcodeIdx(generateOpcodeNameToOpcodeIdxMapping()) {}
+        OpcodeNameToOpcodeIdx(generateOpcodeNameToOpcodeIdxMapping()),
+        RegNameToRegNo(generateRegNameToRegNoMapping()) {}
 
   llvm::StringMap<unsigned> generateOpcodeNameToOpcodeIdxMapping() {
     const llvm::MCInstrInfo &InstrInfo = State->getInstrInfo();
@@ -42,6 +43,15 @@
     return Map;
   };
 
+  llvm::StringMap<unsigned> generateRegNameToRegNoMapping() {
+    const llvm::MCRegisterInfo &RegInfo = State->getRegInfo();
+    llvm::StringMap<unsigned> Map(RegInfo.getNumRegs());
+    for (unsigned I = 0, E = RegInfo.getNumRegs(); I < E; ++I)
+      Map.insert(std::make_pair(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) {
@@ -79,10 +89,9 @@
   }
 
   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;
   }
@@ -158,6 +167,7 @@
   std::string LastError;
   llvm::raw_string_ostream ErrorStream;
   const llvm::StringMap<unsigned> OpcodeNameToOpcodeIdx;
+  const llvm::StringMap<unsigned> RegNameToRegNo;
 };
 } // namespace
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57658.184963.patch
Type: text/x-patch
Size: 1979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190203/089a9273/attachment-0001.bin>


More information about the llvm-commits mailing list