Expression Templates Library (ETL)
scalar_set.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 
25 #ifdef EGBLAS_HAS_SCALAR_SSET
26 
27 static constexpr bool has_scalar_sset = true;
28 
36 inline void scalar_set(float* x, size_t n, size_t s, const float beta) {
37  inc_counter("egblas");
38  egblas_scalar_sset(x, n, s, beta);
39 }
40 
41 #else
42 
43 static constexpr bool has_scalar_sset = false;
44 
45 #endif
46 
47 #ifdef EGBLAS_HAS_SCALAR_DSET
48 
49 static constexpr bool has_scalar_dset = true;
50 
58 inline void scalar_set(double* x, size_t n, size_t s, const double beta) {
59  inc_counter("egblas");
60  egblas_scalar_dset(x, n, s, beta);
61 }
62 
63 #else
64 
65 static constexpr bool has_scalar_dset = false;
66 
67 #endif
68 
69 #ifndef ETL_EGBLAS_MODE
70 
78 template <typename T>
79 inline void scalar_set([[maybe_unused]] T* x, [[maybe_unused]] size_t n, [[maybe_unused]] size_t s, [[maybe_unused]] const T beta) {
80  cpp_unreachable("Invalid call to egblas::scalar_set");
81 }
82 
83 #endif
84 
85 } //end of namespace etl::impl::egblas
auto s(T &&value)
Force the evaluation of the given expression.
Definition: stop.hpp:18
void scalar_set([[maybe_unused]] T *x, [[maybe_unused]] size_t n, [[maybe_unused]] size_t s, [[maybe_unused]] const T beta)
sets the scalar beta to each element of the single-precision vector x
Definition: scalar_set.hpp:79
Definition: abs.hpp:23
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25