Expression Templates Library (ETL)
value_fwd.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
14 #pragma once
15 
16 #include <cstddef>
17 #include <span>
18 
19 #include "cpp_utils/array_wrapper.hpp"
20 
21 #if __cpp_aligned_new >= 201606
22 #include "cpp_utils/soft_aligned_array.hpp"
23 #else
24 #include "cpp_utils/aligned_array.hpp"
25 #endif
26 
28 
29 namespace etl {
30 
38 template <typename T>
39 static constexpr size_t alloc_size_vec(size_t size) {
40  return padding
42  : size;
43 }
44 
45 #ifdef ETL_ADVANCED_PADDING
46 
54 template <typename T>
55 static constexpr size_t alloc_size_mat(size_t size, size_t last) {
56  return size == 0 ? 0
57  : (padding ? (size / last)
58  * (last
60  ? 0
62  : size);
63 }
64 
65 #else
66 
74 template <typename T>
75 static constexpr size_t alloc_size_mat(size_t size, size_t last) {
76  return (void)last, (size == 0 ? 0 : alloc_size_vec<T>(size));
77 }
78 
79 #endif
80 
87 template <typename T, size_t... Dims>
88 static constexpr size_t alloc_size_mat() {
89  return alloc_size_mat<T>((Dims * ...), nth_size<sizeof...(Dims) - 1, 0, Dims...>());
90 }
91 
92 template <typename T, typename ST, order SO, size_t... Dims>
93 struct fast_matrix_impl;
94 
95 template <typename T, typename ST, order SO, size_t... Dims>
96 struct custom_fast_matrix_impl;
97 
98 template <typename T, order SO, size_t D = 2>
99 struct dyn_matrix_impl;
100 
101 template <typename T, order SO, size_t D = 2>
102 struct gpu_dyn_matrix_impl;
103 
104 template <typename T, order SO, size_t D = 2>
105 struct custom_dyn_matrix_impl;
106 
107 template <typename T, sparse_storage SS, size_t D>
108 struct sparse_matrix_impl;
109 
110 template <typename Stream>
111 struct serializer;
112 
113 template <typename Stream>
114 struct deserializer;
115 
116 /*
117  * In C++17, aligned dynamic allocation of over-aligned type is now supported,
118  * so we use the soft_aligned_array.
119  *
120  * When this is not possible, we use the version with internal padding, but this
121  * has a big data overhead.
122  */
123 
124 #if __cpp_aligned_new >= 201606
125 template <typename T, std::size_t S, std::size_t A>
126 using aligned_array = cpp::soft_aligned_array<T, S, A>;
127 #else
128 template <typename T, std::size_t S, std::size_t A>
129 using aligned_array = cpp::aligned_array<T, S, A>;
130 #endif
131 
135 template <typename T, size_t... Dims>
136 using fast_matrix = fast_matrix_impl<T, aligned_array<T, alloc_size_mat<T, Dims...>(), default_intrinsic_traits<T>::alignment>, order::RowMajor, Dims...>;
137 
141 template <typename T, size_t... Dims>
142 using fast_matrix_cm = fast_matrix_impl<T, aligned_array<T, alloc_size_mat<T, Dims...>(), default_intrinsic_traits<T>::alignment>, order::ColumnMajor, Dims...>;
143 
147 template <typename T, size_t Rows>
149 
153 template <typename T, size_t Rows>
155 
159 template <typename T, size_t Rows>
161 
165 template <typename T, size_t... Dims>
167 
171 template <typename T, order SO, size_t... Dims>
173 
177 template <typename T, size_t D = 2>
179 
183 template <typename T, size_t D = 2>
185 
189 template <typename T, order SO, size_t D = 2>
191 
195 template <typename T>
197 
201 template <typename T>
203 
207 template <typename T, size_t D = 2>
209 
213 template <typename T, size_t D = 2>
215 
219 template <typename T, size_t D = 2>
221 
225 template <typename T>
227 
231 template <typename T, size_t Rows>
233 
237 template <typename T, size_t... Dims>
239 
243 template <typename T, size_t D = 2>
245 
246 } //end of namespace etl
constexpr bool padding
Indicates if ETL is allowed to pad matrices and vectors.
Definition: config.hpp:135
Define traits to get vectorization information for types when no vector mode is available.
Definition: no_vectorization.hpp:16
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
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr size_t size
Numbers of elements done at once.
Definition: no_vectorization.hpp:18
Matrix with run-time fixed dimensions.
Definition: dyn.hpp:26
Matrix with compile-time fixed dimensions.
Definition: fast.hpp:26
Column-Major storage.
Matrix with run-time fixed dimensions.
Definition: custom_dyn.hpp:27
Matrix with compile-time fixed dimensions.
Definition: custom_fast.hpp:27
Sparse matrix implementation.
Definition: sparse.hpp:211
GPU special Matrix with run-time fixed dimensions.
Definition: gpu_dyn.hpp:25
Row-Major storage.