Blaze 3.9
gemm.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_BLAS_GEMM_H_
36#define _BLAZE_MATH_BLAS_GEMM_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
51#include <blaze/system/BLAS.h>
53
54
55namespace blaze {
56
57//=================================================================================================
58//
59// BLAS GENERAL MATRIX MULTIPLICATION FUNCTIONS (GEMM)
60//
61//=================================================================================================
62
63//*************************************************************************************************
66#if BLAZE_BLAS_MODE
67
68template< typename MT1, bool SO1, typename MT2, bool SO2, typename MT3, bool SO3, typename ST >
69void gemm( DenseMatrix<MT1,SO1>& C, const DenseMatrix<MT2,SO2>& A,
70 const DenseMatrix<MT3,SO3>& B, ST alpha, ST beta );
71
72#endif
74//*************************************************************************************************
75
76
77//*************************************************************************************************
78#if BLAZE_BLAS_MODE
98template< typename MT1 // Type of the left-hand side target matrix
99 , bool SO1 // Storage order of the left-hand side target matrix
100 , typename MT2 // Type of the left-hand side matrix operand
101 , bool SO2 // Storage order of the left-hand side matrix operand
102 , typename MT3 // Type of the right-hand side matrix operand
103 , bool SO3 // Storage order of the right-hand side matrix operand
104 , typename ST > // Type of the scalar factors
105inline void gemm( DenseMatrix<MT1,SO1>& C, const DenseMatrix<MT2,SO2>& A,
106 const DenseMatrix<MT3,SO3>& B, ST alpha, ST beta )
107{
111
115
119
120 const blas_int_t m ( numeric_cast<blas_int_t>( (*A).rows() ) );
121 const blas_int_t n ( numeric_cast<blas_int_t>( (*B).columns() ) );
122 const blas_int_t k ( numeric_cast<blas_int_t>( (*A).columns() ) );
123 const blas_int_t lda( numeric_cast<blas_int_t>( (*A).spacing() ) );
124 const blas_int_t ldb( numeric_cast<blas_int_t>( (*B).spacing() ) );
125 const blas_int_t ldc( numeric_cast<blas_int_t>( (*C).spacing() ) );
126
127 gemm( ( IsRowMajorMatrix_v<MT1> )?( CblasRowMajor ):( CblasColMajor ),
128 ( SO1 == SO2 )?( CblasNoTrans ):( CblasTrans ),
129 ( SO1 == SO3 )?( CblasNoTrans ):( CblasTrans ),
130 m, n, k, alpha, (*A).data(), lda, (*B).data(), ldb, beta, (*C).data(), ldc );
131}
132#endif
133//*************************************************************************************************
134
135} // namespace blaze
136
137#endif
Header file for auxiliary alias declarations.
Constraint on the data type.
Constraint on the data type.
Header file for the IsRowMajorMatrix type trait.
Constraint on the data type.
Cast operators for numeric types.
Header file for the CBLAS gemm wrapper functions.
Constraint on the data type.
Header file for the DenseMatrix base class.
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.
Definition: MutableDataAccess.h:61
#define BLAZE_CONSTRAINT_MUST_HAVE_CONST_DATA_ACCESS(T)
Constraint on the data type.
Definition: ConstDataAccess.h:61
int32_t blas_int_t
Signed integer type used in the BLAS/LAPACK wrapper functions.
Definition: Types.h:64
System settings for the BLAS mode.