summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-03-01 13:12:41 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-03-08 21:38:36 +0000
commit72e9888bcccbc384d2485409ba055633131ed512 (patch)
tree79eb45091ead4ffeff40a1baf6cebe33edf7a9d4 /eval
parentfa93596f761848645b3ee133bfd665ece2cc06d6 (diff)
Specify destructors explicit to control inlining.
Conflicts: build_settings.cmake
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/call_nodes.cpp4
-rw-r--r--eval/src/vespa/eval/eval/call_nodes.h3
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.cpp30
-rw-r--r--eval/src/vespa/eval/eval/interpreted_function.h22
-rw-r--r--eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp3
-rw-r--r--eval/src/vespa/eval/eval/node_types.cpp12
-rw-r--r--eval/src/vespa/eval/eval/operator_nodes.cpp12
-rw-r--r--eval/src/vespa/eval/eval/operator_nodes.h10
-rw-r--r--eval/src/vespa/eval/eval/simple_tensor.cpp134
-rw-r--r--eval/src/vespa/eval/eval/tensor_spec.cpp18
-rw-r--r--eval/src/vespa/eval/eval/tensor_spec.h3
-rw-r--r--eval/src/vespa/eval/eval/test/tensor_conformance.cpp4
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp2
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h3
-rw-r--r--eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp2
-rw-r--r--eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h1
16 files changed, 170 insertions, 93 deletions
diff --git a/eval/src/vespa/eval/eval/call_nodes.cpp b/eval/src/vespa/eval/eval/call_nodes.cpp
index 8260ede54a0..cc09b53835c 100644
--- a/eval/src/vespa/eval/eval/call_nodes.cpp
+++ b/eval/src/vespa/eval/eval/call_nodes.cpp
@@ -1,6 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
#include "call_nodes.h"
#include "node_visitor.h"
@@ -8,6 +7,9 @@ namespace vespalib {
namespace eval {
namespace nodes {
+Call::~Call() { }
+
+
template <typename T> void CallHelper<T>::accept(NodeVisitor &visitor) const {
visitor.visit(static_cast<const T&>(*this));
}
diff --git a/eval/src/vespa/eval/eval/call_nodes.h b/eval/src/vespa/eval/eval/call_nodes.h
index 70996e2f629..01283a00e42 100644
--- a/eval/src/vespa/eval/eval/call_nodes.h
+++ b/eval/src/vespa/eval/eval/call_nodes.h
@@ -2,9 +2,9 @@
#pragma once
+#include "basic_nodes.h"
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include "basic_nodes.h"
#include <map>
#include <cmath>
@@ -29,6 +29,7 @@ private:
public:
Call(const vespalib::string &name_in, size_t num_params_in)
: _name(name_in), _num_params(num_params_in), _is_const(false) {}
+ ~Call();
virtual bool is_const() const override { return _is_const; }
const vespalib::string &name() const { return _name; }
size_t num_params() const { return _num_params; }
diff --git a/eval/src/vespa/eval/eval/interpreted_function.cpp b/eval/src/vespa/eval/eval/interpreted_function.cpp
index 13622e9999f..61edc4567b7 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.cpp
+++ b/eval/src/vespa/eval/eval/interpreted_function.cpp
@@ -1,6 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
#include "interpreted_function.h"
#include "node_visitor.h"
#include "node_traverser.h"
@@ -516,6 +515,7 @@ const Function *get_lambda(const nodes::Node &node) {
} // namespace vespalib::<unnamed>
+
InterpretedFunction::LazyParams::~LazyParams()
{
}
@@ -534,6 +534,34 @@ InterpretedFunction::SimpleObjectParams::resolve(size_t idx, Stash &) const
return params[idx];
}
+InterpretedFunction::State::State(const TensorEngine &engine_in)
+ : engine(engine_in),
+ params(nullptr),
+ stash(),
+ stack(),
+ let_values(),
+ program_offset(0)
+{
+}
+
+void
+InterpretedFunction::State::init(const LazyParams &params_in) {
+ params = &params_in;
+ stash.clear();
+ stack.clear();
+ let_values.clear();
+ program_offset = 0;
+ if_cnt = 0;
+}
+
+void
+InterpretedFunction::State::replace(size_t prune_cnt, const Value &value) {
+ for (size_t i = 0; i < prune_cnt; ++i) {
+ stack.pop_back();
+ }
+ stack.push_back(value);
+}
+
InterpretedFunction::Context::Context(const InterpretedFunction &ifun)
: _state(ifun._tensor_engine)
{
diff --git a/eval/src/vespa/eval/eval/interpreted_function.h b/eval/src/vespa/eval/eval/interpreted_function.h
index 3a3e6173fd5..d0e6de119af 100644
--- a/eval/src/vespa/eval/eval/interpreted_function.h
+++ b/eval/src/vespa/eval/eval/interpreted_function.h
@@ -59,25 +59,15 @@ public:
std::vector<Value::CREF> let_values;
uint32_t program_offset;
uint32_t if_cnt;
- State(const TensorEngine &engine_in)
- : engine(engine_in), params(nullptr), stash(), stack(), let_values(), program_offset(0) {}
- void init(const LazyParams &params_in) {
- params = &params_in;
- stash.clear();
- stack.clear();
- let_values.clear();
- program_offset = 0;
- if_cnt = 0;
- }
+
+ State(const TensorEngine &engine_in);
+ ~State();
+
+ void init(const LazyParams &params_in);
const Value &peek(size_t ridx) const {
return stack[stack.size() - 1 - ridx];
}
- void replace(size_t prune_cnt, const Value &value) {
- for (size_t i = 0; i < prune_cnt; ++i) {
- stack.pop_back();
- }
- stack.push_back(value);
- }
+ void replace(size_t prune_cnt, const Value &value);
};
class Context {
friend class InterpretedFunction;
diff --git a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp
index 0d404f2077b..021e850188d 100644
--- a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp
+++ b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp
@@ -163,6 +163,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser {
params.push_back(itr);
}
}
+ ~FunctionBuilder();
//-------------------------------------------------------------------------
@@ -618,6 +619,8 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser {
}
};
+FunctionBuilder::~FunctionBuilder() { }
+
} // namespace vespalib::eval::<unnamed>
struct InitializeNativeTarget {
diff --git a/eval/src/vespa/eval/eval/node_types.cpp b/eval/src/vespa/eval/eval/node_types.cpp
index 4834f102790..c02060a1060 100644
--- a/eval/src/vespa/eval/eval/node_types.cpp
+++ b/eval/src/vespa/eval/eval/node_types.cpp
@@ -72,8 +72,8 @@ struct TypeResolver : public NodeVisitor, public NodeTraverser {
using action_function = void (*)(State &);
std::vector<std::pair<const Node *, action_function>> actions;
TypeResolver(const std::vector<ValueType> &params_in,
- std::map<const Node *, ValueType> &type_map_out)
- : state(params_in, type_map_out), actions() {}
+ std::map<const Node *, ValueType> &type_map_out);
+ ~TypeResolver();
//-------------------------------------------------------------------------
@@ -242,6 +242,14 @@ struct TypeResolver : public NodeVisitor, public NodeTraverser {
}
};
+TypeResolver::TypeResolver(const std::vector<ValueType> &params_in,
+ std::map<const Node *, ValueType> &type_map_out)
+ : state(params_in, type_map_out),
+ actions()
+{ }
+
+TypeResolver::~TypeResolver() { }
+
} // namespace vespalib::eval::nodes::<unnamed>
} // namespace vespalib::eval::nodes
diff --git a/eval/src/vespa/eval/eval/operator_nodes.cpp b/eval/src/vespa/eval/eval/operator_nodes.cpp
index ab6955a8248..ea8ab56030f 100644
--- a/eval/src/vespa/eval/eval/operator_nodes.cpp
+++ b/eval/src/vespa/eval/eval/operator_nodes.cpp
@@ -1,6 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
#include "operator_nodes.h"
#include "node_visitor.h"
@@ -8,6 +7,17 @@ namespace vespalib {
namespace eval {
namespace nodes {
+Operator::Operator(const vespalib::string &op_str_in, int priority_in, Order order_in)
+ : _op_str(op_str_in),
+ _priority(priority_in),
+ _order(order_in),
+ _lhs(),
+ _rhs(),
+ _is_const(false)
+{}
+
+Operator::~Operator() { }
+
template <typename T> void OperatorHelper<T>::accept(NodeVisitor &visitor) const {
visitor.visit(static_cast<const T&>(*this));
}
diff --git a/eval/src/vespa/eval/eval/operator_nodes.h b/eval/src/vespa/eval/eval/operator_nodes.h
index 34b1e60d571..a0726137015 100644
--- a/eval/src/vespa/eval/eval/operator_nodes.h
+++ b/eval/src/vespa/eval/eval/operator_nodes.h
@@ -2,11 +2,11 @@
#pragma once
-#include <cmath>
-#include <memory>
+#include "basic_nodes.h"
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include "basic_nodes.h"
+#include <cmath>
+#include <memory>
#include <map>
namespace vespalib {
@@ -35,8 +35,8 @@ private:
bool _is_const;
public:
- Operator(const vespalib::string &op_str_in, int priority_in, Order order_in)
- : _op_str(op_str_in), _priority(priority_in), _order(order_in), _lhs(), _rhs(), _is_const(false) {}
+ Operator(const vespalib::string &op_str_in, int priority_in, Order order_in);
+ ~Operator();
vespalib::string op_str() const { return _op_str; }
int priority() const { return _priority; }
Order order() const { return _order; }
diff --git a/eval/src/vespa/eval/eval/simple_tensor.cpp b/eval/src/vespa/eval/eval/simple_tensor.cpp
index fbe2278a0c9..8845974acf7 100644
--- a/eval/src/vespa/eval/eval/simple_tensor.cpp
+++ b/eval/src/vespa/eval/eval/simple_tensor.cpp
@@ -141,27 +141,8 @@ private:
size_t _block_size;
BlockMap _blocks;
public:
- explicit Builder(const ValueType &type)
- : _type(type),
- _mapped(),
- _indexed(),
- _block_size(1),
- _blocks()
- {
- assert_type(_type);
- for (size_t i = 0; i < type.dimensions().size(); ++i) {
- const auto &dimension = _type.dimensions()[i];
- if (dimension.is_mapped()) {
- _mapped.push_back(i);
- } else {
- _block_size *= dimension.size;
- _indexed.push_back(i);
- }
- }
- if (_mapped.empty()) {
- _blocks.emplace(Address(), Block(_type, _indexed, _block_size));
- }
- }
+ explicit Builder(const ValueType &type);
+ ~Builder();
void set(const Address &address, double value) {
assert_address(address, _type);
Address block_key = select(address, _mapped);
@@ -189,6 +170,29 @@ public:
}
};
+Builder::Builder(const ValueType &type)
+ : _type(type),
+ _mapped(),
+ _indexed(),
+ _block_size(1),
+ _blocks()
+{
+ assert_type(_type);
+ for (size_t i = 0; i < type.dimensions().size(); ++i) {
+ const auto &dimension = _type.dimensions()[i];
+ if (dimension.is_mapped()) {
+ _mapped.push_back(i);
+ } else {
+ _block_size *= dimension.size;
+ _indexed.push_back(i);
+ }
+ }
+ if (_mapped.empty()) {
+ _blocks.emplace(Address(), Block(_type, _indexed, _block_size));
+ }
+}
+Builder::~Builder() { }
+
/**
* Helper class used to calculate which dimensions are shared between
* types and which are not. Also calculates how address elements from
@@ -204,42 +208,18 @@ struct TypeAnalyzer {
IndexList combine;
size_t ignored_a;
size_t ignored_b;
- TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore = "")
- : only_a(), overlap_a(), overlap_b(), only_b(), combine(), ignored_a(npos), ignored_b(npos)
- {
- const auto &a = lhs.dimensions();
- const auto &b = rhs.dimensions();
- size_t b_idx = 0;
- for (size_t a_idx = 0; a_idx < a.size(); ++a_idx) {
- while ((b_idx < b.size()) && (b[b_idx].name < a[a_idx].name)) {
- if (b[b_idx].name != ignore) {
- only_b.push_back(b_idx);
- combine.push_back(a.size() + b_idx);
- } else {
- ignored_b = b_idx;
- }
- ++b_idx;
- }
- if ((b_idx < b.size()) && (b[b_idx].name == a[a_idx].name)) {
- if (a[a_idx].name != ignore) {
- overlap_a.push_back(a_idx);
- overlap_b.push_back(b_idx);
- combine.push_back(a_idx);
- } else {
- ignored_a = a_idx;
- ignored_b = b_idx;
- }
- ++b_idx;
- } else {
- if (a[a_idx].name != ignore) {
- only_a.push_back(a_idx);
- combine.push_back(a_idx);
- } else {
- ignored_a = a_idx;
- }
- }
- }
- while (b_idx < b.size()) {
+ TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore = "");
+ ~TypeAnalyzer();
+};
+
+TypeAnalyzer::TypeAnalyzer(const ValueType &lhs, const ValueType &rhs, const vespalib::string &ignore)
+ : only_a(), overlap_a(), overlap_b(), only_b(), combine(), ignored_a(npos), ignored_b(npos)
+{
+ const auto &a = lhs.dimensions();
+ const auto &b = rhs.dimensions();
+ size_t b_idx = 0;
+ for (size_t a_idx = 0; a_idx < a.size(); ++a_idx) {
+ while ((b_idx < b.size()) && (b[b_idx].name < a[a_idx].name)) {
if (b[b_idx].name != ignore) {
only_b.push_back(b_idx);
combine.push_back(a.size() + b_idx);
@@ -248,8 +228,37 @@ struct TypeAnalyzer {
}
++b_idx;
}
+ if ((b_idx < b.size()) && (b[b_idx].name == a[a_idx].name)) {
+ if (a[a_idx].name != ignore) {
+ overlap_a.push_back(a_idx);
+ overlap_b.push_back(b_idx);
+ combine.push_back(a_idx);
+ } else {
+ ignored_a = a_idx;
+ ignored_b = b_idx;
+ }
+ ++b_idx;
+ } else {
+ if (a[a_idx].name != ignore) {
+ only_a.push_back(a_idx);
+ combine.push_back(a_idx);
+ } else {
+ ignored_a = a_idx;
+ }
+ }
}
-};
+ while (b_idx < b.size()) {
+ if (b[b_idx].name != ignore) {
+ only_b.push_back(b_idx);
+ combine.push_back(a.size() + b_idx);
+ } else {
+ ignored_b = b_idx;
+ }
+ ++b_idx;
+ }
+}
+
+TypeAnalyzer::~TypeAnalyzer() { }
/**
* A view is a total ordering of cells from a SimpleTensor according
@@ -316,6 +325,7 @@ public:
}
std::sort(_refs.begin(), _refs.end(), _less);
}
+ ~View();
const IndexList &selector() const { return _less.selector; }
const CellRef *refs_begin() const { return &_refs[0]; }
const CellRef *refs_end() const { return (refs_begin() + _refs.size()); }
@@ -323,6 +333,8 @@ public:
EqualRange next_range(const EqualRange &prev) const { return make_range(prev.end()); }
};
+View::~View() { }
+
/**
* Helper class used to find matching EqualRanges from two different
* SimpleTensor Views.
@@ -343,6 +355,7 @@ public:
{
assert(a_selector.size() == b_selector.size());
}
+ ~CrossCompare();
Result compare(const Cell &a, const Cell &b) const {
for (size_t i = 0; i < a_selector.size(); ++i) {
if (a.address[a_selector[i]] != b.address[b_selector[i]]) {
@@ -392,6 +405,7 @@ public:
{
find_match();
}
+ ~ViewMatcher();
bool valid() const { return (has_a() && has_b()); }
const EqualRange &get_a() const { return _a_range; }
const EqualRange &get_b() const { return _b_range; }
@@ -402,6 +416,10 @@ public:
}
};
+ViewMatcher::~ViewMatcher() { }
+
+ViewMatcher::CrossCompare::~CrossCompare() { }
+
} // namespace vespalib::eval::<unnamed>
constexpr size_t TensorSpec::Label::npos;
diff --git a/eval/src/vespa/eval/eval/tensor_spec.cpp b/eval/src/vespa/eval/eval/tensor_spec.cpp
index eec930b8da4..dfd8b06bb52 100644
--- a/eval/src/vespa/eval/eval/tensor_spec.cpp
+++ b/eval/src/vespa/eval/eval/tensor_spec.cpp
@@ -1,17 +1,23 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
-#include <vespa/vespalib/util/stringfmt.h>
#include "tensor_spec.h"
-#include <iostream>
+#include <vespa/vespalib/util/stringfmt.h>
+#include <ostream>
namespace vespalib {
namespace eval {
+TensorSpec::TensorSpec(const vespalib::string &type_spec)
+ : _type(type_spec),
+ _cells()
+{ }
+
+TensorSpec::~TensorSpec() { }
+
vespalib::string
TensorSpec::to_string() const
{
- vespalib::string out = vespalib::make_string("spec(%s) {\n", _type.c_str());
+ vespalib::string out = make_string("spec(%s) {\n", _type.c_str());
for (const auto &cell: _cells) {
size_t n = 0;
out.append(" [");
@@ -22,10 +28,10 @@ TensorSpec::to_string() const
if (label.second.is_mapped()) {
out.append(label.second.name);
} else {
- out.append(vespalib::make_string("%zu", label.second.index));
+ out.append(make_string("%zu", label.second.index));
}
}
- out.append(vespalib::make_string("]: %g\n", cell.second.value));
+ out.append(make_string("]: %g\n", cell.second.value));
}
out.append("}");
return out;
diff --git a/eval/src/vespa/eval/eval/tensor_spec.h b/eval/src/vespa/eval/eval/tensor_spec.h
index 06a9a3a2825..4f615d21906 100644
--- a/eval/src/vespa/eval/eval/tensor_spec.h
+++ b/eval/src/vespa/eval/eval/tensor_spec.h
@@ -54,7 +54,8 @@ private:
vespalib::string _type;
Cells _cells;
public:
- TensorSpec(const vespalib::string &type_spec) : _type(type_spec), _cells() {}
+ TensorSpec(const vespalib::string &type_spec);
+ ~TensorSpec();
TensorSpec &add(const Address &address, double value) {
_cells.emplace(address, value);
return *this;
diff --git a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
index 2445160bcd9..93b0cde7363 100644
--- a/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
+++ b/eval/src/vespa/eval/eval/test/tensor_conformance.cpp
@@ -124,7 +124,11 @@ struct Domain {
: dimension(dimension_in), size(size_in), keys() {}
Domain(const vespalib::string &dimension_in, const std::vector<vespalib::string> &keys_in)
: dimension(dimension_in), size(0), keys(keys_in) {}
+ ~Domain();
};
+
+Domain::~Domain() { }
+
using Layout = std::vector<Domain>;
Domain x() { return Domain("x", {}); }
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp
index 53af60bd101..a85a65ed8a9 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.cpp
@@ -33,6 +33,8 @@ public:
}
+DenseTensorAddressCombiner::~DenseTensorAddressCombiner() { }
+
DenseTensorAddressCombiner::DenseTensorAddressCombiner(const eval::ValueType &lhs,
const eval::ValueType &rhs)
: _ops(),
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h
index 482b7f86fc1..9e5f009fa82 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_address_combiner.h
@@ -2,10 +2,10 @@
#pragma once
+#include "dense_tensor_cells_iterator.h"
#include <vespa/eval/tensor/tensor.h>
#include <vespa/eval/tensor/types.h>
#include <vespa/eval/eval/value_type.h>
-#include "dense_tensor_cells_iterator.h"
namespace vespalib {
namespace tensor {
@@ -36,6 +36,7 @@ private:
public:
DenseTensorAddressCombiner(const eval::ValueType &lhs,
const eval::ValueType &rhs);
+ ~DenseTensorAddressCombiner();
bool combine(const CellsIterator &lhsItr,
const CellsIterator &rhsItr);
diff --git a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp
index 8a7ed1928ef..e98bc0261d8 100644
--- a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp
+++ b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.cpp
@@ -35,6 +35,8 @@ calculateCellAddress(const Address &address, const ValueType &type)
}
+DirectDenseTensorBuilder::~DirectDenseTensorBuilder() { }
+
DirectDenseTensorBuilder::DirectDenseTensorBuilder(const ValueType &type_in)
: _type(type_in),
_cells(calculateCellsSize(_type))
diff --git a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h
index b5329860e86..dc755e5bd1d 100644
--- a/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h
+++ b/eval/src/vespa/eval/tensor/dense/direct_dense_tensor_builder.h
@@ -22,6 +22,7 @@ private:
public:
DirectDenseTensorBuilder(const eval::ValueType &type_in);
+ ~DirectDenseTensorBuilder();
void insertCell(const Address &address, double cellValue);
Tensor::UP build();
};