18 constexpr
size_t dimensions([[maybe_unused]]
const E& expr) noexcept {
28 constexpr
size_t dimensions() noexcept {
38 constexpr
int complexity([[maybe_unused]]
const E& expr) noexcept {
58 size_t rows(
const E& expr) {
67 template <fast_expr E>
68 constexpr
size_t rows(
const E& expr) noexcept {
77 template <dyn_matrix_c E>
87 template <fast_matrix_c E>
88 constexpr
size_t columns(
const E& expr) noexcept {
98 size_t size(
const E& expr) {
107 template <fast_expr E>
108 constexpr
size_t size(
const E& expr) noexcept {
117 template <dyn_matrix_c E>
127 template <fast_matrix_c E>
128 constexpr
size_t subsize(
const E& expr) noexcept {
138 template <
size_t D, dyn_expr E>
139 size_t dim(
const E& e) noexcept {
149 template <etl_expr E>
150 size_t dim(
const E& e,
size_t d) noexcept {
160 template <
size_t D, fast_expr E>
161 constexpr
size_t dim(
const E& e) noexcept {
169 template <
size_t D, fast_expr E>
170 constexpr
size_t dim() noexcept {
177 template <
typename E>
183 template <
typename E>
185 struct safe_dimensions_impl<E> : std::integral_constant<size_t, std::numeric_limits<size_t>::max()> {};
190 template <
typename E>
192 struct safe_dimensions_impl<E> : std::integral_constant<size_t, etl_traits<E>::dimensions()> {};
197 template <
typename E,
typename Enable =
void>
206 template <
typename E>
207 constexpr std::pair<size_t, size_t>
index_to_2d(E&& sub,
size_t i) {
209 : std::make_pair(i % dim<0>(sub), i / dim<0>(sub));
263 template <
typename P1,
typename P2>
264 bool memory_alias(
const P1* a_begin,
const P1* a_end,
const P2* b_begin,
const P2* b_end) {
265 cpp_assert(a_begin <= a_end,
"memory_alias works on ordered ranges");
266 cpp_assert(b_begin <= b_end,
"memory_alias works on ordered ranges");
268 return reinterpret_cast<uintptr_t
>(a_begin) < reinterpret_cast<uintptr_t>(b_end)
269 &&
reinterpret_cast<uintptr_t
>(a_end) > reinterpret_cast<uintptr_t>(b_begin);
277 template <
typename E>
279 expr.ensure_cpu_up_to_date();
288 template <
typename E>
290 if constexpr (is_dma<E>) {
291 return expr.is_cpu_up_to_date();
303 template <
typename E>
305 if constexpr (is_dma<E>) {
306 return expr.is_gpu_up_to_date();
322 template <
typename E>
324 if constexpr (is_temporary_expr<E>) {
342 template <
typename E>
344 if constexpr (is_temporary_expr<E>) {
345 if constexpr (E::gpu_computable) {
367 template <
typename E,
typename Y>
369 if constexpr (is_temporary_expr<E>) {
370 if constexpr (E::gpu_computable) {
374 t.ensure_gpu_up_to_date();
378 return expr.gpu_compute_hint(y);
396 template <
typename X,
typename Y>
398 if constexpr (is_temporary_expr<X>) {
399 if constexpr (X::gpu_computable) {
403 t.ensure_gpu_up_to_date();
408 if constexpr (is_dma<X>) {
409 x.ensure_gpu_up_to_date();
410 y.ensure_gpu_allocated();
411 y.gpu_copy_from(x.gpu_memory());
414 return x.gpu_compute(y);
433 template <
typename X,
typename Y>
435 if constexpr (should_gpu_compute_direct<X>) {
447 template <
typename T>
448 constexpr
size_t gpu_inc = is_scalar<T> ? 0 : 1;
constexpr int complexity([[maybe_unused]] const E &expr) noexcept
Return the complexity of the expression.
Definition: helpers.hpp:38
Utility to get the dimensions of an expressions, with support for generator.
Definition: helpers.hpp:178
bool safe_is_gpu_up_to_date(E &&expr)
Indicates if the GPU memory is up to date. If the expression does not have direct memory access...
Definition: helpers.hpp:304
D D
The number of dimensions.
Definition: dyn_matrix_view.hpp:24
decltype(auto) select_smart_gpu_compute(X &x, Y &y)
Compute the expression into a representation that is GPU up to date and possibly store this represent...
Definition: helpers.hpp:434
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr size_t dimensions()
Return the number of dimensions of the expression.
Definition: traits_base.hpp:31
bool memory_alias(const P1 *a_begin, const P1 *a_end, const P2 *b_begin, const P2 *b_end)
Test if two memory ranges overlap.
Definition: helpers.hpp:264
size_t minor_stride(E &&expr)
Returns the minor stride of the given ETL matrix expression.
Definition: helpers.hpp:238
size_t major_stride(E &&expr)
Returns the major stride of the given ETL matrix expression.
Definition: helpers.hpp:248
auto dim(E &&value, size_t i) -> detail::identity_helper< E, dim_view< detail::build_identity_type< E >, D >>
Return a view representing the ith Dth dimension.
Definition: view_expression_builder.hpp:25
size_t columns(const E &expr)
Returns the number of columns of the given ETL expression.
Definition: helpers.hpp:78
decltype(auto) smart_forward_gpu(E &expr)
Smart forwarding for a temporary expression that will be computed in GPU.
Definition: helpers.hpp:343
void safe_ensure_cpu_up_to_date(E &&expr)
Ensure that the CPU is up to date.
Definition: helpers.hpp:278
constexpr std::pair< size_t, size_t > index_to_2d(E &&sub, size_t i)
Convert a flat index into a 2D index.
Definition: helpers.hpp:207
requires(D > 0) struct dyn_base
Matrix with run-time fixed dimensions.
Definition: dyn_base.hpp:113
constexpr size_t gpu_inc
The space between two elements in GPU for the given type.
Definition: helpers.hpp:448
size_t col_stride(E &&expr)
Returns the column stride of the given ETL matrix expression.
Definition: helpers.hpp:228
decltype(auto) smart_forward(E &expr)
Smart forwarding for a temporary expression.
Definition: helpers.hpp:323
decltype(auto) force_temporary_gpu(E &&expr)
Force a temporary out of the expression.
Definition: temporary.hpp:196
decltype(auto) force_temporary(E &&expr)
Force a temporary out of the expression.
Definition: temporary.hpp:91
size_t row_stride(E &&expr)
Returns the row stride of the given ETL matrix expression.
Definition: helpers.hpp:218
size_t rows(const E &expr)
Returns the number of rows of the given ETL expression.
Definition: helpers.hpp:58
decltype(auto) smart_gpu_compute_hint(E &expr, Y &y)
Compute the expression into a representation that is GPU up to date.
Definition: helpers.hpp:368
decltype(auto) smart_gpu_compute(X &x, Y &y)
Compute the expression into a representation that is GPU up to date and store this representation in ...
Definition: helpers.hpp:397
decltype(auto) make_temporary(E &&expr)
Make a temporary out of the expression if necessary.
Definition: temporary.hpp:173
bool safe_is_cpu_up_to_date(E &&expr)
Indicates if the CPU memory is up to date. If the expression does not have direct memory access...
Definition: helpers.hpp:289
size_t subsize(const E &expr)
Returns the sub-size of the given ETL expression, i.e. the size not considering the first dimension...
Definition: helpers.hpp:118
constexpr size_t safe_dimensions
Utility to get the dimensions of an expressions, with support for generator.
Definition: helpers.hpp:198