diff options
author | Aiden Grossman <agrossman154@yahoo.com> | 2023-03-27 08:14:18 +0000 |
---|---|---|
committer | Aiden Grossman <agrossman154@yahoo.com> | 2023-03-27 08:14:36 +0000 |
commit | 389bf5d870b3bc014b004a750c539786eba8c543 (patch) | |
tree | 606bd882a523b34f5caefa2596716306819cc829 /llvm/tools | |
parent | 4a9dc94d336ab0c68d718db21d1666ac19868642 (diff) | |
download | llvm-389bf5d870b3bc014b004a750c539786eba8c543.zip llvm-389bf5d870b3bc014b004a750c539786eba8c543.tar.gz llvm-389bf5d870b3bc014b004a750c539786eba8c543.tar.bz2 |
[llvm-exegesis] Refactor InstructionBenchmark to Benchmark
When llvm-exegesis was first introduced, it only supported benchmarking
individual instructions, hence the name for the data structure storing
the data corresponding to a benchmark being called InstructionBenchmark
made sense. However, now that benchmarking arbitrary snippets is
supported, InstructionBenchmark doesn't correspond to a single
instruction. This patch refactors InstructionBenchmark to be called
Benchmark to clean up this little bit of technical debt.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D146884
Diffstat (limited to 'llvm/tools')
20 files changed, 180 insertions, 180 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index 2d7e17f..f6ee8f6 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -71,7 +71,7 @@ void writeEscaped<kEscapeHtmlString>(raw_ostream &OS, const StringRef S) { template <EscapeTag Tag> static void writeClusterId(raw_ostream &OS, - const InstructionBenchmarkClustering::ClusterId &CID) { + const BenchmarkClustering::ClusterId &CID) { if (CID.isNoise()) writeEscaped<Tag>(OS, "[noise]"); else if (CID.isError()) @@ -126,7 +126,7 @@ void Analysis::writeSnippet(raw_ostream &OS, ArrayRef<uint8_t> Bytes, // point coordinates (measurements). void Analysis::printInstructionRowCsv(const size_t PointId, raw_ostream &OS) const { - const InstructionBenchmark &Point = Clustering_.getPoints()[PointId]; + const Benchmark &Point = Clustering_.getPoints()[PointId]; writeClusterId<kEscapeCsv>(OS, Clustering_.getClusterIdForPoint(PointId)); OS << kCsvSep; writeSnippet<EscapeTag, kEscapeCsv>(OS, Point.AssembledSnippet, "; "); @@ -153,7 +153,7 @@ void Analysis::printInstructionRowCsv(const size_t PointId, } Analysis::Analysis(const LLVMState &State, - const InstructionBenchmarkClustering &Clustering, + const BenchmarkClustering &Clustering, double AnalysisInconsistencyEpsilon, bool AnalysisDisplayUnstableOpcodes) : Clustering_(Clustering), State_(State), @@ -215,7 +215,7 @@ Analysis::makePointsPerSchedClass() const { std::unordered_map<unsigned, size_t> SchedClassIdToIndex; const auto &Points = Clustering_.getPoints(); for (size_t PointId = 0, E = Points.size(); PointId < E; ++PointId) { - const InstructionBenchmark &Point = Points[PointId]; + const Benchmark &Point = Points[PointId]; if (!Point.Error.empty()) continue; assert(!Point.Key.Instructions.empty()); @@ -270,17 +270,17 @@ static void writeLatencySnippetHtml(raw_ostream &OS, } } -void Analysis::printPointHtml(const InstructionBenchmark &Point, +void Analysis::printPointHtml(const Benchmark &Point, llvm::raw_ostream &OS) const { OS << "<li><span class=\"mono\" title=\""; writeSnippet<EscapeTag, kEscapeHtmlString>(OS, Point.AssembledSnippet, "\n"); OS << "\">"; switch (Point.Mode) { - case InstructionBenchmark::Latency: + case Benchmark::Latency: writeLatencySnippetHtml(OS, Point.Key.Instructions, State_.getInstrInfo()); break; - case InstructionBenchmark::Uops: - case InstructionBenchmark::InverseThroughput: + case Benchmark::Uops: + case Benchmark::InverseThroughput: writeParallelSnippetHtml(OS, Point.Key.Instructions, State_.getInstrInfo()); break; default: @@ -334,7 +334,7 @@ void Analysis::printSchedClassClustersHtml( } void Analysis::SchedClassCluster::addPoint( - size_t PointId, const InstructionBenchmarkClustering &Clustering) { + size_t PointId, const BenchmarkClustering &Clustering) { PointIds.push_back(PointId); const auto &Point = Clustering.getPoints()[PointId]; if (ClusterId.isUndef()) @@ -346,10 +346,10 @@ void Analysis::SchedClassCluster::addPoint( bool Analysis::SchedClassCluster::measurementsMatch( const MCSubtargetInfo &STI, const ResolvedSchedClass &RSC, - const InstructionBenchmarkClustering &Clustering, + const BenchmarkClustering &Clustering, const double AnalysisInconsistencyEpsilonSquared_) const { assert(!Clustering.getPoints().empty()); - const InstructionBenchmark::ModeE Mode = Clustering.getPoints()[0].Mode; + const Benchmark::ModeE Mode = Clustering.getPoints()[0].Mode; if (!Centroid.validate(Mode)) return false; @@ -427,7 +427,7 @@ void Analysis::printSchedClassDescHtml(const ResolvedSchedClass &RSC, } void Analysis::printClusterRawHtml( - const InstructionBenchmarkClustering::ClusterId &Id, StringRef display_name, + const BenchmarkClustering::ClusterId &Id, StringRef display_name, llvm::raw_ostream &OS) const { const auto &Points = Clustering_.getPoints(); const auto &Cluster = Clustering_.getCluster(Id); @@ -589,7 +589,7 @@ Error Analysis::run<Analysis::PrintSchedClassInconsistencies>( OS << "</div>"; } - printClusterRawHtml(InstructionBenchmarkClustering::ClusterId::noise(), + printClusterRawHtml(BenchmarkClustering::ClusterId::noise(), "[noise]", OS); OS << "</body></html>"; diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.h b/llvm/tools/llvm-exegesis/lib/Analysis.h index a903fd2..3271925 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.h +++ b/llvm/tools/llvm-exegesis/lib/Analysis.h @@ -37,7 +37,7 @@ namespace exegesis { class Analysis { public: Analysis(const LLVMState &State, - const InstructionBenchmarkClustering &Clustering, + const BenchmarkClustering &Clustering, double AnalysisInconsistencyEpsilon, bool AnalysisDisplayUnstableOpcodes); @@ -49,19 +49,19 @@ public: template <typename Pass> Error run(raw_ostream &OS) const; private: - using ClusterId = InstructionBenchmarkClustering::ClusterId; + using ClusterId = BenchmarkClustering::ClusterId; // Represents the intersection of a sched class and a cluster. class SchedClassCluster { public: - const InstructionBenchmarkClustering::ClusterId &id() const { + const BenchmarkClustering::ClusterId &id() const { return ClusterId; } const std::vector<size_t> &getPointIds() const { return PointIds; } void addPoint(size_t PointId, - const InstructionBenchmarkClustering &Clustering); + const BenchmarkClustering &Clustering); // Return the cluster centroid. const SchedClassClusterCentroid &getCentroid() const { return Centroid; } @@ -69,11 +69,11 @@ private: // Returns true if the cluster representative measurements match that of SC. bool measurementsMatch(const MCSubtargetInfo &STI, const ResolvedSchedClass &SC, - const InstructionBenchmarkClustering &Clustering, + const BenchmarkClustering &Clustering, const double AnalysisInconsistencyEpsilonSquared_) const; private: - InstructionBenchmarkClustering::ClusterId ClusterId; + BenchmarkClustering::ClusterId ClusterId; std::vector<size_t> PointIds; // Measurement stats for the points in the SchedClassCluster. SchedClassClusterCentroid Centroid; @@ -81,10 +81,10 @@ private: void printInstructionRowCsv(size_t PointId, raw_ostream &OS) const; - void printClusterRawHtml(const InstructionBenchmarkClustering::ClusterId &Id, + void printClusterRawHtml(const BenchmarkClustering::ClusterId &Id, StringRef display_name, llvm::raw_ostream &OS) const; - void printPointHtml(const InstructionBenchmark &Point, + void printPointHtml(const Benchmark &Point, llvm::raw_ostream &OS) const; void @@ -110,7 +110,7 @@ private: void writeSnippet(raw_ostream &OS, ArrayRef<uint8_t> Bytes, const char *Separator) const; - const InstructionBenchmarkClustering &Clustering_; + const BenchmarkClustering &Clustering_; const LLVMState &State_; std::unique_ptr<MCContext> Context_; std::unique_ptr<MCAsmInfo> AsmInfo_; diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkCode.h b/llvm/tools/llvm-exegesis/lib/BenchmarkCode.h index 7dceb25..1db8472 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkCode.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkCode.h @@ -19,7 +19,7 @@ namespace exegesis { // A collection of instructions that are to be assembled, executed and measured. struct BenchmarkCode { - InstructionBenchmarkKey Key; + BenchmarkKey Key; // We also need to provide the registers that are live on entry for the // assembler to generate proper prologue/epilogue. diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 673221e..b8e53de 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -209,14 +209,14 @@ template <> struct MappingTraits<exegesis::BenchmarkMeasure> { }; template <> -struct ScalarEnumerationTraits<exegesis::InstructionBenchmark::ModeE> { +struct ScalarEnumerationTraits<exegesis::Benchmark::ModeE> { static void enumeration(IO &Io, - exegesis::InstructionBenchmark::ModeE &Value) { - Io.enumCase(Value, "", exegesis::InstructionBenchmark::Unknown); - Io.enumCase(Value, "latency", exegesis::InstructionBenchmark::Latency); - Io.enumCase(Value, "uops", exegesis::InstructionBenchmark::Uops); + exegesis::Benchmark::ModeE &Value) { + Io.enumCase(Value, "", exegesis::Benchmark::Unknown); + Io.enumCase(Value, "latency", exegesis::Benchmark::Latency); + Io.enumCase(Value, "uops", exegesis::Benchmark::Uops); Io.enumCase(Value, "inverse_throughput", - exegesis::InstructionBenchmark::InverseThroughput); + exegesis::Benchmark::InverseThroughput); } }; @@ -260,8 +260,8 @@ template <> struct ScalarTraits<exegesis::RegisterValue> { }; template <> -struct MappingContextTraits<exegesis::InstructionBenchmarkKey, YamlContext> { - static void mapping(IO &Io, exegesis::InstructionBenchmarkKey &Obj, +struct MappingContextTraits<exegesis::BenchmarkKey, YamlContext> { + static void mapping(IO &Io, exegesis::BenchmarkKey &Obj, YamlContext &Context) { Io.setContext(&Context); Io.mapRequired("instructions", Obj.Instructions); @@ -271,7 +271,7 @@ struct MappingContextTraits<exegesis::InstructionBenchmarkKey, YamlContext> { }; template <> -struct MappingContextTraits<exegesis::InstructionBenchmark, YamlContext> { +struct MappingContextTraits<exegesis::Benchmark, YamlContext> { struct NormalizedBinary { NormalizedBinary(IO &io) {} NormalizedBinary(IO &, std::vector<uint8_t> &Data) : Binary(Data) {} @@ -288,7 +288,7 @@ struct MappingContextTraits<exegesis::InstructionBenchmark, YamlContext> { BinaryRef Binary; }; - static void mapping(IO &Io, exegesis::InstructionBenchmark &Obj, + static void mapping(IO &Io, exegesis::Benchmark &Obj, YamlContext &Context) { Io.mapRequired("mode", Obj.Mode); Io.mapRequired("key", Obj.Key, Context); @@ -305,9 +305,9 @@ struct MappingContextTraits<exegesis::InstructionBenchmark, YamlContext> { } }; -template <> struct MappingTraits<exegesis::InstructionBenchmark::TripleAndCpu> { +template <> struct MappingTraits<exegesis::Benchmark::TripleAndCpu> { static void mapping(IO &Io, - exegesis::InstructionBenchmark::TripleAndCpu &Obj) { + exegesis::Benchmark::TripleAndCpu &Obj) { assert(!Io.outputting() && "can only read TripleAndCpu"); // Read triple. Io.mapRequired("llvm_triple", Obj.LLVMTriple); @@ -320,8 +320,8 @@ template <> struct MappingTraits<exegesis::InstructionBenchmark::TripleAndCpu> { namespace exegesis { -Expected<std::set<InstructionBenchmark::TripleAndCpu>> -InstructionBenchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) { +Expected<std::set<Benchmark::TripleAndCpu>> +Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) { // We're only mapping a field, drop other fields and silence the corresponding // warnings. yaml::Input Yin( @@ -340,11 +340,11 @@ InstructionBenchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) { return Result; } -Expected<InstructionBenchmark> -InstructionBenchmark::readYaml(const LLVMState &State, MemoryBufferRef Buffer) { +Expected<Benchmark> +Benchmark::readYaml(const LLVMState &State, MemoryBufferRef Buffer) { yaml::Input Yin(Buffer); YamlContext Context(State); - InstructionBenchmark Benchmark; + Benchmark Benchmark; if (Yin.setCurrentDocument()) yaml::yamlize(Yin, Benchmark, /*unused*/ true, Context); if (!Context.getLastError().empty()) @@ -352,12 +352,12 @@ InstructionBenchmark::readYaml(const LLVMState &State, MemoryBufferRef Buffer) { return std::move(Benchmark); } -Expected<std::vector<InstructionBenchmark>> -InstructionBenchmark::readYamls(const LLVMState &State, +Expected<std::vector<Benchmark>> +Benchmark::readYamls(const LLVMState &State, MemoryBufferRef Buffer) { yaml::Input Yin(Buffer); YamlContext Context(State); - std::vector<InstructionBenchmark> Benchmarks; + std::vector<Benchmark> Benchmarks; while (Yin.setCurrentDocument()) { Benchmarks.emplace_back(); yamlize(Yin, Benchmarks.back(), /*unused*/ true, Context); @@ -370,7 +370,7 @@ InstructionBenchmark::readYamls(const LLVMState &State, return std::move(Benchmarks); } -Error InstructionBenchmark::writeYamlTo(const LLVMState &State, +Error Benchmark::writeYamlTo(const LLVMState &State, raw_ostream &OS) { auto Cleanup = make_scope_exit([&] { OS.flush(); }); yaml::Output Yout(OS, nullptr /*Ctx*/, 200 /*WrapColumn*/); @@ -383,7 +383,7 @@ Error InstructionBenchmark::writeYamlTo(const LLVMState &State, return Error::success(); } -Error InstructionBenchmark::readYamlFrom(const LLVMState &State, +Error Benchmark::readYamlFrom(const LLVMState &State, StringRef InputContent) { yaml::Input Yin(InputContent); YamlContext Context(State); diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h index a2a8095..0ad18ce 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h @@ -41,9 +41,9 @@ enum class BenchmarkPhaseSelectorE { Measure, }; -enum class InstructionBenchmarkFilter { All, RegOnly, WithMem }; +enum class BenchmarkFilter { All, RegOnly, WithMem }; -struct InstructionBenchmarkKey { +struct BenchmarkKey { // The LLVM opcode name. std::vector<MCInst> Instructions; // The initial values of the registers. @@ -68,8 +68,8 @@ struct BenchmarkMeasure { }; // The result of an instruction benchmark. -struct InstructionBenchmark { - InstructionBenchmarkKey Key; +struct Benchmark { + BenchmarkKey Key; enum ModeE { Unknown, Latency, Uops, InverseThroughput }; ModeE Mode; std::string CpuName; @@ -88,18 +88,18 @@ struct InstructionBenchmark { // How to aggregate measurements. enum ResultAggregationModeE { Min, Max, Mean, MinVariance }; - InstructionBenchmark() = default; - InstructionBenchmark(InstructionBenchmark &&) = default; + Benchmark() = default; + Benchmark(Benchmark &&) = default; - InstructionBenchmark(const InstructionBenchmark &) = delete; - InstructionBenchmark &operator=(const InstructionBenchmark &) = delete; - InstructionBenchmark &operator=(InstructionBenchmark &&) = delete; + Benchmark(const Benchmark &) = delete; + Benchmark &operator=(const Benchmark &) = delete; + Benchmark &operator=(Benchmark &&) = delete; // Read functions. - static Expected<InstructionBenchmark> readYaml(const LLVMState &State, + static Expected<Benchmark> readYaml(const LLVMState &State, MemoryBufferRef Buffer); - static Expected<std::vector<InstructionBenchmark>> + static Expected<std::vector<Benchmark>> readYamls(const LLVMState &State, MemoryBufferRef Buffer); // Given a set of serialized instruction benchmarks, returns the set of diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index cc53b00..e268ba7 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -30,7 +30,7 @@ namespace llvm { namespace exegesis { BenchmarkRunner::BenchmarkRunner(const LLVMState &State, - InstructionBenchmark::ModeE Mode, + Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector) : State(State), Mode(Mode), BenchmarkPhaseSelector(BenchmarkPhaseSelector), Scratch(std::make_unique<ScratchSpace>()) {} @@ -155,7 +155,7 @@ BenchmarkRunner::getRunnableConfiguration( const SnippetRepetitor &Repetitor) const { RunnableConfiguration RC; - InstructionBenchmark &InstrBenchmark = RC.InstrBenchmark; + Benchmark &InstrBenchmark = RC.InstrBenchmark; InstrBenchmark.Mode = Mode; InstrBenchmark.CpuName = std::string(State.getTargetMachine().getTargetCPU()); InstrBenchmark.LLVMTriple = @@ -196,10 +196,10 @@ BenchmarkRunner::getRunnableConfiguration( return std::move(RC); } -Expected<InstructionBenchmark> +Expected<Benchmark> BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC, bool DumpObjectToDisk) const { - InstructionBenchmark &InstrBenchmark = RC.InstrBenchmark; + Benchmark &InstrBenchmark = RC.InstrBenchmark; object::OwningBinary<object::ObjectFile> &ObjectFile = RC.ObjectFile; if (DumpObjectToDisk && diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h index ea60eee..a74f347 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h @@ -35,7 +35,7 @@ namespace exegesis { class BenchmarkRunner { public: explicit BenchmarkRunner(const LLVMState &State, - InstructionBenchmark::ModeE Mode, + Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector); virtual ~BenchmarkRunner(); @@ -54,7 +54,7 @@ public: private: RunnableConfiguration() = default; - InstructionBenchmark InstrBenchmark; + Benchmark InstrBenchmark; object::OwningBinary<object::ObjectFile> ObjectFile; }; @@ -63,7 +63,7 @@ public: unsigned NumRepetitions, unsigned LoopUnrollFactor, const SnippetRepetitor &Repetitor) const; - Expected<InstructionBenchmark> runConfiguration(RunnableConfiguration &&RC, + Expected<Benchmark> runConfiguration(RunnableConfiguration &&RC, bool DumpObjectToDisk) const; // Scratch space to run instructions that touch memory. @@ -97,7 +97,7 @@ public: protected: const LLVMState &State; - const InstructionBenchmark::ModeE Mode; + const Benchmark::ModeE Mode; const BenchmarkPhaseSelectorE BenchmarkPhaseSelector; private: diff --git a/llvm/tools/llvm-exegesis/lib/Clustering.cpp b/llvm/tools/llvm-exegesis/lib/Clustering.cpp index f91d6fc..c702462 100644 --- a/llvm/tools/llvm-exegesis/lib/Clustering.cpp +++ b/llvm/tools/llvm-exegesis/lib/Clustering.cpp @@ -39,7 +39,7 @@ namespace exegesis { // Finds the points at distance less than sqrt(EpsilonSquared) of Q (not // including Q). -void InstructionBenchmarkClustering::rangeQuery( +void BenchmarkClustering::rangeQuery( const size_t Q, std::vector<size_t> &Neighbors) const { Neighbors.clear(); Neighbors.reserve(Points_.size() - 1); // The Q itself isn't a neighbor. @@ -59,7 +59,7 @@ void InstructionBenchmarkClustering::rangeQuery( // Given a set of points, checks that all the points are neighbours // up to AnalysisClusteringEpsilon. This is O(2*N). -bool InstructionBenchmarkClustering::areAllNeighbours( +bool BenchmarkClustering::areAllNeighbours( ArrayRef<size_t> Pts) const { // First, get the centroid of this group of points. This is O(N). SchedClassClusterCentroid G; @@ -88,14 +88,14 @@ bool InstructionBenchmarkClustering::areAllNeighbours( }); } -InstructionBenchmarkClustering::InstructionBenchmarkClustering( - const std::vector<InstructionBenchmark> &Points, +BenchmarkClustering::BenchmarkClustering( + const std::vector<Benchmark> &Points, const double AnalysisClusteringEpsilonSquared) : Points_(Points), AnalysisClusteringEpsilonSquared_(AnalysisClusteringEpsilonSquared), NoiseCluster_(ClusterId::noise()), ErrorCluster_(ClusterId::error()) {} -Error InstructionBenchmarkClustering::validateAndSetup() { +Error BenchmarkClustering::validateAndSetup() { ClusterIdForPoint_.resize(Points_.size()); // Mark erroneous measurements out. // All points must have the same number of dimensions, in the same order. @@ -128,7 +128,7 @@ Error InstructionBenchmarkClustering::validateAndSetup() { return Error::success(); } -void InstructionBenchmarkClustering::clusterizeDbScan(const size_t MinPts) { +void BenchmarkClustering::clusterizeDbScan(const size_t MinPts) { std::vector<size_t> Neighbors; // Persistent buffer to avoid allocs. for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) { if (!ClusterIdForPoint_[P].isUndef()) @@ -185,7 +185,7 @@ void InstructionBenchmarkClustering::clusterizeDbScan(const size_t MinPts) { } } -void InstructionBenchmarkClustering::clusterizeNaive( +void BenchmarkClustering::clusterizeNaive( const MCSubtargetInfo &SubtargetInfo, const MCInstrInfo &InstrInfo) { // Given an instruction Opcode, which sched class id's are represented, // and which are the benchmarks for each sched class? @@ -195,7 +195,7 @@ void InstructionBenchmarkClustering::clusterizeNaive( OpcodeToSchedClassesToPoints.resize(NumOpcodes); size_t NumClusters = 0; for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) { - const InstructionBenchmark &Point = Points_[P]; + const Benchmark &Point = Points_[P]; const MCInst &MCI = Point.keyInstruction(); unsigned SchedClassId; std::tie(SchedClassId, std::ignore) = @@ -249,11 +249,11 @@ void InstructionBenchmarkClustering::clusterizeNaive( // clustered into *different* clusters. This is not great for further analysis. // We shall find every opcode with benchmarks not in just one cluster, and move // *all* the benchmarks of said Opcode into one new unstable cluster per Opcode. -void InstructionBenchmarkClustering::stabilize(unsigned NumOpcodes) { +void BenchmarkClustering::stabilize(unsigned NumOpcodes) { // Given an instruction Opcode and Config, in which clusters do benchmarks of // this instruction lie? Normally, they all should be in the same cluster. struct OpcodeAndConfig { - explicit OpcodeAndConfig(const InstructionBenchmark &IB) + explicit OpcodeAndConfig(const Benchmark &IB) : Opcode(IB.keyInstruction().getOpcode()), Config(&IB.Key.Config) {} unsigned Opcode; const std::string *Config; @@ -327,11 +327,11 @@ void InstructionBenchmarkClustering::stabilize(unsigned NumOpcodes) { } } -Expected<InstructionBenchmarkClustering> InstructionBenchmarkClustering::create( - const std::vector<InstructionBenchmark> &Points, const ModeE Mode, +Expected<BenchmarkClustering> BenchmarkClustering::create( + const std::vector<Benchmark> &Points, const ModeE Mode, const size_t DbscanMinPts, const double AnalysisClusteringEpsilon, const MCSubtargetInfo *SubtargetInfo, const MCInstrInfo *InstrInfo) { - InstructionBenchmarkClustering Clustering( + BenchmarkClustering Clustering( Points, AnalysisClusteringEpsilon * AnalysisClusteringEpsilon); if (auto Error = Clustering.validateAndSetup()) { return std::move(Error); @@ -373,10 +373,10 @@ std::vector<BenchmarkMeasure> SchedClassClusterCentroid::getAsPoint() const { } bool SchedClassClusterCentroid::validate( - InstructionBenchmark::ModeE Mode) const { + Benchmark::ModeE Mode) const { size_t NumMeasurements = Representative.size(); switch (Mode) { - case InstructionBenchmark::Latency: + case Benchmark::Latency: if (NumMeasurements != 1) { errs() << "invalid number of measurements in latency mode: expected 1, got " @@ -384,10 +384,10 @@ bool SchedClassClusterCentroid::validate( return false; } break; - case InstructionBenchmark::Uops: + case Benchmark::Uops: // Can have many measurements. break; - case InstructionBenchmark::InverseThroughput: + case Benchmark::InverseThroughput: if (NumMeasurements != 1) { errs() << "invalid number of measurements in inverse throughput " "mode: expected 1, got " diff --git a/llvm/tools/llvm-exegesis/lib/Clustering.h b/llvm/tools/llvm-exegesis/lib/Clustering.h index 8d8570b..9d6c110 100644 --- a/llvm/tools/llvm-exegesis/lib/Clustering.h +++ b/llvm/tools/llvm-exegesis/lib/Clustering.h @@ -22,14 +22,14 @@ namespace llvm { namespace exegesis { -class InstructionBenchmarkClustering { +class BenchmarkClustering { public: enum ModeE { Dbscan, Naive }; // Clusters `Points` using DBSCAN with the given parameters. See the cc file // for more explanations on the algorithm. - static Expected<InstructionBenchmarkClustering> - create(const std::vector<InstructionBenchmark> &Points, ModeE Mode, + static Expected<BenchmarkClustering> + create(const std::vector<Benchmark> &Points, ModeE Mode, size_t DbscanMinPts, double AnalysisClusteringEpsilon, const MCSubtargetInfo *SubtargetInfo = nullptr, const MCInstrInfo *InstrInfo = nullptr); @@ -91,7 +91,7 @@ public: return ClusterIdForPoint_[P]; } - const std::vector<InstructionBenchmark> &getPoints() const { return Points_; } + const std::vector<Benchmark> &getPoints() const { return Points_; } const Cluster &getCluster(ClusterId Id) const { assert(!Id.isUndef() && "unlabeled cluster"); @@ -119,8 +119,8 @@ public: } private: - InstructionBenchmarkClustering( - const std::vector<InstructionBenchmark> &Points, + BenchmarkClustering( + const std::vector<Benchmark> &Points, double AnalysisClusteringEpsilonSquared); Error validateAndSetup(); @@ -136,7 +136,7 @@ private: bool areAllNeighbours(ArrayRef<size_t> Pts) const; - const std::vector<InstructionBenchmark> &Points_; + const std::vector<Benchmark> &Points_; const double AnalysisClusteringEpsilonSquared_; int NumDimensions_ = 0; @@ -157,7 +157,7 @@ public: void addPoint(ArrayRef<BenchmarkMeasure> Point); - bool validate(InstructionBenchmark::ModeE Mode) const; + bool validate(Benchmark::ModeE Mode) const; private: // Measurement stats for the points in the SchedClassCluster. diff --git a/llvm/tools/llvm-exegesis/lib/CodeTemplate.h b/llvm/tools/llvm-exegesis/lib/CodeTemplate.h index 16982f9..7aca224 100644 --- a/llvm/tools/llvm-exegesis/lib/CodeTemplate.h +++ b/llvm/tools/llvm-exegesis/lib/CodeTemplate.h @@ -123,7 +123,7 @@ struct CodeTemplate { CodeTemplate clone() const; ExecutionMode Execution = ExecutionMode::UNKNOWN; - // See InstructionBenchmarkKey.::Config. + // See BenchmarkKey.::Config. std::string Config; // Some information about how this template has been created. std::string Info; diff --git a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp index d57ee14..18c0671 100644 --- a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp +++ b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp @@ -19,12 +19,12 @@ namespace llvm { namespace exegesis { LatencyBenchmarkRunner::LatencyBenchmarkRunner( - const LLVMState &State, InstructionBenchmark::ModeE Mode, + const LLVMState &State, Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAgg) + Benchmark::ResultAggregationModeE ResultAgg) : BenchmarkRunner(State, Mode, BenchmarkPhaseSelector) { - assert((Mode == InstructionBenchmark::Latency || - Mode == InstructionBenchmark::InverseThroughput) && + assert((Mode == Benchmark::Latency || + Mode == Benchmark::InverseThroughput) && "invalid mode"); ResultAggMode = ResultAgg; } @@ -94,10 +94,10 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements( std::string ModeName; switch (Mode) { - case InstructionBenchmark::Latency: + case Benchmark::Latency: ModeName = "latency"; break; - case InstructionBenchmark::InverseThroughput: + case Benchmark::InverseThroughput: ModeName = "inverse_throughput"; break; default: @@ -105,7 +105,7 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements( } switch (ResultAggMode) { - case InstructionBenchmark::MinVariance: { + case Benchmark::MinVariance: { if (ValuesCount == 1) llvm::errs() << "Each sample only has one value. result-aggregation-mode " "of min-variance is probably non-sensical\n"; @@ -115,19 +115,19 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements( Result.push_back(BenchmarkMeasure::Create(ModeName, Value)); return std::move(Result); } - case InstructionBenchmark::Min: { + case Benchmark::Min: { std::vector<BenchmarkMeasure> Result; Result.push_back( BenchmarkMeasure::Create(ModeName, findMin(AccumulatedValues))); return std::move(Result); } - case InstructionBenchmark::Max: { + case Benchmark::Max: { std::vector<BenchmarkMeasure> Result; Result.push_back( BenchmarkMeasure::Create(ModeName, findMax(AccumulatedValues))); return std::move(Result); } - case InstructionBenchmark::Mean: { + case Benchmark::Mean: { std::vector<BenchmarkMeasure> Result; Result.push_back( BenchmarkMeasure::Create(ModeName, findMean(AccumulatedValues))); diff --git a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h index d7d1fa9..cd06d00 100644 --- a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h @@ -22,16 +22,16 @@ namespace exegesis { class LatencyBenchmarkRunner : public BenchmarkRunner { public: LatencyBenchmarkRunner( - const LLVMState &State, InstructionBenchmark::ModeE Mode, + const LLVMState &State, Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode); + Benchmark::ResultAggregationModeE ResultAggMode); ~LatencyBenchmarkRunner() override; private: Expected<std::vector<BenchmarkMeasure>> runMeasurements(const FunctionExecutor &Executor) const override; - InstructionBenchmark::ResultAggregationModeE ResultAggMode; + Benchmark::ResultAggregationModeE ResultAggMode; }; } // namespace exegesis } // namespace llvm diff --git a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp index 6ed327f..bd4e542 100644 --- a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp +++ b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp @@ -280,13 +280,13 @@ static unsigned findProcResIdx(const MCSubtargetInfo &STI, } std::vector<BenchmarkMeasure> ResolvedSchedClass::getAsPoint( - InstructionBenchmark::ModeE Mode, const MCSubtargetInfo &STI, + Benchmark::ModeE Mode, const MCSubtargetInfo &STI, ArrayRef<PerInstructionStats> Representative) const { const size_t NumMeasurements = Representative.size(); std::vector<BenchmarkMeasure> SchedClassPoint(NumMeasurements); - if (Mode == InstructionBenchmark::Latency) { + if (Mode == Benchmark::Latency) { assert(NumMeasurements == 1 && "Latency is a single measure."); BenchmarkMeasure &LatencyMeasure = SchedClassPoint[0]; @@ -299,7 +299,7 @@ std::vector<BenchmarkMeasure> ResolvedSchedClass::getAsPoint( LatencyMeasure.PerInstructionValue = std::max<double>(LatencyMeasure.PerInstructionValue, WLE->Cycles); } - } else if (Mode == InstructionBenchmark::Uops) { + } else if (Mode == Benchmark::Uops) { for (auto I : zip(SchedClassPoint, Representative)) { BenchmarkMeasure &Measure = std::get<0>(I); const PerInstructionStats &Stats = std::get<1>(I); @@ -326,7 +326,7 @@ std::vector<BenchmarkMeasure> ResolvedSchedClass::getAsPoint( return {}; } } - } else if (Mode == InstructionBenchmark::InverseThroughput) { + } else if (Mode == Benchmark::InverseThroughput) { assert(NumMeasurements == 1 && "Inverse Throughput is a single measure."); BenchmarkMeasure &RThroughputMeasure = SchedClassPoint[0]; diff --git a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.h b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.h index 3c7d8b3..2347449 100644 --- a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.h +++ b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.h @@ -45,7 +45,7 @@ struct ResolvedSchedClass { const MCInstrInfo &InstrInfo, const MCInst &MCI); std::vector<BenchmarkMeasure> - getAsPoint(InstructionBenchmark::ModeE Mode, const MCSubtargetInfo &STI, + getAsPoint(Benchmark::ModeE Mode, const MCSubtargetInfo &STI, ArrayRef<PerInstructionStats> Representative) const; const unsigned SchedClassId; diff --git a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp index bf05131..7112d32 100644 --- a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp +++ b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp @@ -131,14 +131,14 @@ private: SnippetRepetitor::~SnippetRepetitor() {} std::unique_ptr<const SnippetRepetitor> -SnippetRepetitor::Create(InstructionBenchmark::RepetitionModeE Mode, +SnippetRepetitor::Create(Benchmark::RepetitionModeE Mode, const LLVMState &State) { switch (Mode) { - case InstructionBenchmark::Duplicate: + case Benchmark::Duplicate: return std::make_unique<DuplicateSnippetRepetitor>(State); - case InstructionBenchmark::Loop: + case Benchmark::Loop: return std::make_unique<LoopSnippetRepetitor>(State); - case InstructionBenchmark::AggregateMin: + case Benchmark::AggregateMin: break; } llvm_unreachable("Unknown RepetitionModeE enum"); diff --git a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.h b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.h index 239fa25..6f70633 100644 --- a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.h +++ b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.h @@ -29,7 +29,7 @@ namespace exegesis { class SnippetRepetitor { public: static std::unique_ptr<const SnippetRepetitor> - Create(InstructionBenchmark::RepetitionModeE Mode, const LLVMState &State); + Create(Benchmark::RepetitionModeE Mode, const LLVMState &State); virtual ~SnippetRepetitor(); diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp index f12444a..4717f9f 100644 --- a/llvm/tools/llvm-exegesis/lib/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/Target.cpp @@ -57,15 +57,15 @@ void ExegesisTarget::registerTarget(ExegesisTarget *Target) { } std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator( - InstructionBenchmark::ModeE Mode, const LLVMState &State, + Benchmark::ModeE Mode, const LLVMState &State, const SnippetGenerator::Options &Opts) const { switch (Mode) { - case InstructionBenchmark::Unknown: + case Benchmark::Unknown: return nullptr; - case InstructionBenchmark::Latency: + case Benchmark::Latency: return createSerialSnippetGenerator(State, Opts); - case InstructionBenchmark::Uops: - case InstructionBenchmark::InverseThroughput: + case Benchmark::Uops: + case Benchmark::InverseThroughput: return createParallelSnippetGenerator(State, Opts); } return nullptr; @@ -73,18 +73,18 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator( Expected<std::unique_ptr<BenchmarkRunner>> ExegesisTarget::createBenchmarkRunner( - InstructionBenchmark::ModeE Mode, const LLVMState &State, + Benchmark::ModeE Mode, const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode) const { + Benchmark::ResultAggregationModeE ResultAggMode) const { PfmCountersInfo PfmCounters = State.getPfmCounters(); switch (Mode) { - case InstructionBenchmark::Unknown: + case Benchmark::Unknown: return nullptr; - case InstructionBenchmark::Latency: - case InstructionBenchmark::InverseThroughput: + case Benchmark::Latency: + case Benchmark::InverseThroughput: if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure && !PfmCounters.CycleCounter) { - const char *ModeName = Mode == InstructionBenchmark::Latency + const char *ModeName = Mode == Benchmark::Latency ? "latency" : "inverse_throughput"; return make_error<Failure>( @@ -97,7 +97,7 @@ ExegesisTarget::createBenchmarkRunner( } return createLatencyBenchmarkRunner(State, Mode, BenchmarkPhaseSelector, ResultAggMode); - case InstructionBenchmark::Uops: + case Benchmark::Uops: if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure && !PfmCounters.UopsCounter && !PfmCounters.IssueCounters) return make_error<Failure>( @@ -121,16 +121,16 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createParallelSnippetGenerator } std::unique_ptr<BenchmarkRunner> ExegesisTarget::createLatencyBenchmarkRunner( - const LLVMState &State, InstructionBenchmark::ModeE Mode, + const LLVMState &State, Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode) const { + Benchmark::ResultAggregationModeE ResultAggMode) const { return std::make_unique<LatencyBenchmarkRunner>( State, Mode, BenchmarkPhaseSelector, ResultAggMode); } std::unique_ptr<BenchmarkRunner> ExegesisTarget::createUopsBenchmarkRunner( const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE /*unused*/) const { + Benchmark::ResultAggregationModeE /*unused*/) const { return std::make_unique<UopsBenchmarkRunner>(State, BenchmarkPhaseSelector); } diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h index 7669b6c..9f21122 100644 --- a/llvm/tools/llvm-exegesis/lib/Target.h +++ b/llvm/tools/llvm-exegesis/lib/Target.h @@ -154,15 +154,15 @@ public: // Creates a snippet generator for the given mode. std::unique_ptr<SnippetGenerator> - createSnippetGenerator(InstructionBenchmark::ModeE Mode, + createSnippetGenerator(Benchmark::ModeE Mode, const LLVMState &State, const SnippetGenerator::Options &Opts) const; // Creates a benchmark runner for the given mode. Expected<std::unique_ptr<BenchmarkRunner>> createBenchmarkRunner( - InstructionBenchmark::ModeE Mode, const LLVMState &State, + Benchmark::ModeE Mode, const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode = - InstructionBenchmark::Min) const; + Benchmark::ResultAggregationModeE ResultAggMode = + Benchmark::Min) const; // Returns the ExegesisTarget for the given triple or nullptr if the target // does not exist. @@ -198,12 +198,12 @@ private: std::unique_ptr<SnippetGenerator> virtual createParallelSnippetGenerator( const LLVMState &State, const SnippetGenerator::Options &Opts) const; std::unique_ptr<BenchmarkRunner> virtual createLatencyBenchmarkRunner( - const LLVMState &State, InstructionBenchmark::ModeE Mode, + const LLVMState &State, Benchmark::ModeE Mode, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode) const; + Benchmark::ResultAggregationModeE ResultAggMode) const; std::unique_ptr<BenchmarkRunner> virtual createUopsBenchmarkRunner( const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector, - InstructionBenchmark::ResultAggregationModeE ResultAggMode) const; + Benchmark::ResultAggregationModeE ResultAggMode) const; const ExegesisTarget *Next = nullptr; const ArrayRef<CpuAndPfmCounters> CpuPfmCounters; diff --git a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h index c726944..e08eaa7 100644 --- a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h @@ -23,7 +23,7 @@ class UopsBenchmarkRunner : public BenchmarkRunner { public: UopsBenchmarkRunner(const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector) - : BenchmarkRunner(State, InstructionBenchmark::Uops, + : BenchmarkRunner(State, Benchmark::Uops, BenchmarkPhaseSelector) {} ~UopsBenchmarkRunner() override; diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp index 4e260e0..06ae924 100644 --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -69,47 +69,47 @@ static cl::opt<std::string> "results. “-” uses stdin/stdout."), cl::cat(Options), cl::init("")); -static cl::opt<exegesis::InstructionBenchmark::ModeE> BenchmarkMode( +static cl::opt<exegesis::Benchmark::ModeE> BenchmarkMode( "mode", cl::desc("the mode to run"), cl::cat(Options), - cl::values(clEnumValN(exegesis::InstructionBenchmark::Latency, "latency", + cl::values(clEnumValN(exegesis::Benchmark::Latency, "latency", "Instruction Latency"), - clEnumValN(exegesis::InstructionBenchmark::InverseThroughput, + clEnumValN(exegesis::Benchmark::InverseThroughput, "inverse_throughput", "Instruction Inverse Throughput"), - clEnumValN(exegesis::InstructionBenchmark::Uops, "uops", + clEnumValN(exegesis::Benchmark::Uops, "uops", "Uop Decomposition"), // When not asking for a specific benchmark mode, // we'll analyse the results. - clEnumValN(exegesis::InstructionBenchmark::Unknown, "analysis", + clEnumValN(exegesis::Benchmark::Unknown, "analysis", "Analysis"))); -static cl::opt<exegesis::InstructionBenchmark::ResultAggregationModeE> +static cl::opt<exegesis::Benchmark::ResultAggregationModeE> ResultAggMode( "result-aggregation-mode", cl::desc("How to aggregate multi-values result"), cl::cat(BenchmarkOptions), - cl::values(clEnumValN(exegesis::InstructionBenchmark::Min, "min", + cl::values(clEnumValN(exegesis::Benchmark::Min, "min", "Keep min reading"), - clEnumValN(exegesis::InstructionBenchmark::Max, "max", + clEnumValN(exegesis::Benchmark::Max, "max", "Keep max reading"), - clEnumValN(exegesis::InstructionBenchmark::Mean, "mean", + clEnumValN(exegesis::Benchmark::Mean, "mean", "Compute mean of all readings"), - clEnumValN(exegesis::InstructionBenchmark::MinVariance, + clEnumValN(exegesis::Benchmark::MinVariance, "min-variance", "Keep readings set with min-variance")), - cl::init(exegesis::InstructionBenchmark::Min)); + cl::init(exegesis::Benchmark::Min)); -static cl::opt<exegesis::InstructionBenchmark::RepetitionModeE> RepetitionMode( +static cl::opt<exegesis::Benchmark::RepetitionModeE> RepetitionMode( "repetition-mode", cl::desc("how to repeat the instruction snippet"), cl::cat(BenchmarkOptions), cl::values( - clEnumValN(exegesis::InstructionBenchmark::Duplicate, "duplicate", + clEnumValN(exegesis::Benchmark::Duplicate, "duplicate", "Duplicate the snippet"), - clEnumValN(exegesis::InstructionBenchmark::Loop, "loop", + clEnumValN(exegesis::Benchmark::Loop, "loop", "Loop over the snippet"), - clEnumValN(exegesis::InstructionBenchmark::AggregateMin, "min", + clEnumValN(exegesis::Benchmark::AggregateMin, "min", "All of the above and take the minimum of measurements")), - cl::init(exegesis::InstructionBenchmark::Duplicate)); + cl::init(exegesis::Benchmark::Duplicate)); static cl::opt<bool> BenchmarkMeasurementsPrintProgress( "measurements-print-progress", @@ -163,27 +163,27 @@ static cl::opt<bool> IgnoreInvalidSchedClass( cl::desc("ignore instructions that do not define a sched class"), cl::cat(BenchmarkOptions), cl::init(false)); -static cl::opt<exegesis::InstructionBenchmarkFilter> AnalysisSnippetFilter( +static cl::opt<exegesis::BenchmarkFilter> AnalysisSnippetFilter( "analysis-filter", cl::desc("Filter the benchmarks before analysing them"), cl::cat(BenchmarkOptions), cl::values( - clEnumValN(exegesis::InstructionBenchmarkFilter::All, "all", + clEnumValN(exegesis::BenchmarkFilter::All, "all", "Keep all benchmarks (default)"), - clEnumValN(exegesis::InstructionBenchmarkFilter::RegOnly, "reg-only", + clEnumValN(exegesis::BenchmarkFilter::RegOnly, "reg-only", "Keep only those benchmarks that do *NOT* involve memory"), - clEnumValN(exegesis::InstructionBenchmarkFilter::WithMem, "mem-only", + clEnumValN(exegesis::BenchmarkFilter::WithMem, "mem-only", "Keep only the benchmarks that *DO* involve memory")), - cl::init(exegesis::InstructionBenchmarkFilter::All)); + cl::init(exegesis::BenchmarkFilter::All)); -static cl::opt<exegesis::InstructionBenchmarkClustering::ModeE> +static cl::opt<exegesis::BenchmarkClustering::ModeE> AnalysisClusteringAlgorithm( "analysis-clustering", cl::desc("the clustering algorithm to use"), cl::cat(AnalysisOptions), - cl::values(clEnumValN(exegesis::InstructionBenchmarkClustering::Dbscan, + cl::values(clEnumValN(exegesis::BenchmarkClustering::Dbscan, "dbscan", "use DBSCAN/OPTICS algorithm"), - clEnumValN(exegesis::InstructionBenchmarkClustering::Naive, + clEnumValN(exegesis::BenchmarkClustering::Naive, "naive", "one cluster per opcode")), - cl::init(exegesis::InstructionBenchmarkClustering::Dbscan)); + cl::init(exegesis::BenchmarkClustering::Dbscan)); static cl::opt<unsigned> AnalysisDbscanNumPoints( "analysis-numpoints", @@ -369,7 +369,7 @@ static void runBenchmarkConfigurations( Meter.emplace(Configurations.size()); for (const BenchmarkCode &Conf : Configurations) { ProgressMeter<>::ProgressMeterStep MeterStep(Meter ? &*Meter : nullptr); - SmallVector<InstructionBenchmark, 2> AllResults; + SmallVector<Benchmark, 2> AllResults; for (const std::unique_ptr<const SnippetRepetitor> &Repetitor : Repetitors) { @@ -378,18 +378,18 @@ static void runBenchmarkConfigurations( AllResults.emplace_back( ExitOnErr(Runner.runConfiguration(std::move(RC), DumpObjectToDisk))); } - InstructionBenchmark &Result = AllResults.front(); + Benchmark &Result = AllResults.front(); // If any of our measurements failed, pretend they all have failed. if (AllResults.size() > 1 && - any_of(AllResults, [](const InstructionBenchmark &R) { + any_of(AllResults, [](const Benchmark &R) { return R.Measurements.empty(); })) Result.Measurements.clear(); - if (RepetitionMode == InstructionBenchmark::RepetitionModeE::AggregateMin) { - for (const InstructionBenchmark &OtherResult : - ArrayRef<InstructionBenchmark>(AllResults).drop_front()) { + if (RepetitionMode == Benchmark::RepetitionModeE::AggregateMin) { + for (const Benchmark &OtherResult : + ArrayRef<Benchmark>(AllResults).drop_front()) { llvm::append_range(Result.AssembledSnippet, OtherResult.AssembledSnippet); // Aggregate measurements, but only iff all measurements succeeded. @@ -449,12 +449,12 @@ void benchmarkMain() { const auto Opcodes = getOpcodesOrDie(State); SmallVector<std::unique_ptr<const SnippetRepetitor>, 2> Repetitors; - if (RepetitionMode != InstructionBenchmark::RepetitionModeE::AggregateMin) + if (RepetitionMode != Benchmark::RepetitionModeE::AggregateMin) Repetitors.emplace_back(SnippetRepetitor::Create(RepetitionMode, State)); else { - for (InstructionBenchmark::RepetitionModeE RepMode : - {InstructionBenchmark::RepetitionModeE::Duplicate, - InstructionBenchmark::RepetitionModeE::Loop}) + for (Benchmark::RepetitionModeE RepMode : + {Benchmark::RepetitionModeE::Duplicate, + Benchmark::RepetitionModeE::Loop}) Repetitors.emplace_back(SnippetRepetitor::Create(RepMode, State)); } @@ -526,14 +526,14 @@ static void maybeRunAnalysis(const Analysis &Analyzer, const std::string &Name, ExitOnFileError(OutputFilename, std::move(Err)); } -static void filterPoints(MutableArrayRef<InstructionBenchmark> Points, +static void filterPoints(MutableArrayRef<Benchmark> Points, const MCInstrInfo &MCII) { - if (AnalysisSnippetFilter == exegesis::InstructionBenchmarkFilter::All) + if (AnalysisSnippetFilter == exegesis::BenchmarkFilter::All) return; bool WantPointsWithMemOps = - AnalysisSnippetFilter == exegesis::InstructionBenchmarkFilter::WithMem; - for (InstructionBenchmark &Point : Points) { + AnalysisSnippetFilter == exegesis::BenchmarkFilter::WithMem; + for (Benchmark &Point : Points) { if (!Point.Error.empty()) continue; if (WantPointsWithMemOps == @@ -568,7 +568,7 @@ static void analysisMain() { const auto TriplesAndCpus = ExitOnFileError( BenchmarkFile, - InstructionBenchmark::readTriplesAndCpusFromYamls(*MemoryBuffer)); + Benchmark::readTriplesAndCpusFromYamls(*MemoryBuffer)); if (TriplesAndCpus.empty()) { errs() << "no benchmarks to analyze\n"; return; @@ -591,8 +591,8 @@ static void analysisMain() { // Read benchmarks. const LLVMState State = ExitOnErr( LLVMState::Create(TripleAndCpu.LLVMTriple, TripleAndCpu.CpuName)); - std::vector<InstructionBenchmark> Points = ExitOnFileError( - BenchmarkFile, InstructionBenchmark::readYamls(State, *MemoryBuffer)); + std::vector<Benchmark> Points = ExitOnFileError( + BenchmarkFile, Benchmark::readYamls(State, *MemoryBuffer)); outs() << "Parsed " << Points.size() << " benchmark points\n"; if (Points.empty()) { @@ -603,7 +603,7 @@ static void analysisMain() { filterPoints(Points, State.getInstrInfo()); - const auto Clustering = ExitOnErr(InstructionBenchmarkClustering::create( + const auto Clustering = ExitOnErr(BenchmarkClustering::create( Points, AnalysisClusteringAlgorithm, AnalysisDbscanNumPoints, AnalysisClusteringEpsilon, &State.getSubtargetInfo(), &State.getInstrInfo())); @@ -651,7 +651,7 @@ int main(int Argc, char **Argv) { return EXIT_FAILURE; }); - if (exegesis::BenchmarkMode == exegesis::InstructionBenchmark::Unknown) { + if (exegesis::BenchmarkMode == exegesis::Benchmark::Unknown) { exegesis::analysisMain(); } else { exegesis::benchmarkMain(); |