summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-03-19 14:35:16 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-03-19 14:35:16 +0000
commit0872d6ae54cd64ceb2762a0e326ae962b3834427 (patch)
tree031020cb50d637f2f2a5eae33cba804f55f71c3c /vespalib
parent19bbaf872b649b3ce13809f5f9c40af065b28fee (diff)
Use a common accelrator instance.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/dotproduct/dotproductbenchmark.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.cpp11
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h3
3 files changed, 12 insertions, 4 deletions
diff --git a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
index 3588e0ce239..5b75fb46a41 100644
--- a/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
+++ b/vespalib/src/tests/dotproduct/dotproductbenchmark.cpp
@@ -60,7 +60,7 @@ template <typename T>
FullBenchmark<T>::FullBenchmark(size_t numDocs, size_t numValues)
: _values(numDocs*numValues),
_query(numValues),
- _dp(IAccelrated::getAccelrator())
+ _dp(IAccelrated::createAccelrator())
{
for (size_t i(0); i < numDocs; i++) {
for (size_t j(0); j < numValues; j++) {
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.cpp b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.cpp
index ffa994641e9..9d5256d79b2 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.cpp
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.cpp
@@ -122,7 +122,7 @@ RuntimeVerificator::RuntimeVerificator()
GenericAccelrator generic;
verify(generic);
- IAccelrated::UP thisCpu(IAccelrated::getAccelrator());
+ IAccelrated::UP thisCpu(IAccelrated::createAccelrator());
verify(*thisCpu);
}
@@ -156,9 +156,16 @@ RuntimeVerificator _G_verifyAccelrator;
IAccelrated::UP
-IAccelrated::getAccelrator()
+IAccelrated::createAccelrator()
{
return _G_selector.create();
}
+const IAccelrated &
+IAccelrated::getAccelrator()
+{
+ static IAccelrated::UP accelrator = _G_selector.create();
+ return *accelrator;
+}
+
}
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
index ea7e268bc6f..0647aca784f 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/iaccelrated.h
@@ -30,7 +30,8 @@ public:
virtual double squaredEuclideanDistance(const float * a, const float * b, size_t sz) const = 0;
virtual double squaredEuclideanDistance(const double * a, const double * b, size_t sz) const = 0;
- static IAccelrated::UP getAccelrator() __attribute__((noinline));
+ static IAccelrated::UP createAccelrator() __attribute__((noinline));
+ static const IAccelrated & getAccelrator() __attribute__((noinline));
};
}