mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
A templatized interface to the cublas library
Functions | |
template<typename floatT > | |
cublasStatus_t | mx::cuda::cublasTscal (cublasHandle_t handle, int n, const floatT *alpha, floatT *x, int incx) |
Multiplies a vector by a scalar, overwriting the vector with the result. More... | |
template<typename floatT > | |
cublasStatus_t | mx::cuda::cublasTaxpy (cublasHandle_t handle, int n, const floatT *alpha, const floatT *x, int incx, floatT *y, int incy) |
Multiplies a vector by a scalar, adding it to a second vector which is overwritten by the result. More... | |
template<typename dataT1 , typename dataT2 > | |
cudaError_t | mx::cuda::elementwiseXxY (dataT1 *x, dataT2 *y, int size) |
Calculates the element-wise product of two vectors, storing the result in the first. More... | |
template<typename floatT > | |
cublasStatus_t | mx::cuda::cublasTgemv (cublasHandle_t handle, cublasOperation_t trans, int m, int n, const floatT *alpha, const floatT *A, int lda, const floatT *x, int incx, const floatT *beta, floatT *y, int incy) |
Perform a matrix-vector multiplication. More... | |
template<typename floatT > | |
cublasStatus_t | mx::cuda::cublasTgemv (cublasHandle_t handle, cublasOperation_t trans, int m, int n, const floatT *alpha, const floatT *A, const floatT *x, const floatT *beta, floatT *y) |
Perform a matrix-vector multiplication for stride-less arrays. More... | |
cublasStatus_t mx::cuda::cublasTaxpy | ( | cublasHandle_t | handle, |
int | n, | ||
const floatT * | alpha, | ||
const floatT * | x, | ||
int | incx, | ||
floatT * | y, | ||
int | incy | ||
) |
Multiplies a vector by a scalar, adding it to a second vector which is overwritten by the result.
Implements
\[ \vec{y} = \alpha \vec{x} + \vec{y} \]
Specializations are provided for float, double, complex-float, and complex-double
floatT | a floating-point type, either float, double, complex-float, or complex-double |
[in] | handle | handle to the cuBLAS library context. |
[in] | n | scalar used for multiplication. |
[in] | alpha | number of elements in the vector x and y |
[in] | x | vector with n elements. |
[in] | incx | stride between consecutive elements of x |
y | [in.out] vector with n elements. | |
[in] | incy | stride between consecutive elements of y |
Referenced by SCENARIO().
cublasStatus_t mx::cuda::cublasTgemv | ( | cublasHandle_t | handle, |
cublasOperation_t | trans, | ||
int | m, | ||
int | n, | ||
const floatT * | alpha, | ||
const floatT * | A, | ||
const floatT * | x, | ||
const floatT * | beta, | ||
floatT * | y | ||
) |
Perform a matrix-vector multiplication for stride-less arrays.
Implements
\[ \vec{y} = \alpha \mathbf{A} \vec{x} + \beta \vec{y} \]
Specializations are provided for float, double, complex-float, and complex-double
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version assumes stride is 1 in all arrays.
floatT | a floating-point type, either float, double, complex-float, or complex-double |
[in] | handle | handle to the cuBLAS library context. |
[in] | trans | operation on a, CUBLAS_OP_N for none, and CUBLAS_OP_T for transpose |
[in] | m | rows in matrix A. |
[in] | n | columns in matrix A. |
[in] | alpha | scalar used for multiplication of A |
[in] | A | array of dimension m x n. Unchanged. |
[in] | x | vector of at least (1+(n-1)*abs(incx)) elements if transa==CUBLAS_OP_N and at least (1+(m-1)*abs(incx)) elements otherwise. |
[in] | beta | scalar used for multiplication of y, if beta==0 then y does not need to be initialized. |
y | [in.out] vector of at least (1+(m-1)*abs(incy)) elements if transa==CUBLAS_OP_N and at least (1+(n-1)*abs(incy)) elements otherwise. |
cublasStatus_t mx::cuda::cublasTgemv | ( | cublasHandle_t | handle, |
cublasOperation_t | trans, | ||
int | m, | ||
int | n, | ||
const floatT * | alpha, | ||
const floatT * | A, | ||
int | lda, | ||
const floatT * | x, | ||
int | incx, | ||
const floatT * | beta, | ||
floatT * | y, | ||
int | incy | ||
) |
Perform a matrix-vector multiplication.
Implements
\[ \vec{y} = \alpha \mathbf{A} \vec{x} + \beta \vec{y} \]
Specializations are provided for float, double, complex-float, and complex-double
floatT | a floating-point type, either float, double, complex-float, or complex-double |
\tests Scenario: multiplying a vectory by a matrix [code doc]
[in] | handle | handle to the cuBLAS library context. |
[in] | trans | operation on a, CUBLAS_OP_N for none, and CUBLAS_OP_T for transpose |
[in] | m | rows in matrix A. |
[in] | n | columns in matrix A. |
[in] | alpha | scalar used for multiplication of A |
[in] | A | array of dimension lda x n with lda >= max(1,m). The leading m by n part of the array A is multiplied by alpha and x. Unchanged. |
[in] | lda | leading dimension of A. lda must be at least max(1,m). |
[in] | x | vector of at least (1+(n-1)*abs(incx)) elements if transa==CUBLAS_OP_N and at least (1+(m-1)*abs(incx)) elements otherwise. |
[in] | incx | stride of x. |
[in] | beta | scalar used for multiplication of y, if beta==0 then y does not need to be initialized. |
y | [in.out] vector of at least (1+(m-1)*abs(incy)) elements if transa==CUBLAS_OP_N and at least (1+(n-1)*abs(incy)) elements otherwise. | |
[in] | incy | stride of y |
Referenced by SCENARIO().
cublasStatus_t mx::cuda::cublasTscal | ( | cublasHandle_t | handle, |
int | n, | ||
const floatT * | alpha, | ||
floatT * | x, | ||
int | incx | ||
) |
Multiplies a vector by a scalar, overwriting the vector with the result.
Implements
\[ \vec{x} = \alpha \vec{x} \]
Specializations are provided for float, double, complex-float, and complex-double
floatT | a floating-point type, either float, double, complex-float, or complex-double |
[in] | handle | The cublas context handle |
[in] | n | Number of elements in the vector |
[in] | alpha | The scalar |
x | [in.out] The vector of length n | |
[in] | incx | The stride of the vector |
Referenced by SCENARIO().
cudaError_t mx::cuda::elementwiseXxY | ( | dataT1 * | x, |
dataT2 * | y, | ||
int | size | ||
) |
Calculates the element-wise product of two vectors, storing the result in the first.
Calculates \( x = x * y \) element by element, a.k.a. the Hadamard product.
Specializations are provided for:
complex-double, complex-double
x | [in.out] device pointer for the 1st vector. Is replaced with the product of the two vectors | |
[in] | y | device pointer for the 2nd vector. |
[in] | size | the number of elements in the vectors. |
Referenced by SCENARIO().