summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-04-30 14:14:36 +0200
committerTor Egge <Tor.Egge@online.no>2021-04-30 14:14:36 +0200
commit9f54313f75fd089abed817a956022965b00b03ea (patch)
tree22a64e08b9673bc1cedf92246fa9937d362381ed /searchlib
parentcf0d0a6d071f19d830633267796fca09f67ba89d (diff)
Avoid SSE built-in functions when CPU arch is not x86_64.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp b/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
index a49f44a2853..08056725389 100644
--- a/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
@@ -19,6 +19,7 @@ namespace queryeval {
namespace {
+#ifdef __x86_64__
class SkipMinFeatureSSE2 : public SkipMinFeature
{
public:
@@ -83,13 +84,49 @@ SkipMinFeatureSSE2::next()
return -1;
}
}
+#else
+class SkipMinFeatureGeneric : public SkipMinFeature
+{
+ const uint8_t* _min_feature;
+ const uint8_t* _kv;
+ const uint32_t _sz;
+ uint32_t _cur;
+public:
+ SkipMinFeatureGeneric(const uint8_t* min_feature, const uint8_t* kv, size_t sz);
+ uint32_t next() override;
+};
+
+SkipMinFeatureGeneric::SkipMinFeatureGeneric(const uint8_t* min_feature, const uint8_t* kv, size_t sz)
+ : _min_feature(min_feature),
+ _kv(kv),
+ _sz(sz),
+ _cur(0)
+{
+}
+
+uint32_t
+SkipMinFeatureGeneric::next()
+{
+ while (_cur < _sz) {
+ if (_kv[_cur] >= _min_feature[_cur]) {
+ return _cur++;
+ }
+ ++_cur;
+ }
+ return -1;
+}
+#endif
}
SkipMinFeature::UP
SkipMinFeature::create(const uint8_t * min_feature, const uint8_t * kv, size_t sz)
{
- return UP(new SkipMinFeatureSSE2(min_feature, kv, sz));
+#ifdef __x86_64__
+ return std::make_unique<SkipMinFeatureSSE2>(min_feature, kv, sz);
+#else
+ return std::make_unique<SkipMinFeatureGeneric>(min_feature, kv, sz);
+#endif
}
PredicateSearch::PredicateSearch(const uint8_t * minFeatureVector,