Expression Templates Library (ETL)
scal.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_CUBLAS_MODE
16 
17 #include "etl/impl/cublas/cuda.hpp"
19 
20 #endif
21 
22 namespace etl::impl::cublas {
23 
24 #ifdef ETL_CUBLAS_MODE
25 
34 inline void cublas_scal(cublasHandle_t handle, size_t n, const float* alpha, float* A, size_t lda) {
35  cublas_check(cublasSscal(handle, n, alpha, A, lda));
36 }
37 
46 inline void cublas_scal(cublasHandle_t handle, size_t n, const double* alpha, double* A, size_t lda) {
47  cublas_check(cublasDscal(handle, n, alpha, A, lda));
48 }
49 
60 inline void cublas_scal(cublasHandle_t handle, size_t n, const std::complex<float>* alpha, std::complex<float>* A, size_t lda) {
61  cublas_check(cublasCscal(handle, n, reinterpret_cast<const cuComplex*>(alpha), reinterpret_cast<cuComplex*>(A), lda));
62 }
63 
74 inline void cublas_scal(cublasHandle_t handle, size_t n, const std::complex<double>* alpha, std::complex<double>* A, size_t lda) {
75  cublas_check(cublasZscal(handle, n, reinterpret_cast<const cuDoubleComplex*>(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda));
76 }
77 
88 inline void cublas_scal(cublasHandle_t handle, size_t n, const etl::complex<float>* alpha, etl::complex<float>* A, size_t lda) {
89  cublas_check(cublasCscal(handle, n, reinterpret_cast<const cuComplex*>(alpha), reinterpret_cast<cuComplex*>(A), lda));
90 }
91 
102 inline void cublas_scal(cublasHandle_t handle, size_t n, const etl::complex<double>* alpha, etl::complex<double>* A, size_t lda) {
103  cublas_check(cublasZscal(handle, n, reinterpret_cast<const cuDoubleComplex*>(alpha), reinterpret_cast<cuDoubleComplex*>(A), lda));
104 }
105 
106 #endif
107 
108 } //end of namespace etl::impl::cublas
Complex number implementation.
Definition: complex.hpp:31
Definition: axpy.hpp:22
Utility functions for cublas.