[PATCH] D54415: [llvm-exegesis] InstructionBenchmarkClustering::rangeQuery(): reserve for the upper bound of Neighbors
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 19 05:32:00 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347204: [llvm-exegesis] (+final perf overview) InstructionBenchmarkClustering… (authored by lebedevri, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D54415?vs=173619&id=174599#toc
Repository:
rL LLVM
https://reviews.llvm.org/D54415
Files:
llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp
llvm/trunk/tools/llvm-exegesis/lib/Clustering.h
Index: llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp
===================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp
+++ llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp
@@ -34,8 +34,9 @@
// Finds the points at distance less than sqrt(EpsilonSquared) of Q (not
// including Q).
void InstructionBenchmarkClustering::rangeQuery(
- const size_t Q, llvm::SmallVectorImpl<size_t> &Neighbors) const {
+ const size_t Q, std::vector<size_t> &Neighbors) const {
Neighbors.clear();
+ Neighbors.reserve(Points_.size() - 1); // The Q itself isn't a neighbor.
const auto &QMeasurements = Points_[Q].Measurements;
for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) {
if (P == Q)
@@ -91,7 +92,7 @@
}
void InstructionBenchmarkClustering::dbScan(const size_t MinPts) {
- llvm::SmallVector<size_t, 0> Neighbors; // Persistent buffer to avoid allocs.
+ 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())
continue; // Previously processed in inner loop.
@@ -136,6 +137,8 @@
}
}
}
+ // assert(Neighbors.capacity() == (Points_.size() - 1));
+ // ^ True, but it is not quaranteed to be true in all the cases.
// Add noisy points to noise cluster.
for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) {
Index: llvm/trunk/tools/llvm-exegesis/lib/Clustering.h
===================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/Clustering.h
+++ llvm/trunk/tools/llvm-exegesis/lib/Clustering.h
@@ -104,7 +104,7 @@
const std::vector<InstructionBenchmark> &Points, double EpsilonSquared);
llvm::Error validateAndSetup();
void dbScan(size_t MinPts);
- void rangeQuery(size_t Q, llvm::SmallVectorImpl<size_t> &Scratchpad) const;
+ void rangeQuery(size_t Q, std::vector<size_t> &Scratchpad) const;
const std::vector<InstructionBenchmark> &Points_;
const double EpsilonSquared_;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54415.174599.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/82b6c677/attachment.bin>
More information about the llvm-commits
mailing list