[llvm-exegesis] Analysis: detect clustering inconsistencies.
Summary:
Warn on instructions that should have the same performance
characteristics according to the sched model but actually
differ in their benchmarks.
Next step: Make the display nicer to browse, I was thinking maybe html.
Reviewers: gchatelet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D46945
llvm-svn: 332601
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.h b/llvm/tools/llvm-exegesis/lib/Analysis.h
index 64de23c..dcfaf34 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.h
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.h
@@ -18,8 +18,8 @@
#include "Clustering.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <unordered_map>
@@ -29,19 +29,28 @@
// A helper class to analyze benchmark results for a target.
class Analysis {
public:
- Analysis(const llvm::Target& Target, const InstructionBenchmarkClustering &Clustering);
+ Analysis(const llvm::Target &Target,
+ const InstructionBenchmarkClustering &Clustering);
// Prints a csv of instructions for each cluster.
llvm::Error printClusters(llvm::raw_ostream &OS) const;
- private:
- void printInstructionRow(size_t ClusterId, size_t PointId,
- llvm::raw_ostream &OS) const;
+ // Find potential errors in the scheduling information given measurements.
+ llvm::Error printSchedClassInconsistencies(llvm::raw_ostream &OS) const;
- const InstructionBenchmarkClustering & Clustering_;
- std::unique_ptr<llvm::MCSubtargetInfo> SubtargetInfo_;
- std::unique_ptr<llvm::MCInstrInfo> InstrInfo_;
- std::unordered_map<std::string, unsigned> MnemonicToOpcode_;
+private:
+ void printInstructionRow(bool PrintSchedClass, size_t PointId,
+ llvm::raw_ostream &OS) const;
+
+ // Builds a map of Sched Class -> indices of points that belong to the sched
+ // class.
+ std::unordered_map<unsigned, std::vector<size_t>>
+ makePointsPerSchedClass() const;
+
+ const InstructionBenchmarkClustering &Clustering_;
+ std::unique_ptr<llvm::MCSubtargetInfo> SubtargetInfo_;
+ std::unique_ptr<llvm::MCInstrInfo> InstrInfo_;
+ std::unordered_map<std::string, unsigned> MnemonicToOpcode_;
};
} // namespace exegesis