Library/ManagedCuda/CudaBlas/CudaBlasHandler.cs
/// <summary>
/// This function performs the matrix-matrix multiplications of an array of matrices.
/// where and are scalars, and , and are arrays of pointers to matrices stored
/// in column-major format with dimensions op(A[i])m x k, op(B[i])k x n and op(C[i])m x n, 
/// respectively.<para/>
/// This function is intended to be used for matrices of small sizes where the launch
/// overhead is a significant factor. For small sizes, typically smaller than 100x100,
/// this function improves significantly performance compared to making calls to its
/// corresponding cublas<![CDATA[<type>]]>gemm routine. However, on GPU architectures that support
/// concurrent kernels, it might be advantageous to make multiple calls to cublas<![CDATA[<type>]]>gemm
/// into different streams as the matrix sizes increase.
/// </summary>
/// <param name="transa">operation op(A[i]) that is non- or (conj.) transpose.</param>
/// <param name="transb">operation op(B[i]) that is non- or (conj.) transpose.</param>
/// <param name="m">number of rows of matrix op(A[i]) and C[i].</param>
/// <param name="n">number of columns of op(B[i]) and C[i].</param>
/// <param name="k">number of columns of op(A[i]) and rows of op(B[i]).</param>
/// <param name="alpha">scalar used for multiplication.</param>
/// <param name="Aarray">array of device pointers, with each array/device pointer of dim. lda x k with lda>=max(1,m) if
/// transa==CUBLAS_OP_N and lda x m with lda>=max(1,k) otherwise.</param>
/// <param name="lda">leading dimension of two-dimensional array used to store each matrix A[i].</param>
/// <param name="Barray">array of device pointers, with each array of dim. ldb x n with ldb>=max(1,k) if
/// transa==CUBLAS_OP_N and ldb x k with ldb>=max(1,n) max(1,) otherwise.</param>
/// <param name="ldb">leading dimension of two-dimensional array used to store each matrix B[i].</param>
/// <param name="beta">scalar used for multiplication. If beta == 0, C does not have to be a valid input.</param>
/// <param name="Carray">array of device pointers. It has dimensions ldc x n with ldc>=max(1,m).</param>
/// <param name="ldc">leading dimension of two-dimensional array used to store each matrix C[i].</param>
/// <param name="batchCount">number of pointers contained in A, B and C.</param>
This function performs the matrix-matrix multiplications of an array of matrices.
where and are scalars, and , and are arrays of pointers to matrices stored
in column-major format with dimensions op(A[i])m x k, op(B[i])k x n and op(C[i])m x n,
respectively.
This function is intended to be used for matrices of small sizes where the launch
overhead is a significant factor. For small sizes, typically smaller than 100x100,
this function improves significantly performance compared to making calls to its
corresponding cublasgemm routine. However, on GPU architectures that support
concurrent kernels, it might be advantageous to make multiple calls to cublasgemm
into different streams as the matrix sizes increase.
This function performs the matrix - matrix multiplications of an array of matrices . where and are scalars and and are arrays of pointers to matrices stored in column - major format with dimensions op ( A [ i ] ) m x k op ( B [ i ] ) k x n and op ( C [ i ] ) m x n respectively . This function is intended to be used for matrices of small sizes where the launch overhead is a significant factor . For small sizes typically smaller than 100x100 this function improves significantly performance compared to making calls to its corresponding cublasgemm routine . However on GPU architectures that support concurrent kernels it might be advantageous to make multiple calls to cublasgemm into different streams as the matrix sizes increase .
public void GemmBatched(Operation transa, Operation transb, int m, int n, int k, float alpha, CudaDeviceVariable<CUdeviceptr> Aarray,
			int lda, CudaDeviceVariable<CUdeviceptr> Barray, int ldb, float beta, CudaDeviceVariable<CUdeviceptr> Carray, int ldc, int batchCount)
		{
			_status = CudaBlasNativeMethods.cublasSgemmBatched(_blasHandle, transa, transb, m, n, k, ref alpha, Aarray.DevicePointer, lda, Barray.DevicePointer, ldb, ref beta, Carray.DevicePointer, ldc, batchCount);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cublasSgemmBatched", _status));
			if (_status != CublasStatus.Success) throw new CudaBlasException(_status);
		}
public void GemmBatched ( Operation transa , Operation transb , int m , int n , int k , float alpha , CudaDeviceVariable < CUdeviceptr > Aarray , int lda , CudaDeviceVariable < CUdeviceptr > Barray , int ldb , float beta , CudaDeviceVariable < CUdeviceptr > Carray , int ldc , int batchCount ) { _status = CudaBlasNativeMethods . cublasSgemmBatched ( _blasHandle , transa , transb , m , n , k , ref alpha , Aarray . DevicePointer , lda , Barray . DevicePointer , ldb , ref beta , Carray . DevicePointer , ldc , batchCount ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , _status ) ) ; if ( _status != CublasStatus . Success ) throw new CudaBlasException ( _status ) ; }
This function performs the matrix-matrix multiplications of an array of matrices.
This function performs the matrix - matrix multiplications of an array of matrices .
transa
Operation
operation op(A[i]) that is non- or (conj.) transpose.
operation op ( A [ i ] ) that is non - or ( conj . ) transpose .
transb
Operation
operation op(B[i]) that is non- or (conj.) transpose.
operation op ( B [ i ] ) that is non - or ( conj . ) transpose .
m
int
number of rows of matrix op(A[i]) and C[i].
number of rows of matrix op ( A [ i ] ) and C [ i ] .
n
int
number of columns of op(B[i]) and C[i].
number of columns of op ( B [ i ] ) and C [ i ] .
k
int
number of columns of op(A[i]) and rows of op(B[i]).
number of columns of op ( A [ i ] ) and rows of op ( B [ i ] ) .
alpha
float
scalar used for multiplication.
scalar used for multiplication .
Aarray
CudaDeviceVariable<CUdeviceptr>
array of device pointers, with each array/device pointer of dim. lda x k with lda>=max(1,m) if
transa==CUBLAS_OP_N and lda x m with lda>=max(1,k) otherwise.
array of device pointers with each array / device pointer of dim . lda x k with lda > = max ( 1 m ) if transa == CUBLAS_OP_N and lda x m with lda > = max ( 1 k ) otherwise .
lda
int
leading dimension of two-dimensional array used to store each matrix A[i].
leading dimension of two - dimensional array used to store each matrix A [ i ] .
Barray
CudaDeviceVariable<CUdeviceptr>
array of device pointers, with each array of dim. ldb x n with ldb>=max(1,k) if
transa==CUBLAS_OP_N and ldb x k with ldb>=max(1,n) max(1,) otherwise.
array of device pointers with each array of dim . ldb x n with ldb > = max ( 1 k ) if transa == CUBLAS_OP_N and ldb x k with ldb > = max ( 1 n ) max ( 1 ) otherwise .
ldb
int
leading dimension of two-dimensional array used to store each matrix B[i].
leading dimension of two - dimensional array used to store each matrix B [ i ] .
beta
float
scalar used for multiplication. If beta == 0, C does not have to be a valid input.
scalar used for multiplication . If beta == 0 C does not have to be a valid input .
Carray
CudaDeviceVariable<CUdeviceptr>
array of device pointers. It has dimensions ldc x n with ldc>=max(1,m).
array of device pointers . It has dimensions ldc x n with ldc > = max ( 1 m ) .
ldc
int
leading dimension of two-dimensional array used to store each matrix C[i].
leading dimension of two - dimensional array used to store each matrix C [ i ] .
batchCount
int
number of pointers contained in A, B and C.
number of pointers contained in A B and C .