[PATCH] D54445: [llvm-exegesis] BitVectorVector: provide assign() method, use it.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 12 13:31:51 PST 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: courbet, MaskRay, RKSimon, gchatelet, john.brawn.
Herald added a subscriber: tschuett.

Original idea by @MaskRay in https://reviews.llvm.org/D54442.
When doing the initial filing of the BitVectorVector, we know beforehand that
we will not have duplicates in the input values, and the storage is empty,
so we don't have to check before assigning.

Old: (https://reviews.llvm.org/D54418)

   Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html' (16 runs):
  
         5597.034043      task-clock (msec)         #    1.000 CPUs utilized            ( +-  0.35% )
  ...
              5.5975 +- 0.0198 seconds time elapsed  ( +-  0.35% )

New:

   Performance counter stats for './bin/llvm-exegesis -mode=analysis -analysis-epsilon=100000 -benchmarks-file=/tmp/benchmarks.yaml -analysis-inconsistencies-output-file=/tmp/clusters.html' (16 runs):
  
         5578.307677      task-clock (msec)         #    1.000 CPUs utilized            ( +-  0.18% )
  ...
              5.5800 +- 0.0101 seconds time elapsed  ( +-  0.18% )

-0.3%, not that much, but not nothing, too.


Repository:
  rL LLVM

https://reviews.llvm.org/D54445

Files:
  tools/llvm-exegesis/lib/BitVectorVector.h
  tools/llvm-exegesis/lib/Clustering.cpp


Index: tools/llvm-exegesis/lib/Clustering.cpp
===================================================================
--- tools/llvm-exegesis/lib/Clustering.cpp
+++ tools/llvm-exegesis/lib/Clustering.cpp
@@ -112,8 +112,7 @@
     CurrentCluster.PointIndices.push_back(P);
 
     // Process P's neighbors.
-    ToProcess.clear();
-    ToProcess.insert(Neighbors.begin(), Neighbors.end());
+    ToProcess.assign(Neighbors.begin(), Neighbors.end());
     while (!ToProcess.empty()) {
       // Retrieve a point from the set.
       const size_t Q = *ToProcess.begin();
Index: tools/llvm-exegesis/lib/BitVectorVector.h
===================================================================
--- tools/llvm-exegesis/lib/BitVectorVector.h
+++ tools/llvm-exegesis/lib/BitVectorVector.h
@@ -57,6 +57,14 @@
   /// Get a const_iterator to the beginning of the BitVectorVector.
   const_iterator begin() const { return vector_.begin(); }
 
+  /// Assign a range of elements, replacing the existing content.
+  template <typename It> void assign(It Start, It End) {
+    clear();
+    vector_.assign(Start, End);
+    for (const value_type Value : llvm::make_range(Start, End))
+      bitvector_.set(Value);
+  }
+
   /// Insert a range of elements into the BitVectorVector.
   template <typename It> void insert(It Start, It End) {
     for (; Start != End; ++Start) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54445.173748.patch
Type: text/x-patch
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181112/f5745f14/attachment.bin>


More information about the llvm-commits mailing list