summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-01-24 15:10:15 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-01-24 15:10:15 +0000
commit5cb24ee230a6d5f7eb1155b2746c6a3f11d28b16 (patch)
treed2d9628909144c2a1affb432392d34fc39658d55 /searchlib
parent5ff453a5a69bbae2f05ba67240f08774be025e79 (diff)
Count bits faster when hardware supports it.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvector.cpp19
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvector.h1
2 files changed, 1 insertions, 19 deletions
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.cpp b/searchlib/src/vespa/searchlib/common/bitvector.cpp
index bd6e677f8d4..e28ebe6682f 100644
--- a/searchlib/src/vespa/searchlib/common/bitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/bitvector.cpp
@@ -136,23 +136,6 @@ BitVector::count() const
}
BitVector::Index
-BitVector::internalCount(const Word *tarr, size_t sz)
-{
- Index count(0);
- size_t i(0);
- for (; (i + 3) < sz; i += 4) {
- count += Optimized::popCount(tarr[i + 0]) +
- Optimized::popCount(tarr[i + 1]) +
- Optimized::popCount(tarr[i + 2]) +
- Optimized::popCount(tarr[i + 3]);
- }
- for (; i < sz; i++) {
- count += Optimized::popCount(tarr[i]);
- }
- return count;
-}
-
-BitVector::Index
BitVector::countInterval(Index start, Index end) const
{
if (start >= end) return 0;
@@ -182,7 +165,7 @@ BitVector::countInterval(Index start, Index end) const
++endw;
}
if (startw < endw) {
- res += internalCount(bitValues + startw, endw - startw);
+ res += IAccelrated::getAccelrator()->populationCount(bitValues + startw, endw - startw);
}
if (partialEnd) {
res += Optimized::popCount(bitValues[endw] & ~endBits(last));
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.h b/searchlib/src/vespa/searchlib/common/bitvector.h
index e058f0d3f78..98e8c9adad3 100644
--- a/searchlib/src/vespa/searchlib/common/bitvector.h
+++ b/searchlib/src/vespa/searchlib/common/bitvector.h
@@ -297,7 +297,6 @@ private:
}
}
VESPA_DLL_LOCAL void repairEnds();
- VESPA_DLL_LOCAL static Index internalCount(const Word *tarr, size_t sz);
Index count() const;
bool hasTrueBitsInternal() const;
template <typename FunctionType, typename WordConverter>