diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-02-04 14:13:02 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-02-04 14:13:02 +0000 |
commit | 491ae609b62a4e61bedac86bf2306b1f28c9cc54 (patch) | |
tree | 3cc67831f771cfe16c57cfedabdf1890845e5237 /eval | |
parent | 38ab36b58a4e3d22c1df4c6dd2a2102a257482a5 (diff) |
remove sparse optimisation from generic code
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/fast_value.hpp | 34 | ||||
-rw-r--r-- | eval/src/vespa/eval/instruction/generic_merge.cpp | 35 |
2 files changed, 2 insertions, 67 deletions
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp index 88319df7590..6673494ccd2 100644 --- a/eval/src/vespa/eval/eval/fast_value.hpp +++ b/eval/src/vespa/eval/eval/fast_value.hpp @@ -155,12 +155,6 @@ struct FastValueIndex final : Value::Index { const std::vector<JoinAddrSource> &addr_sources, ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash); - template <typename LCT, typename RCT, typename OCT, typename Fun> - static const Value &sparse_only_merge(const ValueType &res_type, const Fun &fun, - const FastValueIndex &lhs, const FastValueIndex &rhs, - ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, - Stash &stash) __attribute((noinline)); - size_t size() const override { return map.size(); } std::unique_ptr<View> create_view(const std::vector<size_t> &dims) const override; }; @@ -429,32 +423,4 @@ FastValueIndex::sparse_no_overlap_join(const ValueType &res_type, const Fun &fun //----------------------------------------------------------------------------- -template <typename LCT, typename RCT, typename OCT, typename Fun> -const Value & -FastValueIndex::sparse_only_merge(const ValueType &res_type, const Fun &fun, - const FastValueIndex &lhs, const FastValueIndex &rhs, - ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash) -{ - size_t guess_size = lhs.map.size() + rhs.map.size(); - auto &result = stash.create<FastValue<OCT,true>>(res_type, lhs.map.addr_size(), 1, guess_size); - lhs.map.each_map_entry([&](auto lhs_subspace, auto hash) - { - result.add_mapping(lhs.map.get_addr(lhs_subspace), hash); - result.my_cells.push_back_fast(lhs_cells[lhs_subspace]); - }); - rhs.map.each_map_entry([&](auto rhs_subspace, auto hash) - { - auto rhs_addr = rhs.map.get_addr(rhs_subspace); - auto result_subspace = result.my_index.map.lookup(rhs_addr, hash); - if (result_subspace == FastAddrMap::npos()) { - result.add_mapping(rhs_addr, hash); - result.my_cells.push_back_fast(rhs_cells[rhs_subspace]); - } else { - OCT &out_cell = *result.my_cells.get(result_subspace); - out_cell = fun(out_cell, rhs_cells[rhs_subspace]); - } - }); - return result; -} - } diff --git a/eval/src/vespa/eval/instruction/generic_merge.cpp b/eval/src/vespa/eval/instruction/generic_merge.cpp index b40388aa547..7d2edfc7f0b 100644 --- a/eval/src/vespa/eval/instruction/generic_merge.cpp +++ b/eval/src/vespa/eval/instruction/generic_merge.cpp @@ -119,39 +119,8 @@ void my_mixed_merge_op(State &state, uint64_t param_in) { state.pop_pop_push(result_ref); }; -template <typename LCT, typename RCT, typename OCT, typename Fun> -void my_sparse_merge_op(State &state, uint64_t param_in) { - const auto ¶m = unwrap_param<MergeParam>(param_in); - const Value &lhs = state.peek(1); - const Value &rhs = state.peek(0); - if (auto indexes = detect_type<FastValueIndex>(lhs.index(), rhs.index())) { - auto lhs_cells = lhs.cells().typify<LCT>(); - auto rhs_cells = rhs.cells().typify<RCT>(); - if (lhs_cells.size() < rhs_cells.size()) { - return state.pop_pop_push( - FastValueIndex::sparse_only_merge<RCT,LCT,OCT,Fun>( - param.res_type, Fun(param.function), - indexes.get<1>(), indexes.get<0>(), - rhs_cells, lhs_cells, state.stash)); - } else { - return state.pop_pop_push( - FastValueIndex::sparse_only_merge<LCT,RCT,OCT,Fun>( - param.res_type, Fun(param.function), - indexes.get<0>(), indexes.get<1>(), - lhs_cells, rhs_cells, state.stash)); - } - } - auto up = generic_mixed_merge<LCT, RCT, OCT, Fun>(lhs, rhs, param); - auto &result = state.stash.create<std::unique_ptr<Value>>(std::move(up)); - const Value &result_ref = *(result.get()); - state.pop_pop_push(result_ref); -}; - struct SelectGenericMergeOp { - template <typename LCT, typename RCT, typename OCT, typename Fun> static auto invoke(const MergeParam ¶m) { - if (param.dense_subspace_size == 1) { - return my_sparse_merge_op<LCT,RCT,OCT,Fun>; - } + template <typename LCT, typename RCT, typename OCT, typename Fun> static auto invoke() { return my_mixed_merge_op<LCT,RCT,OCT,Fun>; } }; @@ -167,7 +136,7 @@ GenericMerge::make_instruction(const ValueType &lhs_type, const ValueType &rhs_t const ValueBuilderFactory &factory, Stash &stash) { const auto ¶m = stash.create<MergeParam>(lhs_type, rhs_type, function, factory); - auto fun = typify_invoke<4,MergeTypify,SelectGenericMergeOp>(lhs_type.cell_type(), rhs_type.cell_type(), param.res_type.cell_type(), function, param); + auto fun = typify_invoke<4,MergeTypify,SelectGenericMergeOp>(lhs_type.cell_type(), rhs_type.cell_type(), param.res_type.cell_type(), function); return Instruction(fun, wrap_param<MergeParam>(param)); } |