Expression Templates Library (ETL)
ceil.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 
28 #ifdef EGBLAS_HAS_SCEIL
29 static constexpr bool has_sceil = true;
30 #else
31 static constexpr bool has_sceil = false;
32 #endif
33 
43 inline void ceil([[maybe_unused]] size_t n,
44  [[maybe_unused]] float alpha,
45  [[maybe_unused]] float* A,
46  [[maybe_unused]] size_t lda,
47  [[maybe_unused]] float* B,
48  [[maybe_unused]] size_t ldb) {
49 #ifdef EGBLAS_HAS_SCEIL
50  inc_counter("egblas");
51  egblas_sceil(n, alpha, A, lda, B, ldb);
52 #else
53  cpp_unreachable("Invalid call to egblas::ceil");
54 #endif
55 }
56 
60 #ifdef EGBLAS_HAS_DCEIL
61 static constexpr bool has_dceil = true;
62 #else
63 static constexpr bool has_dceil = false;
64 #endif
65 
75 inline void ceil([[maybe_unused]] size_t n,
76  [[maybe_unused]] double alpha,
77  [[maybe_unused]] double* A,
78  [[maybe_unused]] size_t lda,
79  [[maybe_unused]] double* B,
80  [[maybe_unused]] size_t ldb) {
81 #ifdef EGBLAS_HAS_DCEIL
82  inc_counter("egblas");
83  egblas_dceil(n, alpha, A, lda, B, ldb);
84 #else
85  cpp_unreachable("Invalid call to egblas::ceil");
86 #endif
87 }
88 
92 #ifdef EGBLAS_HAS_CCEIL
93 static constexpr bool has_cceil = true;
94 #else
95 static constexpr bool has_cceil = false;
96 #endif
97 
107 inline void ceil([[maybe_unused]] size_t n,
108  [[maybe_unused]] std::complex<float> alpha,
109  [[maybe_unused]] std::complex<float>* A,
110  [[maybe_unused]] size_t lda,
111  [[maybe_unused]] std::complex<float>* B,
112  [[maybe_unused]] size_t ldb) {
113 #ifdef EGBLAS_HAS_CCEIL
114  inc_counter("egblas");
115  egblas_cceil(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
116 #else
117  cpp_unreachable("Invalid call to egblas::ceil");
118 #endif
119 }
120 
130 inline void ceil([[maybe_unused]] size_t n,
131  [[maybe_unused]] etl::complex<float> alpha,
132  [[maybe_unused]] etl::complex<float>* A,
133  [[maybe_unused]] size_t lda,
134  [[maybe_unused]] etl::complex<float>* B,
135  [[maybe_unused]] size_t ldb) {
136 #ifdef EGBLAS_HAS_CCEIL
137  inc_counter("egblas");
138  egblas_cceil(n, complex_cast(alpha), reinterpret_cast<cuComplex*>(A), lda, reinterpret_cast<cuComplex*>(B), ldb);
139 #else
140  cpp_unreachable("Invalid call to egblas::ceil");
141 #endif
142 }
143 
147 #ifdef EGBLAS_HAS_ZCEIL
148 static constexpr bool has_zceil = true;
149 #else
150 static constexpr bool has_zceil = false;
151 #endif
152 
162 inline void ceil([[maybe_unused]] size_t n,
163  [[maybe_unused]] std::complex<double> alpha,
164  [[maybe_unused]] std::complex<double>* A,
165  [[maybe_unused]] size_t lda,
166  [[maybe_unused]] std::complex<double>* B,
167  [[maybe_unused]] size_t ldb) {
168 #ifdef EGBLAS_HAS_ZCEIL
169  inc_counter("egblas");
170  egblas_zceil(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
171 #else
172  cpp_unreachable("Invalid call to egblas::ceil");
173 #endif
174 }
175 
185 inline void ceil([[maybe_unused]] size_t n,
186  [[maybe_unused]] etl::complex<double> alpha,
187  [[maybe_unused]] etl::complex<double>* A,
188  [[maybe_unused]] size_t lda,
189  [[maybe_unused]] etl::complex<double>* B,
190  [[maybe_unused]] size_t ldb) {
191 #ifdef EGBLAS_HAS_ZCEIL
192  inc_counter("egblas");
193  egblas_zceil(n, complex_cast(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda, reinterpret_cast<cuDoubleComplex*>(B), ldb);
194 #else
195  cpp_unreachable("Invalid call to egblas::ceil");
196 #endif
197 }
198 
199 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
auto ceil(E &&value)
Round up each values of the ETL expression.
Definition: expression_builder.hpp:98
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25