aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-05-22 22:32:10 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-05-22 22:48:22 +0000
commitaa839c11eb6861401026f6fff3b4c2e68426f71c (patch)
treeaa57a409b60acf306c74ac425780f8ec8150e782 /vespalib
parent8e998d910756843efafb16e03690eec863af4ce6 (diff)
Add optimized support for array<byte>
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/generic.cpp11
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/generic.h2
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp11
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.h1
5 files changed, 27 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/generic.cpp b/vespalib/src/vespa/vespalib/hwaccelrated/generic.cpp
index 1bf7ea1c44c..d70071525c6 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/generic.cpp
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/generic.cpp
@@ -71,6 +71,17 @@ GenericAccelrator::dotProduct(const double * a, const double * b, size_t sz) con
}
int64_t
+GenericAccelrator::dotProduct(const int8_t * a, const int8_t * b, size_t sz) const
+{
+ return multiplyAdd<int64_t, int8_t, 4>(a, b, sz);
+}
+
+int64_t
+GenericAccelrator::dotProduct(const int16_t * a, const int16_t * b, size_t sz) const
+{
+ return multiplyAdd<int64_t, int16_t, 4>(a, b, sz);
+}
+int64_t
GenericAccelrator::dotProduct(const int32_t * a, const int32_t * b, size_t sz) const
{
return multiplyAdd<int64_t, int32_t, 4>(a, b, sz);
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/generic.h b/vespalib/src/vespa/vespalib/hwaccelrated/generic.h
index 0115d5c55c7..f9aab3ae845 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/generic.h
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/generic.h
@@ -14,6 +14,8 @@ class GenericAccelrator : public IAccelrated
public:
float dotProduct(const float * a, const float * b, size_t sz) const override;
double dotProduct(const double * a, const double * b, size_t sz) const override;
+ int64_t dotProduct(const int8_t * a, const int8_t * b, size_t sz) const override;
+ int64_t dotProduct(const int16_t * a, const int16_t * b, size_t sz) const override;
int64_t dotProduct(const int32_t * a, const int32_t * b, size_t sz) const override;
long long dotProduct(const int64_t * a, const int64_t * b, size_t sz) const override;
void orBit(void * a, const void * b, size_t bytes) const override;
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
index 7c2f2547240..aae60279d06 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
@@ -18,6 +18,8 @@ public:
typedef std::unique_ptr<IAccelrated> UP;
virtual float dotProduct(const float * a, const float * b, size_t sz) const = 0;
virtual double dotProduct(const double * a, const double * b, size_t sz) const = 0;
+ virtual int64_t dotProduct(const int8_t * a, const int8_t * b, size_t sz) const = 0;
+ virtual int64_t dotProduct(const int16_t * a, const int16_t * b, size_t sz) const = 0;
virtual int64_t dotProduct(const int32_t * a, const int32_t * b, size_t sz) const = 0;
virtual long long dotProduct(const int64_t * a, const int64_t * b, size_t sz) const = 0;
virtual void orBit(void * a, const void * b, size_t bytes) const = 0;
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index c141d35e80e..30a963c374c 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -235,6 +235,17 @@ asciistream & asciistream::operator >> (char & v)
return *this;
}
+asciistream & asciistream::operator >> (signed char & v)
+{
+ for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
+ if (_rPos < length()) {
+ v = _rbuf[_rPos++];
+ } else {
+ throwUnderflow(_rPos);
+ }
+ return *this;
+}
+
asciistream & asciistream::operator >> (unsigned char & v)
{
for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.h b/vespalib/src/vespa/vespalib/stllike/asciistream.h
index 88c3e1f7fc8..2f11d902283 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.h
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.h
@@ -64,6 +64,7 @@ public:
asciistream & operator >> (FloatModifier v) { _floatModifier = v; return *this; }
asciistream & operator >> (bool & v);
asciistream & operator >> (char & v);
+ asciistream & operator >> (signed char & v);
asciistream & operator >> (unsigned char & v);
asciistream & operator >> (std::string & v);
asciistream & operator >> (string & v);