[llvm] 18da9a0 - [llvm-exegesis] Fix 'min' repetition mode in presence of missing measurements

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 18 06:52:20 PST 2022


Author: Roman Lebedev
Date: 2022-12-18T17:52:04+03:00
New Revision: 18da9a0cb35c3849e47625272e477dbc5544e25b

URL: https://github.com/llvm/llvm-project/commit/18da9a0cb35c3849e47625272e477dbc5544e25b
DIFF: https://github.com/llvm/llvm-project/commit/18da9a0cb35c3849e47625272e477dbc5544e25b.diff

LOG: [llvm-exegesis] Fix 'min' repetition mode in presence of missing measurements

This was a regression from 17e202424c021fd903950fec7a8b6cca2d83abce.
Previously we'd gracefully handle missing measurements,
but that handling got accidentally lost during the code move,
and we'd assert.

What we want to do, is to discard all measurements (from all repetitors
in a given config) if any of them failed, but do append the snippet,
and do emit the empty measurement.

Added: 
    

Modified: 
    llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
    llvm/tools/llvm-exegesis/llvm-exegesis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
index 9f6a5486b3ca..2598c04cb09d 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
@@ -1,5 +1,6 @@
 # RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=duplicate | FileCheck %s
 # RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=loop | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=min | FileCheck %s
 
 CHECK:      ---
 CHECK-NEXT: mode: latency

diff  --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index c17a29b2c34c..459e9800f083 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -348,14 +348,21 @@ static void runBenchmarkConfigurations(
     }
     InstructionBenchmark &Result = AllResults.front();
 
+    // If any of our measurements failed, pretend they all have failed.
+    if (AllResults.size() > 1 &&
+        any_of(AllResults, [](const InstructionBenchmark &R) {
+          return R.Measurements.empty();
+        }))
+      Result.Measurements.clear();
+
     if (RepetitionMode == InstructionBenchmark::RepetitionModeE::AggregateMin) {
-      assert(!Result.Measurements.empty() &&
-             "We're in an 'min' repetition mode, and need to aggregate new "
-             "result to the existing result.");
       for (const InstructionBenchmark &OtherResult :
            ArrayRef<InstructionBenchmark>(AllResults).drop_front()) {
         llvm::append_range(Result.AssembledSnippet,
                            OtherResult.AssembledSnippet);
+        // Aggregate measurements, but only iff all measurements succeeded.
+        if (Result.Measurements.empty())
+          continue;
         assert(OtherResult.Measurements.size() == Result.Measurements.size() &&
                "Expected to have identical number of measurements.");
         for (auto I : zip(Result.Measurements, OtherResult.Measurements)) {


        


More information about the llvm-commits mailing list