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="A">pointer to <![CDATA[<Atype>]]> matrix, A, corresponds to the first instance of the batch 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="strideA">value of type long long int that gives the address offset between A[i] and A[i+1]. </param>
/// <param name="strideB">value of type long long int that gives the address offset between B[i] and B[i+1]. </param>
/// <param name="strideC">value of type long long int that gives the address offset between C[i] and C[i+1]. </param>
/// <param name="B">pointer to <![CDATA[<Btype>]]> matrix, A, corresponds to the first instance of the batch 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="C">pointer to <![CDATA[<Ctype>]]> matrix, A, corresponds to the first instance of the batch. 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>
/// <param name="algo"></param>
/// <param name="Atype"></param>
/// <param name="Btype"></param>
/// <param name="computeType"></param>
/// <param name="Ctype"></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 GemmStridedBatched(Operation transa, Operation transb, int m, int n, int k, IntPtr alpha,
                                   CUdeviceptr A, cudaDataType Atype, int lda, long strideA, CUdeviceptr B, cudaDataType Btype, int ldb, long strideB,
                                   IntPtr beta, CUdeviceptr C, cudaDataType Ctype, int ldc, long strideC, int batchCount, cudaDataType computeType, GemmAlgo algo)
        {
            _status = CudaBlasNativeMethods.cublasGemmStridedBatchedEx(_blasHandle, transa, transb, m, n, k, alpha, A,
                Atype, lda, strideA, B, Btype, ldb, strideB, beta, C, Ctype, ldc, strideC, batchCount, computeType, algo);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cublasGemmBatchedEx", _status));
            if (_status != CublasStatus.Success) throw new CudaBlasException(_status);
        }
public void GemmStridedBatched ( Operation transa , Operation transb , int m , int n , int k , IntPtr alpha , CUdeviceptr A , cudaDataType Atype , int lda , long strideA , CUdeviceptr B , cudaDataType Btype , int ldb , long strideB , IntPtr beta , CUdeviceptr C , cudaDataType Ctype , int ldc , long strideC , int batchCount , cudaDataType computeType , GemmAlgo algo ) { _status = CudaBlasNativeMethods . cublasGemmStridedBatchedEx ( _blasHandle , transa , transb , m , n , k , alpha , A , Atype , lda , strideA , B , Btype , ldb , strideB , beta , C , Ctype , ldc , strideC , batchCount , computeType , algo ) ; 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
IntPtr
scalar used for multiplication.
scalar used for multiplication .
A
CUdeviceptr
pointer to  matrix, A, corresponds to the first instance of the batch 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.
pointer to matrix A corresponds to the first instance of the batch 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 .
Atype
cudaDataType
None
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 ] .
strideA
long
value of type long long int that gives the address offset between A[i] and A[i+1].
value of type long long int that gives the address offset between A [ i ] and A [ i + 1 ] .
B
CUdeviceptr
pointer to  matrix, A, corresponds to the first instance of the batch 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.
pointer to matrix A corresponds to the first instance of the batch 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 .
Btype
cudaDataType
None
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 ] .
strideB
long
value of type long long int that gives the address offset between B[i] and B[i+1].
value of type long long int that gives the address offset between B [ i ] and B [ i + 1 ] .
beta
IntPtr
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 .
C
CUdeviceptr
pointer to  matrix, A, corresponds to the first instance of the batch. It has dimensions ldc x n with ldc>=max(1,m).
pointer to matrix A corresponds to the first instance of the batch . It has dimensions ldc x n with ldc > = max ( 1 m ) .
Ctype
cudaDataType
None
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 ] .
strideC
long
value of type long long int that gives the address offset between C[i] and C[i+1].
value of type long long int that gives the address offset between C [ i ] and C [ i + 1 ] .
batchCount
int
number of pointers contained in A, B and C.
number of pointers contained in A B and C .
computeType
cudaDataType
None
algo
GemmAlgo
None