19 template <
typename T,
bool DMA,
size_t... Dims>
20 struct fast_matrix_view;
27 template <
typename T,
size_t... Dims>
30 assignable<fast_matrix_view<T, false, Dims...>, value_t<T>> {
44 template <
typename V = default_vec>
47 using assignable_base_type::operator=;
54 static constexpr
size_t n_dimensions =
sizeof...(Dims);
90 return sub.read_flat(j);
98 template <size_c... S>
100 return sub[etl::fast_index<this_type>(
static_cast<size_t>(args)...)];
108 template <size_c... S>
110 return sub[etl::fast_index<this_type>(
static_cast<size_t>(args)...)];
137 template <
typename V = default_vec>
138 auto load(
size_t x)
const noexcept {
139 return sub.template load<V>(x);
148 template <
typename V = default_vec>
149 auto loadu(
size_t x)
const noexcept {
150 return sub.template loadu<V>(x);
159 template <
typename V = default_vec>
161 sub.template store<V>(in, i);
170 template <
typename V = default_vec>
172 sub.template storeu<V>(in, i);
181 template <
typename V = default_vec>
183 sub.template stream<V>(in, i);
191 template <
typename E>
192 bool alias(
const E& rhs)
const noexcept {
193 return sub.alias(rhs);
202 template <
typename L>
211 template <
typename L>
220 template <
typename L>
229 template <
typename L>
238 template <
typename L>
247 template <
typename L>
268 sub.ensure_cpu_up_to_date();
277 sub.ensure_gpu_up_to_date();
287 return os <<
"reshape(" << v.sub <<
")";
296 template <
typename T,
size_t... Dims>
299 assignable<fast_matrix_view<T, true, Dims...>, value_t<T>> {
313 template <
typename V = default_vec>
316 using assignable_base_type::operator=;
325 static constexpr
size_t n_dimensions =
sizeof...(Dims);
337 standard_evaluator::pre_assign_rhs(*
this);
340 this->memory = this->sub.memory_start();
342 cpp_assert(this->memory,
"Invalid memory");
351 cpp_assert(memory,
"Memory has not been initialized");
362 cpp_assert(memory,
"Memory has not been initialized");
375 cpp_assert(memory,
"Memory has not been initialized");
385 template <size_c... S>
387 cpp_assert(memory,
"Memory has not been initialized");
390 return memory[etl::fast_index<this_type>(
static_cast<size_t>(args)...)];
398 template <size_c... S>
400 cpp_assert(memory,
"Memory has not been initialized");
402 return memory[etl::fast_index<this_type>(
static_cast<size_t>(args)...)];
429 template <
typename V = default_vec>
430 auto load(
size_t x)
const noexcept {
440 template <
typename V = default_vec>
441 auto loadu(
size_t x)
const noexcept {
451 template <
typename V = default_vec>
462 template <
typename V = default_vec>
464 sub.template store<V>(in, i);
473 template <
typename V = default_vec>
483 template <
typename E>
484 bool alias(
const E& rhs)
const noexcept {
485 return sub.alias(rhs);
493 return sub.memory_start();
501 return sub.memory_start();
509 return sub.memory_end();
517 return sub.memory_end();
526 template <
typename L>
535 template <
typename L>
544 template <
typename L>
553 template <
typename L>
562 template <
typename L>
571 template <
typename L>
591 return sub.gpu_memory();
605 sub.invalidate_cpu();
612 sub.invalidate_gpu();
634 sub.ensure_gpu_allocated();
641 sub.ensure_gpu_up_to_date();
649 sub.ensure_cpu_up_to_date();
657 sub.gpu_copy_from(gpu_memory);
665 return sub.is_cpu_up_to_date();
673 return sub.is_gpu_up_to_date();
683 return os <<
"reshape(" << v.sub <<
")";
690 template <
typename T,
bool DMA,
size_t... Dims>
697 static constexpr
bool is_etl =
true;
701 static constexpr
bool is_linear = sub_traits::is_linear;
704 static constexpr
bool is_value =
false;
705 static constexpr
bool is_direct = sub_traits::is_direct;
706 static constexpr
bool is_generator =
false;
707 static constexpr
bool is_padded =
false;
708 static constexpr
bool is_aligned =
false;
709 static constexpr
bool is_temporary = sub_traits::is_temporary;
710 static constexpr
bool gpu_computable =
false;
711 static constexpr
order storage_order = sub_traits::storage_order;
718 template <vector_mode_t V>
719 static constexpr
bool vectorizable = sub_traits::template vectorizable<V>;
726 static constexpr
size_t size([[maybe_unused]]
const expr_t& v) {
736 static size_t dim([[maybe_unused]]
const expr_t& v,
size_t d) {
744 static constexpr
size_t size() {
754 static constexpr
size_t dim() {
763 return sizeof...(Dims);
static constexpr size_t size([[maybe_unused]] const expr_t &v)
Returns the size of the given expression.
Definition: fast_matrix_view.hpp:726
CRTP class to inject iterators functions.
Definition: iterable.hpp:23
void assign_add_to(L &&lhs) const
Add to the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:217
static constexpr size_t size()
Returns the size of an expression of this fast type.
Definition: fast_matrix_view.hpp:744
void ensure_gpu_allocated() const
Ensures that the GPU memory is allocated and that the GPU memory is up to date (to undefined value)...
Definition: sub_view.hpp:717
void std_assign_evaluate(Expr &&expr, Result &&result)
Evaluation of the expr into result.
Definition: evaluator.hpp:1176
bool alias(const E &rhs) const noexcept
Test if this expression aliases with the given expression.
Definition: dyn_matrix_view.hpp:197
size_t dyn_nth_size(size_t i)
Returns the dth (dynamic) dimension from the variadic list D.
Definition: tmp.hpp:116
void assign_div_to(L &&lhs) const
Divide the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:244
const_memory_t< sub_type > const_memory_type
The const memory access type.
Definition: fast_matrix_view.hpp:37
value_t< sub_type > value_type
The value contained in the expression.
Definition: dyn_matrix_view.hpp:31
void assign_mul_to(L &&lhs) const
Multiply the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:235
static size_t dim([[maybe_unused]] const expr_t &v, size_t d)
Returns the dth dimension of the given expression.
Definition: fast_matrix_view.hpp:736
constexpr bool is_magic_view
Traits indicating if the given ETL type is a magic view expression.
Definition: traits.hpp:311
memory_t< sub_type > memory_type
The memory acess type.
Definition: fast_matrix_view.hpp:36
void assign_to(L &&lhs) const
Assign to the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:208
D D
The number of dimensions.
Definition: dyn_matrix_view.hpp:24
Base class and utilities for dyn matrix implementations.
View to represent a fast matrix in top of an expression.
Definition: fast_matrix_view.hpp:297
order
Storage order of a matrix.
Definition: order.hpp:15
constexpr size_t nth_size()
Traits to get the Sth dimension in Dims..
Definition: tmp.hpp:102
memory_t< sub_type > memory_type
The memory acess type.
Definition: fast_matrix_view.hpp:305
static constexpr size_t dim()
Returns the Dth dimension of an expression of this type.
Definition: fast_matrix_view.hpp:754
Definition: expr_fwd.hpp:77
bool is_cpu_up_to_date() const noexcept
Indicates if the CPU memory is up to date.
Definition: sub_view.hpp:777
std::conditional_t< std::is_lvalue_reference_v< S >, const value_t< T > &, value_t< T > > const_return_helper
Definition: traits.hpp:872
void gpu_copy_from([[maybe_unused]] const value_type *new_gpu_memory) const
Copy from GPU to GPU.
Definition: sub_view.hpp:761
std::decay_t< T > sub_expr_t
The sub expression type.
Definition: fast_matrix_view.hpp:693
value_type read_flat(size_t j) const noexcept(assert_nothrow)
Returns the value at the given index This function never has side effects.
Definition: fast_matrix_view.hpp:374
const_return_helper< sub_type, decltype(std::declval< sub_type >()[0])> const_return_type
The const type return by the view.
Definition: fast_matrix_view.hpp:39
void gpu_evict() const noexcept
Evict the expression from GPU.
Definition: sub_view.hpp:681
CRTP class to inject functions testing values of the expressions.
Definition: value_testable.hpp:26
typename sub_traits::value_type value_type
The value type.
Definition: fast_matrix_view.hpp:695
constexpr bool is_fast
Traits to test if the given ETL expresion type is fast (sizes known at compile-time) ...
Definition: traits.hpp:588
auto end() noexcept
Return an iterator to the past-the-end element of the matrix.
Definition: iterable.hpp:59
fast_matrix_view(sub_type sub)
Construct a new fast_matrix_view over the given sub expression.
Definition: fast_matrix_view.hpp:63
auto load(size_t x) const noexcept
Load several elements of the expression at once.
Definition: dyn_matrix_view.hpp:143
Traits to get information about ETL types.
Definition: tmp.hpp:68
typename V::template vec_type< value_type > vec_type
The vectorization type for V.
Definition: fast_matrix_view.hpp:314
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr size_t dimensions()
Returns the number of expressions for this type.
Definition: fast_matrix_view.hpp:762
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_return_type operator[](size_t j) const
Returns the element at the given index.
Definition: fast_matrix_view.hpp:350
void invalidate_gpu() const noexcept
Invalidates the GPU memory.
Definition: sub_view.hpp:695
return_type operator[](size_t j)
Returns the element at the given index.
Definition: fast_matrix_view.hpp:361
std::conditional_t< std::is_const_v< std::remove_reference_t< S > >, typename std::decay_t< S >::const_memory_type, typename std::decay_t< S >::memory_type > memory_t
Traits to extract the direct memory type out of an ETL type.
Definition: tmp.hpp:88
void store(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once.
Definition: dyn_matrix_view.hpp:176
void stream(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once, using non-temporal store.
Definition: dyn_matrix_view.hpp:165
const_memory_t< sub_type > const_memory_type
The const memory access type.
Definition: fast_matrix_view.hpp:306
std::ostream & operator<<(std::ostream &os, const etl::complex< T > &c)
Outputs a textual representation of the complex number in the given stream.
Definition: complex.hpp:576
value_type read_flat(size_t j) const noexcept
Returns the value at the given index This function never has side effects.
Definition: fast_matrix_view.hpp:89
typename std::decay_t< S >::const_memory_type const_memory_t
Traits to extract the direct const memory type out of an ETL type.
Definition: tmp.hpp:94
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: dyn_matrix_view.hpp:271
return_type operator[](size_t j)
Returns the element at the given index.
Definition: fast_matrix_view.hpp:79
Visitor to perform local evaluation when necessary.
Definition: eval_visitors.hpp:23
const_return_helper< sub_type, decltype(std::declval< sub_type >()[0])> const_return_type
The const type return by the view.
Definition: fast_matrix_view.hpp:308
void invalidate_cpu() const noexcept
Invalidates the CPU memory.
Definition: sub_view.hpp:688
void storeu(vec_type< V > in, size_t i) noexcept
Store several elements in the matrix at once.
Definition: dyn_matrix_view.hpp:187
void std_mod_evaluate(Expr &&expr, Result &&result)
Compound modulo evaluation of the expr into result.
Definition: evaluator.hpp:1271
const_return_type operator[](size_t j) const
Returns the element at the given index.
Definition: fast_matrix_view.hpp:70
auto begin() noexcept
Return an iterator to the first element of the matrix.
Definition: iterable.hpp:46
const_return_type operator()(size_t j) const
Access to the element at the given position.
Definition: dyn_matrix_view.hpp:89
T sub_type
The sub type.
Definition: fast_matrix_view.hpp:301
return_helper< sub_type, decltype(std::declval< sub_type >()[0])> return_type
The type returned by the view.
Definition: fast_matrix_view.hpp:307
void std_mul_evaluate(Expr &&expr, Result &&result)
Compound multiply evaluation of the expr into result.
Definition: evaluator.hpp:1233
auto loadu(size_t x) const noexcept
Load several elements of the expression at once.
Definition: dyn_matrix_view.hpp:154
Matrix with compile-time fixed dimensions.
Definition: fast.hpp:26
constexpr bool is_transformer
Traits indicating if the given ETL type is a transformer expression.
Definition: traits.hpp:297
void visit(detail::evaluator_visitor &visitor) const
Apply the given visitor to this expression and its descendants.
Definition: dyn_matrix_view.hpp:263
T sub_type
The sub type.
Definition: fast_matrix_view.hpp:31
requires(D > 0) struct dyn_base
Matrix with run-time fixed dimensions.
Definition: dyn_base.hpp:113
constexpr bool is_view
Traits indicating if the given ETL type is a view expression.
Definition: traits.hpp:304
bool is_gpu_up_to_date() const noexcept
Indicates if the GPU memory is up to date.
Definition: sub_view.hpp:785
void ensure_gpu_up_to_date() const
Copy back from the GPU to the expression memory if necessary.
Definition: dyn_matrix_view.hpp:280
return_helper< sub_type, decltype(std::declval< sub_type >()[0])> return_type
The type returned by the view.
Definition: fast_matrix_view.hpp:38
auto sub(E &&value, size_t i, size_t j, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p) -> sub_matrix_4d< detail::build_identity_type< E >, false >
Returns view representing a sub matrix view of the given expression.
Definition: view_expression_builder.hpp:100
static constexpr int complexity() noexcept
Estimate the complexity of computation.
Definition: fast_matrix_view.hpp:770
void validate_gpu() const noexcept
Validates the GPU memory.
Definition: sub_view.hpp:709
CRTP class to inject assign operations to matrix and vector structures.
Definition: assignable.hpp:25
void std_sub_evaluate(Expr &&expr, Result &&result)
Compound subtract evaluation of the expr into result.
Definition: evaluator.hpp:1214
void assign_mod_to(L &&lhs) const
Modulo the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:253
fast_matrix_view(sub_type sub)
Construct a new fast_matrix_view over the given sub expression.
Definition: fast_matrix_view.hpp:334
constexpr bool is_thread_safe
Traits to test if the given ETL expresion type is thread safe.
Definition: traits.hpp:687
typename V::template vec_type< value_type > vec_type
The vectorization type for V.
Definition: fast_matrix_view.hpp:45
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
void validate_cpu() const noexcept
Validates the CPU memory.
Definition: sub_view.hpp:702
value_type * gpu_memory() const noexcept
Return GPU memory of this expression, if any.
Definition: sub_view.hpp:674
value_t< sub_type > value_type
The value contained in the expression.
Definition: fast_matrix_view.hpp:302
void std_add_evaluate(Expr &&expr, Result &&result)
Compound add evaluation of the expr into result.
Definition: evaluator.hpp:1195
value_t< sub_type > value_type
The value contained in the expression.
Definition: fast_matrix_view.hpp:33
void assign_sub_to(L &&lhs) const
Sub from the given left-hand-side expression.
Definition: dyn_matrix_view.hpp:226