Expression Templates Library (ETL)
axdy.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_SAXDY
26 static constexpr bool has_saxdy = true;
27 #else
28 static constexpr bool has_saxdy = false;
29 #endif
30 
40 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] float alpha, [[maybe_unused]] const float* A, [[maybe_unused]] size_t lda, [[maybe_unused]] float* B, [[maybe_unused]] size_t ldb) {
41 #ifdef EGBLAS_HAS_SAXDY
42  inc_counter("egblas");
43  egblas_saxdy(n, alpha, A, lda, B, ldb);
44 #else
45  cpp_unreachable("Invalid call to egblas::axdy");
46 #endif
47 }
48 
49 #ifdef EGBLAS_HAS_DAXDY
50 static constexpr bool has_daxdy = true;
51 #else
52 static constexpr bool has_daxdy = false;
53 #endif
54 
64 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] double alpha, [[maybe_unused]] const double* A, [[maybe_unused]] size_t lda, [[maybe_unused]] double* B, [[maybe_unused]] size_t ldb) {
65 #ifdef EGBLAS_HAS_DAXDY
66  inc_counter("egblas");
67  egblas_daxdy(n, alpha, A, lda, B, ldb);
68 #else
69  cpp_unreachable("Invalid call to egblas::axdy");
70 #endif
71 }
72 
73 #ifdef EGBLAS_HAS_CAXDY
74 static constexpr bool has_caxdy = true;
75 #else
76 static constexpr bool has_caxdy = false;
77 #endif
78 
88 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] std::complex<float> alpha, [[maybe_unused]] const std::complex<float>* A, [[maybe_unused]] size_t lda, [[maybe_unused]] std::complex<float>* B, [[maybe_unused]] size_t ldb) {
89 #ifdef EGBLAS_HAS_CAXDY
90  inc_counter("egblas");
91  egblas_caxdy(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
92 #else
93  cpp_unreachable("Invalid call to egblas::axdy");
94 #endif
95 }
96 
106 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] etl::complex<float> alpha, [[maybe_unused]] const etl::complex<float>* A, [[maybe_unused]] size_t lda, [[maybe_unused]] etl::complex<float>* B, [[maybe_unused]] size_t ldb) {
107 #ifdef EGBLAS_HAS_CAXDY
108  inc_counter("egblas");
109  egblas_caxdy(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
110 #else
111  cpp_unreachable("Invalid call to egblas::axdy");
112 #endif
113 }
114 
115 #ifdef EGBLAS_HAS_ZAXDY
116 static constexpr bool has_zaxdy = true;
117 #else
118 static constexpr bool has_zaxdy = false;
119 #endif
120 
130 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] std::complex<double> alpha, [[maybe_unused]] const std::complex<double>* A, [[maybe_unused]] size_t lda, [[maybe_unused]] std::complex<double>* B, [[maybe_unused]] size_t ldb) {
131 #ifdef EGBLAS_HAS_ZAXDY
132  inc_counter("egblas");
133  egblas_zaxdy(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
134 #else
135  cpp_unreachable("Invalid call to egblas::axdy");
136 #endif
137 }
138 
148 inline void axdy([[maybe_unused]] size_t n, [[maybe_unused]] etl::complex<double> alpha, [[maybe_unused]] const etl::complex<double>* A, [[maybe_unused]] size_t lda, [[maybe_unused]] etl::complex<double>* B, [[maybe_unused]] size_t ldb) {
149 #ifdef EGBLAS_HAS_ZAXDY
150  inc_counter("egblas");
151  egblas_zaxdy(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
152 #else
153  cpp_unreachable("Invalid call to egblas::axdy");
154 #endif
155 }
156 
157 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
void axdy([[maybe_unused]] size_t n, [[maybe_unused]] float alpha, [[maybe_unused]] const float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb)
Wrappers for single-precision egblas axdy operation.
Definition: axdy.hpp:40
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25