Expression Templates Library (ETL)
apxdby.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_SAPXDBY
26 static constexpr bool has_sapxdby = true;
27 #else
28 static constexpr bool has_sapxdby = false;
29 #endif
30 
40 inline void apxdby([[maybe_unused]] size_t n,
41  [[maybe_unused]] float alpha,
42  [[maybe_unused]] float* A,
43  [[maybe_unused]] size_t lda,
44  [[maybe_unused]] float beta,
45  [[maybe_unused]] float* B,
46  [[maybe_unused]] size_t ldb) {
47 #ifdef EGBLAS_HAS_SAPXDBY
48  inc_counter("egblas");
49  egblas_sapxdby(n, alpha, A, lda, beta, B, ldb);
50 #else
51  cpp_unreachable("Invalid call to egblas::apxdby");
52 #endif
53 }
54 
55 #ifdef EGBLAS_HAS_DAPXDBY
56 static constexpr bool has_dapxdby = true;
57 #else
58 static constexpr bool has_dapxdby = false;
59 #endif
60 
70 inline void apxdby([[maybe_unused]] size_t n,
71  [[maybe_unused]] double alpha,
72  [[maybe_unused]] double* A,
73  [[maybe_unused]] size_t lda,
74  [[maybe_unused]] double beta,
75  [[maybe_unused]] double* B,
76  [[maybe_unused]] size_t ldb) {
77 #ifdef EGBLAS_HAS_DAPXDBY
78  inc_counter("egblas");
79  egblas_dapxdby(n, alpha, A, lda, beta, B, ldb);
80 #else
81  cpp_unreachable("Invalid call to egblas::apxdby");
82 #endif
83 }
84 
85 #ifdef EGBLAS_HAS_CAPXDBY
86 static constexpr bool has_capxdby = true;
87 #else
88 static constexpr bool has_capxdby = false;
89 #endif
90 
100 inline void apxdby([[maybe_unused]] size_t n,
101  [[maybe_unused]] std::complex<float> alpha,
102  [[maybe_unused]] std::complex<float>* A,
103  [[maybe_unused]] size_t lda,
104  [[maybe_unused]] std::complex<float> beta,
105  [[maybe_unused]] std::complex<float>* B,
106  [[maybe_unused]] size_t ldb) {
107 #ifdef EGBLAS_HAS_CAPXDBY
108  inc_counter("egblas");
109  egblas_capxdby(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuComplex*>(B), ldb);
110 #else
111  cpp_unreachable("Invalid call to egblas::apxdby");
112 #endif
113 }
114 
124 inline void apxdby([[maybe_unused]] size_t n,
125  [[maybe_unused]] etl::complex<float> alpha,
126  [[maybe_unused]] etl::complex<float>* A,
127  [[maybe_unused]] size_t lda,
128  [[maybe_unused]] std::complex<float> beta,
129  [[maybe_unused]] etl::complex<float>* B,
130  [[maybe_unused]] size_t ldb) {
131 #ifdef EGBLAS_HAS_CAPXDBY
132  inc_counter("egblas");
133  egblas_capxdby(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuComplex*>(B), ldb);
134 #else
135  cpp_unreachable("Invalid call to egblas::apxdby");
136 #endif
137 }
138 
139 #ifdef EGBLAS_HAS_ZAPXDBY
140 static constexpr bool has_zapxdby = true;
141 #else
142 static constexpr bool has_zapxdby = false;
143 #endif
144 
154 inline void apxdby([[maybe_unused]] size_t n,
155  [[maybe_unused]] std::complex<double> alpha,
156  [[maybe_unused]] std::complex<double>* A,
157  [[maybe_unused]] size_t lda,
158  [[maybe_unused]] std::complex<double> beta,
159  [[maybe_unused]] std::complex<double>* B,
160  [[maybe_unused]] size_t ldb) {
161 #ifdef EGBLAS_HAS_ZAPXDBY
162  inc_counter("egblas");
163  egblas_zapxdby(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuDoubleComplex*>(B), ldb);
164 #else
165  cpp_unreachable("Invalid call to egblas::apxdby");
166 #endif
167 }
168 
178 inline void apxdby([[maybe_unused]] size_t n,
179  [[maybe_unused]] etl::complex<double> alpha,
180  [[maybe_unused]] etl::complex<double>* A,
181  [[maybe_unused]] size_t lda,
182  [[maybe_unused]] std::complex<double> beta,
183  [[maybe_unused]] etl::complex<double>* B,
184  [[maybe_unused]] size_t ldb) {
185 #ifdef EGBLAS_HAS_ZAPXDBY
186  inc_counter("egblas");
187  egblas_zapxdby(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuDoubleComplex*>(B), ldb);
188 #else
189  cpp_unreachable("Invalid call to egblas::apxdby");
190 #endif
191 }
192 
193 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
void apxdby([[maybe_unused]] size_t n, [[maybe_unused]] float alpha, [[maybe_unused]] float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float beta, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb)
Wrappers for single-precision egblas apxdby operation.
Definition: apxdby.hpp:40
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25