Expression Templates Library (ETL)
not_equal.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_SNOT_EQUAL
29 static constexpr bool has_snot_equal = true;
30 #else
31 static constexpr bool has_snot_equal = false;
32 #endif
33 
44 inline void not_equal([[maybe_unused]] size_t n,
45  [[maybe_unused]] const float* A,
46  [[maybe_unused]] size_t lda,
47  [[maybe_unused]] const float* B,
48  [[maybe_unused]] size_t ldb,
49  [[maybe_unused]] bool* C,
50  [[maybe_unused]] size_t ldc) {
51 #ifdef EGBLAS_HAS_SNOT_EQUAL
52  inc_counter("egblas");
53  egblas_snot_equal(n, A, lda, B, ldb, C, ldc);
54 #else
55  cpp_unreachable("Invalid call to egblas::not_equal");
56 #endif
57 }
58 
62 #ifdef EGBLAS_HAS_DNOT_EQUAL
63 static constexpr bool has_dnot_equal = true;
64 #else
65 static constexpr bool has_dnot_equal = false;
66 #endif
67 
78 inline void not_equal([[maybe_unused]] size_t n,
79  [[maybe_unused]] const double* A,
80  [[maybe_unused]] size_t lda,
81  [[maybe_unused]] const double* B,
82  [[maybe_unused]] size_t ldb,
83  [[maybe_unused]] bool* C,
84  [[maybe_unused]] size_t ldc) {
85 #ifdef EGBLAS_HAS_DNOT_EQUAL
86  inc_counter("egblas");
87  egblas_dnot_equal(n, A, lda, B, ldb, C, ldc);
88 #else
89  cpp_unreachable("Invalid call to egblas::not_equal");
90 #endif
91 }
92 
96 #ifdef EGBLAS_HAS_CNOT_EQUAL
97 static constexpr bool has_cnot_equal = true;
98 #else
99 static constexpr bool has_cnot_equal = false;
100 #endif
101 
112 inline void not_equal([[maybe_unused]] size_t n,
113  [[maybe_unused]] const std::complex<float>* A,
114  [[maybe_unused]] size_t lda,
115  [[maybe_unused]] const std::complex<float>* B,
116  [[maybe_unused]] size_t ldb,
117  [[maybe_unused]] bool* C,
118  [[maybe_unused]] size_t ldc) {
119 #ifdef EGBLAS_HAS_CNOT_EQUAL
120  inc_counter("egblas");
121  egblas_cnot_equal(n, reinterpret_cast<const cuComplex*>(A), lda, reinterpret_cast<const cuComplex*>(B), ldb, C, ldc);
122 #else
123  cpp_unreachable("Invalid call to egblas::not_equal");
124 #endif
125 }
126 
137 inline void not_equal([[maybe_unused]] size_t n,
138  [[maybe_unused]] const etl::complex<float>* A,
139  [[maybe_unused]] size_t lda,
140  [[maybe_unused]] const etl::complex<float>* B,
141  [[maybe_unused]] size_t ldb,
142  [[maybe_unused]] bool* C,
143  [[maybe_unused]] size_t ldc) {
144 #ifdef EGBLAS_HAS_CNOT_EQUAL
145  inc_counter("egblas");
146  egblas_cnot_equal(n, reinterpret_cast<const cuComplex*>(A), lda, reinterpret_cast<const cuComplex*>(B), ldb, C, ldc);
147 #else
148  cpp_unreachable("Invalid call to egblas::not_equal");
149 #endif
150 }
151 
155 #ifdef EGBLAS_HAS_ZNOT_EQUAL
156 static constexpr bool has_znot_equal = true;
157 #else
158 static constexpr bool has_znot_equal = false;
159 #endif
160 
171 inline void not_equal([[maybe_unused]] size_t n,
172  [[maybe_unused]] const std::complex<double>* A,
173  [[maybe_unused]] size_t lda,
174  [[maybe_unused]] const std::complex<double>* B,
175  [[maybe_unused]] size_t ldb,
176  [[maybe_unused]] bool* C,
177  [[maybe_unused]] size_t ldc) {
178 #ifdef EGBLAS_HAS_ZNOT_EQUAL
179  inc_counter("egblas");
180  egblas_znot_equal(n, reinterpret_cast<const cuDoubleComplex*>(A), lda, reinterpret_cast<const cuDoubleComplex*>(B), ldb, C, ldc);
181 #else
182  cpp_unreachable("Invalid call to egblas::not_equal");
183 #endif
184 }
185 
196 inline void not_equal([[maybe_unused]] size_t n,
197  [[maybe_unused]] const etl::complex<double>* A,
198  [[maybe_unused]] size_t lda,
199  [[maybe_unused]] const etl::complex<double>* B,
200  [[maybe_unused]] size_t ldb,
201  [[maybe_unused]] bool* C,
202  [[maybe_unused]] size_t ldc) {
203 #ifdef EGBLAS_HAS_ZNOT_EQUAL
204  inc_counter("egblas");
205  egblas_znot_equal(n, reinterpret_cast<const cuDoubleComplex*>(A), lda, reinterpret_cast<const cuDoubleComplex*>(B), ldb, C, ldc);
206 #else
207  cpp_unreachable("Invalid call to egblas::not_equal");
208 #endif
209 }
210 
211 } //end of namespace etl::impl::egblas
Complex number implementation.
Definition: complex.hpp:31
Definition: abs.hpp:23
auto not_equal(LE &&lhs, RE rhs)
Builds an expression representing the elementwise comparison of lhs and rhs.
Definition: binary_expression_builder.hpp:406
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25