summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2020-10-26 11:33:22 +0000
committerHåvard Pettersen <havardpe@oath.com>2020-10-26 12:26:31 +0000
commit61a2caf4de7152a6db3e1580bdceebdc0ec428a5 (patch)
treec04e742853e1edb344cf1230d416a82db3d95f3b /eval
parentf6aa9914191ff0fc5d1c62344b3744225ebbf335 (diff)
let fast path allocate uninitialized cell values
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/fast_value.cpp3
-rw-r--r--eval/src/vespa/eval/eval/fast_value.hpp34
-rw-r--r--eval/src/vespa/eval/instruction/generic_concat.cpp2
-rw-r--r--eval/src/vespa/eval/instruction/generic_join.cpp2
-rw-r--r--eval/src/vespa/eval/instruction/generic_map.cpp2
5 files changed, 40 insertions, 3 deletions
diff --git a/eval/src/vespa/eval/eval/fast_value.cpp b/eval/src/vespa/eval/eval/fast_value.cpp
index 2e8226257a4..aeea49835cd 100644
--- a/eval/src/vespa/eval/eval/fast_value.cpp
+++ b/eval/src/vespa/eval/eval/fast_value.cpp
@@ -15,6 +15,9 @@ struct CreateFastValueBuilderBase {
size_t num_mapped_dims, size_t subspace_size, size_t expected_subspaces)
{
assert(check_cell_type<T>(type.cell_type()));
+ if (num_mapped_dims == 0) {
+ return std::make_unique<FastDenseValue<T>>(type, subspace_size);
+ }
return std::make_unique<FastValue<T>>(type, num_mapped_dims, subspace_size, expected_subspaces);
}
};
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp
index 49b4cdc0a64..05cd7bf0ec3 100644
--- a/eval/src/vespa/eval/eval/fast_value.hpp
+++ b/eval/src/vespa/eval/eval/fast_value.hpp
@@ -253,6 +253,40 @@ template <typename T> FastValue<T>::~FastValue() = default;
//-----------------------------------------------------------------------------
+template <typename T>
+struct FastDenseValue final : Value, ValueBuilder<T> {
+
+ ValueType my_type;
+ FastCells<T> my_cells;
+
+ FastDenseValue(const ValueType &type_in, size_t subspace_size_in)
+ : my_type(type_in), my_cells(subspace_size_in)
+ {
+ my_cells.add_cells(subspace_size_in);
+ }
+ ~FastDenseValue() override;
+ const ValueType &type() const override { return my_type; }
+ const Value::Index &index() const override { return TrivialIndex::get(); }
+ TypedCells cells() const override { return TypedCells(my_cells.memory, get_cell_type<T>(), my_cells.size); }
+ ArrayRef<T> add_subspace(ConstArrayRef<vespalib::stringref>) override {
+ return ArrayRef<T>(my_cells.get(0), my_cells.size);
+ }
+ std::unique_ptr<Value> build(std::unique_ptr<ValueBuilder<T>> self) override {
+ ValueBuilder<T>* me = this;
+ assert(me == self.get());
+ self.release();
+ return std::unique_ptr<Value>(this);
+ }
+ MemoryUsage get_memory_usage() const override {
+ MemoryUsage usage = self_memory_usage<FastValue<T>>();
+ usage.merge(my_cells.estimate_extra_memory_usage());
+ return usage;
+ }
+};
+template <typename T> FastDenseValue<T>::~FastDenseValue() = default;
+
+//-----------------------------------------------------------------------------
+
template <typename LCT, typename RCT, typename OCT, typename Fun>
const Value &
FastValueIndex::sparse_full_overlap_join(const ValueType &res_type, const Fun &fun,
diff --git a/eval/src/vespa/eval/instruction/generic_concat.cpp b/eval/src/vespa/eval/instruction/generic_concat.cpp
index eaa2dbf95ae..7a2280c5db7 100644
--- a/eval/src/vespa/eval/instruction/generic_concat.cpp
+++ b/eval/src/vespa/eval/instruction/generic_concat.cpp
@@ -95,7 +95,7 @@ void my_dense_simple_concat_op(State &state, uint64_t param_in) {
const Value &rhs = state.peek(0);
const auto a = lhs.cells().typify<LCT>();
const auto b = rhs.cells().typify<RCT>();
- ArrayRef<OCT> result = state.stash.create_array<OCT>(a.size() + b.size());
+ ArrayRef<OCT> result = state.stash.create_uninitialized_array<OCT>(a.size() + b.size());
auto pos = result.begin();
for (size_t i = 0; i < a.size(); ++i) {
*pos++ = a[i];
diff --git a/eval/src/vespa/eval/instruction/generic_join.cpp b/eval/src/vespa/eval/instruction/generic_join.cpp
index 86720d6e539..b7648793e5a 100644
--- a/eval/src/vespa/eval/instruction/generic_join.cpp
+++ b/eval/src/vespa/eval/instruction/generic_join.cpp
@@ -114,7 +114,7 @@ void my_dense_join_op(State &state, uint64_t param_in) {
Fun fun(param.function);
auto lhs_cells = state.peek(1).cells().typify<LCT>();
auto rhs_cells = state.peek(0).cells().typify<RCT>();
- ArrayRef<OCT> out_cells = state.stash.create_array<OCT>(param.dense_plan.out_size);
+ ArrayRef<OCT> out_cells = state.stash.create_uninitialized_array<OCT>(param.dense_plan.out_size);
OCT *dst = out_cells.begin();
auto join_cells = [&](size_t lhs_idx, size_t rhs_idx) { *dst++ = fun(lhs_cells[lhs_idx], rhs_cells[rhs_idx]); };
param.dense_plan.execute(0, 0, join_cells);
diff --git a/eval/src/vespa/eval/instruction/generic_map.cpp b/eval/src/vespa/eval/instruction/generic_map.cpp
index 272c8b7fc35..c24f6645f70 100644
--- a/eval/src/vespa/eval/instruction/generic_map.cpp
+++ b/eval/src/vespa/eval/instruction/generic_map.cpp
@@ -22,7 +22,7 @@ void my_generic_map_op(State &state, uint64_t param_in) {
Func function(to_map_fun(param_in));
const Value &a = state.peek(0);
auto input_cells = a.cells().typify<CT>();
- auto output_cells = state.stash.create_array<CT>(input_cells.size());
+ auto output_cells = state.stash.create_uninitialized_array<CT>(input_cells.size());
auto pos = output_cells.begin();
for (CT value : input_cells) {
*pos++ = (CT) function(value);