21 template <
typename T,
bool Aligned>
22 struct memory_slice_view {
41 template <
typename V = default_vec>
58 return sub[first + j];
67 return sub[first + j];
77 return sub[first + j];
86 template <
typename V = default_vec>
87 auto load(
size_t x)
const noexcept {
88 if constexpr (Aligned) {
89 return sub.template load<V>(x + first);
91 return sub.template loadu<V>(x + first);
101 template <
typename V = default_vec>
102 auto loadu(
size_t x)
const noexcept {
103 return sub.template loadu<V>(x + first);
112 template <
typename V = default_vec>
114 if constexpr (Aligned) {
115 sub.template store<V>(in, first + i);
117 sub.template storeu<V>(in, first + i);
127 template <
typename V = default_vec>
129 sub.template storeu<V>(in, first + i);
138 template <
typename V = default_vec>
140 if constexpr (Aligned) {
141 sub.template stream<V>(in, first + i);
143 sub.template storeu<V>(in, first + i);
152 template <
typename E>
153 bool alias(
const E& rhs)
const noexcept {
154 return sub.alias(rhs);
162 return sub.memory_start() + first;
170 return sub.memory_start() + first;
178 return sub.memory_start() + last;
186 return sub.memory_start() + last;
195 template <
typename L>
204 template <
typename L>
213 template <
typename L>
222 template <
typename L>
231 template <
typename L>
240 template <
typename L>
261 sub.ensure_cpu_up_to_date();
270 sub.ensure_gpu_up_to_date();
277 template <
typename T,
bool Aligned>
283 static constexpr
bool is_etl =
true;
290 static constexpr
bool is_value =
false;
292 static constexpr
bool is_generator =
false;
293 static constexpr
bool is_padded =
false;
294 static constexpr
bool is_aligned = Aligned;
296 static constexpr
bool gpu_computable =
false;
304 template <vector_mode_t V>
313 return v.last - v.first;
322 static size_t dim(
const expr_t& v, [[maybe_unused]]
size_t d) {
323 return v.last - v.first;
350 template <
bool Aligned = false, etl_expr E>
const_memory_type memory_start() const noexcept
Returns a pointer to the first element in memory.
Definition: memory_slice_view.hpp:169
void assign_mul_to(L &&lhs) const
Multiply the given left-hand-side expression.
Definition: memory_slice_view.hpp:223
void assign_sub_to(L &&lhs) const
Sub from the given left-hand-side expression.
Definition: memory_slice_view.hpp:214
void visit(detail::evaluator_visitor &visitor) const
Apply the given visitor to this expression and its descendants.
Definition: memory_slice_view.hpp:251
void stream(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once, using non-temporal store.
Definition: memory_slice_view.hpp:139
static size_t size(const expr_t &v)
Returns the size of the given expression.
Definition: memory_slice_view.hpp:312
void storeu(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once.
Definition: memory_slice_view.hpp:128
void std_assign_evaluate(Expr &&expr, Result &&result)
Evaluation of the expr into result.
Definition: evaluator.hpp:1176
void assign_add_to(L &&lhs) const
Add to the given left-hand-side expression.
Definition: memory_slice_view.hpp:205
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
auto loadu(size_t x) const noexcept
Load several elements of the expression at once.
Definition: memory_slice_view.hpp:102
memory_slice_view(sub_type sub, size_t first, size_t last)
Construct a new memory_slice_view over the given sub expression.
Definition: memory_slice_view.hpp:50
void ensure_gpu_up_to_date() const
Copy back from the GPU to the expression memory if necessary.
Definition: memory_slice_view.hpp:268
order
Storage order of a matrix.
Definition: order.hpp:15
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: memory_slice_view.hpp:338
View that shows a slice of an expression.
Definition: expr_fwd.hpp:74
memory_type memory_start() noexcept
Returns a pointer to the first element in memory.
Definition: memory_slice_view.hpp:161
std::conditional_t< std::is_lvalue_reference_v< S >, const value_t< T > &, value_t< T > > const_return_helper
Definition: traits.hpp:872
An unary expression.
Definition: unary_expr.hpp:126
constexpr bool is_fast
Traits to test if the given ETL expresion type is fast (sizes known at compile-time) ...
Definition: traits.hpp:588
static constexpr size_t dimensions()
Returns the number of expressions for this type.
Definition: memory_slice_view.hpp:330
void ensure_cpu_up_to_date() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: memory_slice_view.hpp:259
value_t< sub_type > value_type
The value contained in the expression.
Definition: memory_slice_view.hpp:24
return_type operator[](size_t j)
Returns the element at the given index.
Definition: memory_slice_view.hpp:66
Traits to get information about ETL types.
Definition: tmp.hpp:68
const_return_helper< sub_type, decltype(std::declval< sub_type >()[0])> const_return_type
The const type return by the view.
Definition: memory_slice_view.hpp:28
Root namespace for the ETL library.
Definition: adapter.hpp:15
typename V::template vec_type< value_type > vec_type
The vectorization type for V.
Definition: memory_slice_view.hpp:42
std::conditional_t< std::is_const_v< std::remove_reference_t< S > >, const value_t< T > &, std::conditional_t< std::is_lvalue_reference_v< S > &&!std::is_const_v< T >, value_t< T > &, value_t< T > >> return_helper
Definition: traits.hpp:866
const_memory_type memory_end() const noexcept
Returns a pointer to the past-the-end element in memory.
Definition: memory_slice_view.hpp:185
auto load(size_t x) const noexcept
Load several elements of the expression at once.
Definition: memory_slice_view.hpp:87
const_return_type operator[](size_t j) const
Returns the element at the given index.
Definition: memory_slice_view.hpp:57
static size_t dim(const expr_t &v, [[maybe_unused]] size_t d)
Returns the dth dimension of the given expression.
Definition: memory_slice_view.hpp:322
Visitor to perform local evaluation when necessary.
Definition: eval_visitors.hpp:23
typename etl_traits< sub_expr_t >::value_type value_type
The value type.
Definition: memory_slice_view.hpp:281
void assign_div_to(L &&lhs) const
Divide the given left-hand-side expression.
Definition: memory_slice_view.hpp:232
void std_mod_evaluate(Expr &&expr, Result &&result)
Compound modulo evaluation of the expr into result.
Definition: evaluator.hpp:1271
memory_type memory_end() noexcept
Returns a pointer to the past-the-end element in memory.
Definition: memory_slice_view.hpp:177
void assign_to(L &&lhs) const
Assign to the given left-hand-side expression.
Definition: memory_slice_view.hpp:196
void std_mul_evaluate(Expr &&expr, Result &&result)
Compound multiply evaluation of the expr into result.
Definition: evaluator.hpp:1233
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
const value_type * const_memory_type
The const memory access type.
Definition: memory_slice_view.hpp:26
void assign_mod_to(L &&lhs) const
Modulo the given left-hand-side expression.
Definition: memory_slice_view.hpp:241
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
value_type * memory_type
The memory acess type.
Definition: memory_slice_view.hpp:25
void store(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once.
Definition: memory_slice_view.hpp:113
T sub_type
The sub type.
Definition: memory_slice_view.hpp:23
auto memory_slice(E &&value, size_t first, size_t last) -> detail::identity_helper< E, memory_slice_view< detail::build_identity_type< E >, Aligned >>
Returns view representing a memory slice view of the given expression.
Definition: memory_slice_view.hpp:351
void std_sub_evaluate(Expr &&expr, Result &&result)
Compound subtract evaluation of the expr into result.
Definition: evaluator.hpp:1214
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
value_type read_flat(size_t j) const noexcept
Returns the value at the given index This function never has side effects.
Definition: memory_slice_view.hpp:76
std::decay_t< T > sub_expr_t
The sub expression type.
Definition: memory_slice_view.hpp:280
bool alias(const E &rhs) const noexcept
Test if this expression aliases with the given expression.
Definition: memory_slice_view.hpp:153
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
void std_div_evaluate(Expr &&expr, Result &&result)
Compound divide evaluation of the expr into result.
Definition: evaluator.hpp:1252
return_helper< sub_type, decltype(std::declval< sub_type >()[0])> return_type
The type returned by the view.
Definition: memory_slice_view.hpp:27
void std_add_evaluate(Expr &&expr, Result &&result)
Compound add evaluation of the expr into result.
Definition: evaluator.hpp:1195