diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-03-29 11:36:08 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-03-29 11:36:08 +0000 |
| commit | b8fb15d4122b04d620c1d4a89449b6eba2f4b0c0 (patch) | |
| tree | a4583c4fd8f1064a6e2b3b5760ff74332396adc8 /llvm/tools/llvm-exegesis/lib/Clustering.cpp | |
| parent | aeaf7fcddeefe733c87f69d88265f9e27540e5ec (diff) | |
| download | bcm5719-llvm-b8fb15d4122b04d620c1d4a89449b6eba2f4b0c0.tar.gz bcm5719-llvm-b8fb15d4122b04d620c1d4a89449b6eba2f4b0c0.zip | |
[NFC][llvm-exegesis] Refactor Analysis::SchedClassCluster::measurementsMatch()
Summary:
The diff looks scary but it really isn't:
1. I moved the check for the number of measurements into `SchedClassClusterCentroid::validate()`
2. While there, added a check that we can only have a single inverse throughput measurement. I missed that when adding it initially.
3. In `Analysis::SchedClassCluster::measurementsMatch()` is called with the current LLVM values from schedule class and the values from Centroid.
3.1. The values from centroid we can already get from `SchedClassClusterCentroid::getAsPoint()`.
This isn't 100% a NFC, because previously for inverse throughput we used `min()`. I have asked whether i have done that correctly in
https://reviews.llvm.org/D57647?id=184939#inline-510384 but did not hear back. I think `avg()` should be used too, thus it is a fix.
3.2. Finally, refactor the computation of the LLVM-specified values into `Analysis::SchedClassCluster::getSchedClassPoint()`
I will need that function for [[ https://bugs.llvm.org/show_bug.cgi?id=41275 | PR41275 ]]
Reviewers: courbet, gchatelet
Reviewed By: courbet
Subscribers: tschuett, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59951
llvm-svn: 357245
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Clustering.cpp')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/Clustering.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Clustering.cpp b/llvm/tools/llvm-exegesis/lib/Clustering.cpp index 2a8cc453be0..398bbf776af 100644 --- a/llvm/tools/llvm-exegesis/lib/Clustering.cpp +++ b/llvm/tools/llvm-exegesis/lib/Clustering.cpp @@ -363,5 +363,36 @@ std::vector<BenchmarkMeasure> SchedClassClusterCentroid::getAsPoint() const { return ClusterCenterPoint; } +bool SchedClassClusterCentroid::validate( + InstructionBenchmark::ModeE Mode) const { + size_t NumMeasurements = Representative.size(); + switch (Mode) { + case InstructionBenchmark::Latency: + if (NumMeasurements != 1) { + llvm::errs() + << "invalid number of measurements in latency mode: expected 1, got " + << NumMeasurements << "\n"; + return false; + } + break; + case InstructionBenchmark::Uops: + // Can have many measurements. + break; + case InstructionBenchmark::InverseThroughput: + if (NumMeasurements != 1) { + llvm::errs() << "invalid number of measurements in inverse throughput " + "mode: expected 1, got " + << NumMeasurements << "\n"; + return false; + } + break; + default: + llvm_unreachable("unimplemented measurement matching mode"); + return false; + } + + return true; // All good. +} + } // namespace exegesis } // namespace llvm |

