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())
// 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, "; ");
}
Analysis::Analysis(const LLVMState &State,
- const InstructionBenchmarkClustering &Clustering,
+ const BenchmarkClustering &Clustering,
double AnalysisInconsistencyEpsilon,
bool AnalysisDisplayUnstableOpcodes)
: Clustering_(Clustering), State_(State),
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());
}
}
-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:
}
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())
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;
}
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);
OS << "</div>";
}
- printClusterRawHtml(InstructionBenchmarkClustering::ClusterId::noise(),
+ printClusterRawHtml(BenchmarkClustering::ClusterId::noise(),
"[noise]", OS);
OS << "</body></html>";
class Analysis {
public:
Analysis(const LLVMState &State,
- const InstructionBenchmarkClustering &Clustering,
+ const BenchmarkClustering &Clustering,
double AnalysisInconsistencyEpsilon,
bool AnalysisDisplayUnstableOpcodes);
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; }
// 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;
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
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_;
// 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.
};
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);
}
};
};
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);
};
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) {}
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);
}
};
-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);
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(
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())
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);
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*/);
return Error::success();
}
-Error InstructionBenchmark::readYamlFrom(const LLVMState &State,
+Error Benchmark::readYamlFrom(const LLVMState &State,
StringRef InputContent) {
yaml::Input Yin(InputContent);
YamlContext Context(State);
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.
};
// 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;
// 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
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>()) {}
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 =
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 &&
class BenchmarkRunner {
public:
explicit BenchmarkRunner(const LLVMState &State,
- InstructionBenchmark::ModeE Mode,
+ Benchmark::ModeE Mode,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector);
virtual ~BenchmarkRunner();
private:
RunnableConfiguration() = default;
- InstructionBenchmark InstrBenchmark;
+ Benchmark InstrBenchmark;
object::OwningBinary<object::ObjectFile> ObjectFile;
};
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.
protected:
const LLVMState &State;
- const InstructionBenchmark::ModeE Mode;
+ const Benchmark::ModeE Mode;
const BenchmarkPhaseSelectorE BenchmarkPhaseSelector;
private:
// 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.
// 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;
});
}
-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.
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())
}
}
-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?
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) =
// 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;
}
}
-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);
}
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 "
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 "
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);
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");
}
private:
- InstructionBenchmarkClustering(
- const std::vector<InstructionBenchmark> &Points,
+ BenchmarkClustering(
+ const std::vector<Benchmark> &Points,
double AnalysisClusteringEpsilonSquared);
Error validateAndSetup();
bool areAllNeighbours(ArrayRef<size_t> Pts) const;
- const std::vector<InstructionBenchmark> &Points_;
+ const std::vector<Benchmark> &Points_;
const double AnalysisClusteringEpsilonSquared_;
int NumDimensions_ = 0;
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.
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;
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;
}
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:
}
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";
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)));
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
}
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];
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);
return {};
}
}
- } else if (Mode == InstructionBenchmark::InverseThroughput) {
+ } else if (Mode == Benchmark::InverseThroughput) {
assert(NumMeasurements == 1 && "Inverse Throughput is a single measure.");
BenchmarkMeasure &RThroughputMeasure = SchedClassPoint[0];
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;
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");
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();
}
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;
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>(
}
return createLatencyBenchmarkRunner(State, Mode, BenchmarkPhaseSelector,
ResultAggMode);
- case InstructionBenchmark::Uops:
+ case Benchmark::Uops:
if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure &&
!PfmCounters.UopsCounter && !PfmCounters.IssueCounters)
return make_error<Failure>(
}
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);
}
// 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.
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;
public:
UopsBenchmarkRunner(const LLVMState &State,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector)
- : BenchmarkRunner(State, InstructionBenchmark::Uops,
+ : BenchmarkRunner(State, Benchmark::Uops,
BenchmarkPhaseSelector) {}
~UopsBenchmarkRunner() override;
"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",
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",
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) {
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.
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));
}
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 ==
const auto TriplesAndCpus = ExitOnFileError(
BenchmarkFile,
- InstructionBenchmark::readTriplesAndCpusFromYamls(*MemoryBuffer));
+ Benchmark::readTriplesAndCpusFromYamls(*MemoryBuffer));
if (TriplesAndCpus.empty()) {
errs() << "no benchmarks to analyze\n";
return;
// 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()) {
filterPoints(Points, State.getInstrInfo());
- const auto Clustering = ExitOnErr(InstructionBenchmarkClustering::create(
+ const auto Clustering = ExitOnErr(BenchmarkClustering::create(
Points, AnalysisClusteringAlgorithm, AnalysisDbscanNumPoints,
AnalysisClusteringEpsilon, &State.getSubtargetInfo(),
&State.getInstrInfo()));
return EXIT_FAILURE;
});
- if (exegesis::BenchmarkMode == exegesis::InstructionBenchmark::Unknown) {
+ if (exegesis::BenchmarkMode == exegesis::Benchmark::Unknown) {
exegesis::analysisMain();
} else {
exegesis::benchmarkMain();
using testing::UnorderedElementsAreArray;
static const auto HasPoints = [](const std::vector<int> &Indices) {
- return Field(&InstructionBenchmarkClustering::Cluster::PointIndices,
+ return Field(&BenchmarkClustering::Cluster::PointIndices,
UnorderedElementsAreArray(Indices));
};
TEST(ClusteringTest, Clusters3D) {
- std::vector<InstructionBenchmark> Points(6);
+ std::vector<Benchmark> Points(6);
// Cluster around (x=0, y=1, z=2): points {0, 3}.
Points[0].Measurements = {
// Error cluster: points {2}
Points[2].Error = "oops";
- auto Clustering = InstructionBenchmarkClustering::create(
- Points, InstructionBenchmarkClustering::ModeE::Dbscan, 2, 0.25);
+ auto Clustering = BenchmarkClustering::create(
+ Points, BenchmarkClustering::ModeE::Dbscan, 2, 0.25);
ASSERT_TRUE((bool)Clustering);
EXPECT_THAT(Clustering.get().getValidClusters(),
UnorderedElementsAre(HasPoints({0, 3}), HasPoints({1, 4})));
EXPECT_THAT(Clustering.get().getCluster(
- InstructionBenchmarkClustering::ClusterId::noise()),
+ BenchmarkClustering::ClusterId::noise()),
HasPoints({5}));
EXPECT_THAT(Clustering.get().getCluster(
- InstructionBenchmarkClustering::ClusterId::error()),
+ BenchmarkClustering::ClusterId::error()),
HasPoints({2}));
EXPECT_EQ(Clustering.get().getClusterIdForPoint(2),
- InstructionBenchmarkClustering::ClusterId::error());
+ BenchmarkClustering::ClusterId::error());
EXPECT_EQ(Clustering.get().getClusterIdForPoint(5),
- InstructionBenchmarkClustering::ClusterId::noise());
+ BenchmarkClustering::ClusterId::noise());
EXPECT_EQ(Clustering.get().getClusterIdForPoint(0),
Clustering.get().getClusterIdForPoint(3));
EXPECT_EQ(Clustering.get().getClusterIdForPoint(1),
}
TEST(ClusteringTest, Clusters3D_InvalidSize) {
- std::vector<InstructionBenchmark> Points(6);
+ std::vector<Benchmark> Points(6);
Points[0].Measurements = {
{"x", 0.01, 0.0}, {"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
Points[1].Measurements = {{"y", 1.02, 0.0}, {"z", 1.98, 0.0}};
auto Error =
- InstructionBenchmarkClustering::create(
- Points, InstructionBenchmarkClustering::ModeE::Dbscan, 2, 0.25)
+ BenchmarkClustering::create(
+ Points, BenchmarkClustering::ModeE::Dbscan, 2, 0.25)
.takeError();
ASSERT_TRUE((bool)Error);
consumeError(std::move(Error));
}
TEST(ClusteringTest, Clusters3D_InvalidOrder) {
- std::vector<InstructionBenchmark> Points(6);
+ std::vector<Benchmark> Points(6);
Points[0].Measurements = {{"x", 0.01, 0.0}, {"y", 1.02, 0.0}};
Points[1].Measurements = {{"y", 1.02, 0.0}, {"x", 1.98, 0.0}};
auto Error =
- InstructionBenchmarkClustering::create(
- Points, InstructionBenchmarkClustering::ModeE::Dbscan, 2, 0.25)
+ BenchmarkClustering::create(
+ Points, BenchmarkClustering::ModeE::Dbscan, 2, 0.25)
.takeError();
ASSERT_TRUE((bool)Error);
consumeError(std::move(Error));
}
TEST(ClusteringTest, Ordering) {
- ASSERT_LT(InstructionBenchmarkClustering::ClusterId::makeValid(1),
- InstructionBenchmarkClustering::ClusterId::makeValid(2));
+ ASSERT_LT(BenchmarkClustering::ClusterId::makeValid(1),
+ BenchmarkClustering::ClusterId::makeValid(2));
- ASSERT_LT(InstructionBenchmarkClustering::ClusterId::makeValid(2),
- InstructionBenchmarkClustering::ClusterId::noise());
+ ASSERT_LT(BenchmarkClustering::ClusterId::makeValid(2),
+ BenchmarkClustering::ClusterId::noise());
- ASSERT_LT(InstructionBenchmarkClustering::ClusterId::makeValid(2),
- InstructionBenchmarkClustering::ClusterId::error());
+ ASSERT_LT(BenchmarkClustering::ClusterId::makeValid(2),
+ BenchmarkClustering::ClusterId::error());
- ASSERT_LT(InstructionBenchmarkClustering::ClusterId::noise(),
- InstructionBenchmarkClustering::ClusterId::error());
+ ASSERT_LT(BenchmarkClustering::ClusterId::noise(),
+ BenchmarkClustering::ClusterId::error());
}
TEST(ClusteringTest, Ordering1) {
- std::vector<InstructionBenchmark> Points(3);
+ std::vector<Benchmark> Points(3);
Points[0].Measurements = {
{"x", 0.0, 0.0}};
Points[2].Measurements = {
{"x", 2.0, 0.0}};
- auto Clustering = InstructionBenchmarkClustering::create(
- Points, InstructionBenchmarkClustering::ModeE::Dbscan, 2, 1.1);
+ auto Clustering = BenchmarkClustering::create(
+ Points, BenchmarkClustering::ModeE::Dbscan, 2, 1.1);
ASSERT_TRUE((bool)Clustering);
EXPECT_THAT(Clustering.get().getValidClusters(),
UnorderedElementsAre(HasPoints({0, 1, 2})));
}
TEST(ClusteringTest, Ordering2) {
- std::vector<InstructionBenchmark> Points(3);
+ std::vector<Benchmark> Points(3);
Points[0].Measurements = {
{"x", 0.0, 0.0}};
Points[2].Measurements = {
{"x", 1.0, 0.0}};
- auto Clustering = InstructionBenchmarkClustering::create(
- Points, InstructionBenchmarkClustering::ModeE::Dbscan, 2, 1.1);
+ auto Clustering = BenchmarkClustering::create(
+ Points, BenchmarkClustering::ModeE::Dbscan, 2, 1.1);
ASSERT_TRUE((bool)Clustering);
EXPECT_THAT(Clustering.get().getValidClusters(),
UnorderedElementsAre(HasPoints({0, 1, 2})));
TEST_F(MipsBenchmarkResultTest, WriteToAndReadFromDisk) {
ExitOnError ExitOnErr;
- InstructionBenchmark ToDisk;
+ Benchmark ToDisk;
ToDisk.Key.Instructions.push_back(MCInstBuilder(Mips::XOR)
.addReg(Mips::T0)
ToDisk.Key.RegisterInitialValues = {
RegisterValue{Mips::T1, APInt(8, "123", 10)},
RegisterValue{Mips::T2, APInt(8, "456", 10)}};
- ToDisk.Mode = InstructionBenchmark::Latency;
+ ToDisk.Mode = Benchmark::Latency;
ToDisk.CpuName = "cpu_name";
ToDisk.LLVMTriple = "llvm_triple";
ToDisk.NumRepetitions = 1;
{
// One-element version.
const auto FromDisk =
- ExitOnErr(InstructionBenchmark::readYaml(State, *Buffer));
+ ExitOnErr(Benchmark::readYaml(State, *Buffer));
EXPECT_THAT(FromDisk.Key.Instructions,
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
{
// Vector version.
const auto FromDiskVector =
- ExitOnErr(InstructionBenchmark::readYamls(State, *Buffer));
+ ExitOnErr(Benchmark::readYamls(State, *Buffer));
ASSERT_EQ(FromDiskVector.size(), size_t{1});
const auto &FromDisk = FromDiskVector[0];
EXPECT_THAT(FromDisk.Key.Instructions,
ExitOnError ExitOnErr;
- InstructionBenchmark ToDisk;
+ Benchmark ToDisk;
ToDisk.Key.Instructions.push_back(MCInstBuilder(X86::XOR32rr)
.addReg(X86::AL)
ToDisk.Key.RegisterInitialValues = {
RegisterValue{X86::AL, APInt(8, "-1", 10)},
RegisterValue{X86::AH, APInt(8, "123", 10)}};
- ToDisk.Mode = InstructionBenchmark::Latency;
+ ToDisk.Mode = Benchmark::Latency;
ToDisk.CpuName = "cpu_name";
ToDisk.LLVMTriple = "llvm_triple";
ToDisk.NumRepetitions = 1;
{
// Read Triples/Cpu only.
const auto TriplesAndCpus =
- ExitOnErr(InstructionBenchmark::readTriplesAndCpusFromYamls(*Buffer));
+ ExitOnErr(Benchmark::readTriplesAndCpusFromYamls(*Buffer));
ASSERT_THAT(TriplesAndCpus,
testing::ElementsAre(
- AllOf(Field(&InstructionBenchmark::TripleAndCpu::LLVMTriple,
+ AllOf(Field(&Benchmark::TripleAndCpu::LLVMTriple,
Eq("llvm_triple")),
- Field(&InstructionBenchmark::TripleAndCpu::CpuName,
+ Field(&Benchmark::TripleAndCpu::CpuName,
Eq("cpu_name")))));
}
{
// One-element version.
const auto FromDisk =
- ExitOnErr(InstructionBenchmark::readYaml(State, *Buffer));
+ ExitOnErr(Benchmark::readYaml(State, *Buffer));
EXPECT_THAT(FromDisk.Key.Instructions,
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
{
// Vector version.
const auto FromDiskVector =
- ExitOnErr(InstructionBenchmark::readYamls(State, *Buffer));
+ ExitOnErr(Benchmark::readYamls(State, *Buffer));
ASSERT_EQ(FromDiskVector.size(), size_t{1});
const auto &FromDisk = FromDiskVector[0];
EXPECT_THAT(FromDisk.Key.Instructions,
MF = &createVoidVoidPtrMachineFunction("TestFn", Mod.get(), MMI.get());
}
- void TestCommon(InstructionBenchmark::RepetitionModeE RepetitionMode) {
+ void TestCommon(Benchmark::RepetitionModeE RepetitionMode) {
const auto Repetitor = SnippetRepetitor::Create(RepetitionMode, State);
const std::vector<MCInst> Instructions = {MCInstBuilder(X86::NOOP)};
FunctionFiller Sink(*MF, {X86::EAX});
};
TEST_F(X86SnippetRepetitorTest, Duplicate) {
- TestCommon(InstructionBenchmark::Duplicate);
+ TestCommon(Benchmark::Duplicate);
// Duplicating creates a single basic block that repeats the instructions.
ASSERT_EQ(MF->getNumBlockIDs(), 1u);
EXPECT_THAT(MF->getBlockNumbered(0)->instrs(),
}
TEST_F(X86SnippetRepetitorTest, Loop) {
- TestCommon(InstructionBenchmark::Loop);
+ TestCommon(Benchmark::Loop);
// Duplicating creates an entry block, a loop body and a ret block.
ASSERT_EQ(MF->getNumBlockIDs(), 3u);
const auto &LoopBlock = *MF->getBlockNumbered(1);