Expression Templates Library (ETL)
shuffle.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 
13 #pragma once
14 
15 #ifdef ETL_EGBLAS_MODE
16 
17 #include "etl/impl/cublas/cuda.hpp"
18 
19 #include <egblas.hpp>
20 
21 #endif
22 
23 namespace etl::impl::egblas {
24 
28 #ifdef EGBLAS_HAS_SHUFFLE
29 static constexpr bool has_shuffle = true;
30 #else
31 static constexpr bool has_shuffle = false;
32 #endif
33 
40 inline void shuffle([[maybe_unused]] size_t n, [[maybe_unused]] void* x, [[maybe_unused]] size_t incx) {
41 #ifdef EGBLAS_HAS_SHUFFLE
42  inc_counter("egblas");
43  egblas_shuffle(n, x, incx);
44 #else
45  cpp_unreachable("Invalid call to egblas::shuffle");
46 #endif
47 }
48 
52 #ifdef EGBLAS_HAS_SHUFFLE_SEED
53 static constexpr bool has_shuffle_seed = true;
54 #else
55 static constexpr bool has_shuffle_seed = false;
56 #endif
57 
65 inline void shuffle_seed([[maybe_unused]] size_t n, [[maybe_unused]] void* x, [[maybe_unused]] size_t incx, [[maybe_unused]] size_t seed) {
66 #ifdef EGBLAS_HAS_SHUFFLE_SEED
67  inc_counter("egblas");
68  egblas_shuffle_seed(n, x, incx, seed);
69 #else
70  cpp_unreachable("Invalid call to egblas::shuffle_seed");
71 #endif
72 }
73 
77 #ifdef EGBLAS_HAS_PAR_SHUFFLE
78 static constexpr bool has_par_shuffle = true;
79 #else
80 static constexpr bool has_par_shuffle = false;
81 #endif
82 
91 inline void par_shuffle(
92  [[maybe_unused]] size_t n, [[maybe_unused]] void* x, [[maybe_unused]] size_t incx, [[maybe_unused]] void* y, [[maybe_unused]] size_t incy) {
93 #ifdef EGBLAS_HAS_PAR_SHUFFLE
94  inc_counter("egblas");
95  egblas_par_shuffle(n, x, incx, y, incy);
96 #else
97  cpp_unreachable("Invalid call to egblas::par_shuffle");
98 #endif
99 }
100 
104 #ifdef EGBLAS_HAS_PAR_SHUFFLE_SEED
105 static constexpr bool has_par_shuffle_seed = true;
106 #else
107 static constexpr bool has_par_shuffle_seed = false;
108 #endif
109 
119 inline void par_shuffle_seed([[maybe_unused]] size_t n,
120  [[maybe_unused]] void* x,
121  [[maybe_unused]] size_t incx,
122  [[maybe_unused]] void* y,
123  [[maybe_unused]] size_t incy,
124  [[maybe_unused]] size_t seed) {
125 #ifdef EGBLAS_HAS_PAR_SHUFFLE_SEED
126  inc_counter("egblas");
127  egblas_par_shuffle_seed(n, x, incx, y, incy, seed);
128 #else
129  cpp_unreachable("Invalid call to egblas::par_shuffle");
130 #endif
131 }
132 
133 } //end of namespace etl::impl::egblas
void par_shuffle_seed([[maybe_unused]] size_t n, [[maybe_unused]] void *x, [[maybe_unused]] size_t incx, [[maybe_unused]] void *y, [[maybe_unused]] size_t incy, [[maybe_unused]] size_t seed)
Wrappers for egblas par_shuffle_seed operation.
Definition: shuffle.hpp:119
void shuffle(T &vector)
Shuffle all the elements of an ETL vector.
Definition: globals.hpp:480
Definition: abs.hpp:23
void shuffle_seed([[maybe_unused]] size_t n, [[maybe_unused]] void *x, [[maybe_unused]] size_t incx, [[maybe_unused]] size_t seed)
Wrappers for egblas shuffle_seed operation.
Definition: shuffle.hpp:65
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25
void par_shuffle([[maybe_unused]] size_t n, [[maybe_unused]] void *x, [[maybe_unused]] size_t incx, [[maybe_unused]] void *y, [[maybe_unused]] size_t incy)
Wrappers for egblas par_shuffle operation.
Definition: shuffle.hpp:91