Expression Templates Library (ETL)
axmy_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_SAXMY_3
26 static constexpr bool has_saxmy_3 = true;
27 #else
28 static constexpr bool has_saxmy_3 = false;
29 #endif
30 
40 inline void axmy_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* B,
45  [[maybe_unused]] size_t ldb,
46  [[maybe_unused]] float* C,
47  [[maybe_unused]] size_t ldc) {
48 #ifdef EGBLAS_HAS_SAXMY_3
49  inc_counter("egblas");
50  egblas_saxmy_3(n, alpha, A, lda, B, ldb, C, ldc);
51 #else
52  cpp_unreachable("Invalid call to egblas::axmy_3");
53 #endif
54 }
55 
56 #ifdef EGBLAS_HAS_DAXMY_3
57 static constexpr bool has_daxmy_3 = true;
58 #else
59 static constexpr bool has_daxmy_3 = false;
60 #endif
61 
71 inline void axmy_3([[maybe_unused]] size_t n,
72  [[maybe_unused]] double alpha,
73  [[maybe_unused]] double* A,
74  [[maybe_unused]] size_t lda,
75  [[maybe_unused]] double* B,
76  [[maybe_unused]] size_t ldb,
77  [[maybe_unused]] double* C,
78  [[maybe_unused]] size_t ldc) {
79 #ifdef EGBLAS_HAS_DAXMY_3
80  inc_counter("egblas");
81  egblas_daxmy_3(n, alpha, A, lda, B, ldb, C, ldc);
82 #else
83  cpp_unreachable("Invalid call to egblas::axmy_3");
84 #endif
85 }
86 
87 #ifdef EGBLAS_HAS_CAXMY_3
88 static constexpr bool has_caxmy_3 = true;
89 #else
90 static constexpr bool has_caxmy_3 = false;
91 #endif
92 
102 inline void axmy_3([[maybe_unused]] size_t n,
103  [[maybe_unused]] std::complex<float> alpha,
104  [[maybe_unused]] std::complex<float>* A,
105  [[maybe_unused]] size_t lda,
106  [[maybe_unused]] std::complex<float>* B,
107  [[maybe_unused]] size_t ldb,
108  [[maybe_unused]] std::complex<float>* C,
109  [[maybe_unused]] size_t ldc) {
110 #ifdef EGBLAS_HAS_CAXMY_3
111  inc_counter("egblas");
112  egblas_caxmy_3(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb, reinterpret_cast<cuComplex*>(C), ldc);
113 #else
114  cpp_unreachable("Invalid call to egblas::axmy_3");
115 #endif
116 }
117 
127 inline void axmy_3([[maybe_unused]] size_t n,
128  [[maybe_unused]] etl::complex<float> alpha,
129  [[maybe_unused]] etl::complex<float>* A,
130  [[maybe_unused]] size_t lda,
131  [[maybe_unused]] etl::complex<float>* B,
132  [[maybe_unused]] size_t ldb,
133  [[maybe_unused]] etl::complex<float>* C,
134  [[maybe_unused]] size_t ldc) {
135 #ifdef EGBLAS_HAS_CAXMY_3
136  inc_counter("egblas");
137  egblas_caxmy_3(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb, reinterpret_cast<cuComplex*>(C), ldc);
138 #else
139  cpp_unreachable("Invalid call to egblas::axmy_3");
140 #endif
141 }
142 
143 #ifdef EGBLAS_HAS_ZAXMY_3
144 static constexpr bool has_zaxmy_3 = true;
145 #else
146 static constexpr bool has_zaxmy_3 = false;
147 #endif
148 
158 inline void axmy_3([[maybe_unused]] size_t n,
159  [[maybe_unused]] std::complex<double> alpha,
160  [[maybe_unused]] std::complex<double>* A,
161  [[maybe_unused]] size_t lda,
162  [[maybe_unused]] std::complex<double>* B,
163  [[maybe_unused]] size_t ldb,
164  [[maybe_unused]] std::complex<double>* C,
165  [[maybe_unused]] size_t ldc) {
166 #ifdef EGBLAS_HAS_ZAXMY_3
167  inc_counter("egblas");
168  egblas_zaxmy_3(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb,
169  reinterpret_cast<cuDoubleComplex*>(C), ldc);
170 #else
171  cpp_unreachable("Invalid call to egblas::axmy_3");
172 #endif
173 }
174 
184 inline void axmy_3([[maybe_unused]] size_t n,
185  [[maybe_unused]] etl::complex<double> alpha,
186  [[maybe_unused]] etl::complex<double>* A,
187  [[maybe_unused]] size_t lda,
188  [[maybe_unused]] etl::complex<double>* B,
189  [[maybe_unused]] size_t ldb,
190  [[maybe_unused]] etl::complex<double>* C,
191  [[maybe_unused]] size_t ldc) {
192 #ifdef EGBLAS_HAS_ZAXMY_3
193  inc_counter("egblas");
194  egblas_zaxmy_3(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb,
195  reinterpret_cast<cuDoubleComplex*>(C), ldc);
196 #else
197  cpp_unreachable("Invalid call to egblas::axmy_3");
198 #endif
199 }
200 
201 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
void axmy_3([[maybe_unused]] size_t n, [[maybe_unused]] float alpha, [[maybe_unused]] float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb, [[maybe_unused]] float *C, [[maybe_unused]] size_t ldc)
Wrappers for single-precision egblas axmy_3 operation.
Definition: axmy_3.hpp:40
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25