Expression Templates Library (ETL)
apxdby_3.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_3
26 static constexpr bool has_sapxdby_3 = true;
27 #else
28 static constexpr bool has_sapxdby_3 = false;
29 #endif
30 
40 inline void apxdby_3([[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  [[maybe_unused]] float* C,
48  [[maybe_unused]] size_t ldc) {
49 #ifdef EGBLAS_HAS_SAPXDBY_3
50  inc_counter("egblas");
51  egblas_sapxdby_3(n, alpha, A, lda, beta, B, ldb, C, ldc);
52 #else
53  cpp_unreachable("Invalid call to egblas::apxdby_3");
54 #endif
55 }
56 
57 #ifdef EGBLAS_HAS_DAPXDBY_3
58 static constexpr bool has_dapxdby_3 = true;
59 #else
60 static constexpr bool has_dapxdby_3 = false;
61 #endif
62 
72 inline void apxdby_3([[maybe_unused]] size_t n,
73  [[maybe_unused]] double alpha,
74  [[maybe_unused]] double* A,
75  [[maybe_unused]] size_t lda,
76  [[maybe_unused]] double beta,
77  [[maybe_unused]] double* B,
78  [[maybe_unused]] size_t ldb,
79  [[maybe_unused]] double* C,
80  [[maybe_unused]] size_t ldc) {
81 #ifdef EGBLAS_HAS_DAPXDBY_3
82  inc_counter("egblas");
83  egblas_dapxdby_3(n, alpha, A, lda, beta, B, ldb, C, ldc);
84 #else
85  cpp_unreachable("Invalid call to egblas::apxdby_3");
86 #endif
87 }
88 
89 #ifdef EGBLAS_HAS_CAPXDBY_3
90 static constexpr bool has_capxdby_3 = true;
91 #else
92 static constexpr bool has_capxdby_3 = false;
93 #endif
94 
104 inline void apxdby_3([[maybe_unused]] size_t n,
105  [[maybe_unused]] std::complex<float> alpha,
106  [[maybe_unused]] std::complex<float>* A,
107  [[maybe_unused]] size_t lda,
108  [[maybe_unused]] std::complex<float> beta,
109  [[maybe_unused]] std::complex<float>* B,
110  [[maybe_unused]] size_t ldb,
111  [[maybe_unused]] std::complex<float>* C,
112  [[maybe_unused]] size_t ldc) {
113 #ifdef EGBLAS_HAS_CAPXDBY_3
114  inc_counter("egblas");
115  egblas_capxdby_3(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuComplex*>(B), ldb,
116  reinterpret_cast<cuComplex*>(C), ldc);
117 #else
118  cpp_unreachable("Invalid call to egblas::apxdby_3");
119 #endif
120 }
121 
131 inline void apxdby_3([[maybe_unused]] size_t n,
132  [[maybe_unused]] etl::complex<float> alpha,
133  [[maybe_unused]] etl::complex<float>* A,
134  [[maybe_unused]] size_t lda,
135  [[maybe_unused]] etl::complex<float> beta,
136  [[maybe_unused]] etl::complex<float>* B,
137  [[maybe_unused]] size_t ldb,
138  [[maybe_unused]] etl::complex<float>* C,
139  [[maybe_unused]] size_t ldc) {
140 #ifdef EGBLAS_HAS_CAPXDBY_3
141  inc_counter("egblas");
142  egblas_capxdby_3(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuComplex*>(B), ldb,
143  reinterpret_cast<cuComplex*>(C), ldc);
144 #else
145  cpp_unreachable("Invalid call to egblas::apxdby");
146 #endif
147 }
148 
149 #ifdef EGBLAS_HAS_ZAPXDBY_3
150 static constexpr bool has_zapxdby_3 = true;
151 #else
152 static constexpr bool has_zapxdby_3 = false;
153 #endif
154 
164 inline void apxdby_3([[maybe_unused]] size_t n,
165  [[maybe_unused]] std::complex<double> alpha,
166  [[maybe_unused]] std::complex<double>* A,
167  [[maybe_unused]] size_t lda,
168  [[maybe_unused]] std::complex<double> beta,
169  [[maybe_unused]] std::complex<double>* B,
170  [[maybe_unused]] size_t ldb,
171  [[maybe_unused]] std::complex<double>* C,
172  [[maybe_unused]] size_t ldc) {
173 #ifdef EGBLAS_HAS_ZAPXDBY_3
174  inc_counter("egblas");
175  egblas_zapxdby_3(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuDoubleComplex*>(B), ldb,
176  reinterpret_cast<cuDoubleComplex*>(C), ldc);
177 #else
178  cpp_unreachable("Invalid call to egblas::apxdby_3");
179 #endif
180 }
181 
191 inline void apxdby_3([[maybe_unused]] size_t n,
192  [[maybe_unused]] etl::complex<double> alpha,
193  [[maybe_unused]] etl::complex<double>* A,
194  [[maybe_unused]] size_t lda,
195  [[maybe_unused]] etl::complex<double> beta,
196  [[maybe_unused]] etl::complex<double>* B,
197  [[maybe_unused]] size_t ldb,
198  [[maybe_unused]] etl::complex<double>* C,
199  [[maybe_unused]] size_t ldc) {
200 #ifdef EGBLAS_HAS_ZAPXDBY_3
201  inc_counter("egblas");
202  egblas_zapxdby_3(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, complex_cast(beta), reinterpret_cast<cuDoubleComplex*>(B), ldb,
203  reinterpret_cast<cuDoubleComplex*>(C), ldc);
204 #else
205  cpp_unreachable("Invalid call to egblas::apxdby_3");
206 #endif
207 }
208 
209 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
void apxdby_3([[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, [[maybe_unused]] float *C, [[maybe_unused]] size_t ldc)
Wrappers for single-precision egblas apxdby operation.
Definition: apxdby_3.hpp:40
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25