Expression Templates Library (ETL)
apxdbpy.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_SAPXDBPY
26 static constexpr bool has_sapxdbpy = true;
27 #else
28 static constexpr bool has_sapxdbpy = false;
29 #endif
30 
40 inline void apxdbpy([[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_SAPXDBPY
48  inc_counter("egblas");
49  egblas_sapxdbpy(n, alpha, A, lda, beta, B, ldb);
50 #else
51  cpp_unreachable("Invalid call to egblas::apxdbpy");
52 #endif
53 }
54 
55 #ifdef EGBLAS_HAS_DAPXDBPY
56 static constexpr bool has_dapxdbpy = true;
57 #else
58 static constexpr bool has_dapxdbpy = false;
59 #endif
60 
70 inline void apxdbpy([[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_DAPXDBPY
78  inc_counter("egblas");
79  egblas_dapxdbpy(n, alpha, A, lda, beta, B, ldb);
80 #else
81  cpp_unreachable("Invalid call to egblas::apxdbpy");
82 #endif
83 }
84 
85 #ifdef EGBLAS_HAS_CAPXDBPY
86 static constexpr bool has_capxdbpy = true;
87 #else
88 static constexpr bool has_capxdbpy = false;
89 #endif
90 
100 inline void apxdbpy([[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_CAPXDBPY
108  inc_counter("egblas");
109  egblas_capxdbpy(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::apxdbpy");
112 #endif
113 }
114 
124 inline void apxdbpy([[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_CAPXDBPY
132  inc_counter("egblas");
133  egblas_capxdbpy(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::apxdbpy");
136 #endif
137 }
138 
139 #ifdef EGBLAS_HAS_ZAPXDBPY
140 static constexpr bool has_zapxdbpy = true;
141 #else
142 static constexpr bool has_zapxdbpy = false;
143 #endif
144 
154 inline void apxdbpy([[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_ZAPXDBPY
162  inc_counter("egblas");
163  egblas_zapxdbpy(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::apxdbpy");
166 #endif
167 }
168 
178 inline void apxdbpy([[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_ZAPXDBPY
186  inc_counter("egblas");
187  egblas_zapxdbpy(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::apxdbpy");
190 #endif
191 }
192 
193 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
void apxdbpy([[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 apxdbpy operation.
Definition: apxdbpy.hpp:40
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25