40 #ifndef MM_KERNEL_OUTER_A_H 41 #define MM_KERNEL_OUTER_A_H 52 template<
typename T_gemm_kernel,
int T_M_block,
int T_N_block>
54 template<
int T_rows_block,
int T_cols_block,
typename T_ordering_block,
typename T_pack_type_kernel>
78 static void exec(
real const *
const *
const A,
79 real const *
const *
const B,
85 template<
typename T_gemm_kernel,
int T_M_block,
int T_N_block>
87 real const *
const *
const B,
91 for (
int n = 0; n < N_block; ++n )
92 for (
int m = 0; m < M_block; ++m ) {
93 T_gemm_kernel::exec(
A,
B, C, n_mul,
94 Ordering_block_A::get( m, 0, M_block, K_block ) * T_gemm_kernel::Pack_type_A::size_packed,
95 Ordering_block_B::get( 0, n, K_block, N_block ) * T_gemm_kernel::Pack_type_B::size_packed,
96 Ordering_block_C::get( m, n, M_block, N_block ) * T_gemm_kernel::Pack_type_C::size_packed );
102 T_gemm_kernel::template exec<Ordering_block_A::template Get<0, 0, M_block, K_block>::index * T_gemm_kernel::Pack_type_A::size_packed,
103 Ordering_block_B::template Get<0, 0, K_block, N_block>::index * T_gemm_kernel::Pack_type_B::size_packed,
104 Ordering_block_C::template Get<0, 0, M_block, N_block>::index * T_gemm_kernel::Pack_type_C::size_packed>(
A,
B, C, n_mul );
105 T_gemm_kernel::template exec<Ordering_block_A::template Get<1, 0, M_block, K_block>::index * T_gemm_kernel::Pack_type_A::size_packed,
106 Ordering_block_B::template Get<0, 0, K_block, N_block>::index * T_gemm_kernel::Pack_type_B::size_packed,
107 Ordering_block_C::template Get<1, 0, M_block, N_block>::index * T_gemm_kernel::Pack_type_C::size_packed>(
A,
B, C, n_mul );
109 T_gemm_kernel::exec(
A,
B, C, n_mul,
110 Ordering_block_A::get( 0, 0, M_block, K_block ) * T_gemm_kernel::Pack_type_A::size_packed,
111 Ordering_block_B::get( 0, 0, K_block, N_block ) * T_gemm_kernel::Pack_type_B::size_packed,
112 Ordering_block_C::get( 0, 0, M_block, N_block ) * T_gemm_kernel::Pack_type_C::size_packed );
127 template<
typename T_gemm_kernel,
int T_M_block,
int T_N_block>
128 template<
int T_rows_block,
int T_cols_block,
typename T_ordering_block,
typename T_pack_type_kernel>
133 static int const rows = rows_kernel * T_rows_block;
134 static int const cols = cols_kernel * T_cols_block;
139 static unsigned int const size_packed = T_rows_block * T_cols_block * T_pack_type_kernel::size_packed;
142 template<
typename T_ordering_matrix>
146 template<
typename T_ordering_matrix>
156 template<
template<
typename T_ordering>
class T_assign,
typename T_ordering_matrix>
157 static void exec(
typename T_assign<T_ordering_matrix>::PtrType X,
typename T_assign<T_ordering_matrix>::PtrTypePacked X_packed,
158 int const rows_total_matrix,
int const cols_total_matrix) {
160 for (
int col_b = 0; col_b < T_cols_block; ++col_b ) {
162 for (
int row_b = 0; row_b < T_rows_block; ++row_b ) {
163 T_pack_type_kernel::template exec< T_assign, T_ordering_matrix >
164 ( &X[ T_assign<T_ordering_matrix>::Ordering_matrix::get( row_b * rows_kernel, col_b * cols_kernel,
165 rows_total_matrix, cols_total_matrix ) ],
166 &X_packed[ T_ordering_block::get( row_b, col_b, T_rows_block, T_cols_block ) *
167 T_pack_type_kernel::size_packed ],
168 rows_total_matrix, cols_total_matrix );
180 template<
typename T_ordering_matrix>
182 int const rows_total_matrix,
int const cols_total_matrix) {
183 exec< Assign_to_packed, T_ordering_matrix >(X, X_packed, rows_total_matrix, cols_total_matrix);
189 template<
typename T_ordering_matrix>
191 int const rows_total_matrix,
int const cols_total_matrix) {
192 exec< Extract_from_packed, T_ordering_matrix >(X, X_packed, rows_total_matrix, cols_total_matrix);
mat::SizesAndBlocks rows
Definition: test.cc:51
static int const M_block
Number of rows of A and C (blocks).
Definition: mm_kernel_outer_A.h:60
static int const M
Number of rows of A and C.
Definition: mm_kernel_outer_A.h:63
mat::SizesAndBlocks cols
Definition: test.cc:52
Pack< M_block, N_block, Ordering_block_C, typename T_gemm_kernel::Pack_type_C > Pack_type_C
Definition: mm_kernel_outer_A.h:74
static void exec(real const *const *const A, real const *const *const B, real *const C, int const i=1)
Executes the matrix-matrix multiply C += A B with the three matrices A, B, and C stored using the pac...
Definition: mm_kernel_outer_A.h:86
static int const K_kernel
Number of columns of A kernels and rows of B kernels.
Definition: mm_kernel_outer_A.h:59
Ordering_col_wise Ordering_block_C
Definition: mm_kernel_outer_A.h:70
static void unpack(real *X, real const *const X_packed, int const rows_total_matrix, int const cols_total_matrix)
Convenience function for extracting matrix from packed matrix.
Definition: mm_kernel_outer_A.h:190
ergo_real real
Definition: test.cc:46
T_ordering_matrix Ordering_matrix
Definition: mm_kernel_outer_A.h:144
static int const M_kernel
Number of rows of A and C kernels.
Definition: mm_kernel_outer_A.h:57
Template for for translations between unpacked and packed matrix storage.
Definition: mm_kernel_outer_A.h:55
T_gemm_kernel::real real
Real number type (usually float or double)
Definition: mm_kernel_outer_A.h:66
static void exec(typename T_assign< T_ordering_matrix >::PtrType X, typename T_assign< T_ordering_matrix >::PtrTypePacked X_packed, int const rows_total_matrix, int const cols_total_matrix)
Elaborate function that can be called either to assign to or extract from packed format.
Definition: mm_kernel_outer_A.h:157
static int const N_block
Number of columns of B and C (blocks).
Definition: mm_kernel_outer_A.h:61
static int const K_block
Number of columns of A and rows of B (blocks).
Definition: mm_kernel_outer_A.h:62
Pack< K_block, N_block, Ordering_block_B, typename T_gemm_kernel::Pack_type_B > Pack_type_B
Definition: mm_kernel_outer_A.h:73
Struct for access to matrix elements stored in column wise order.
Definition: common.h:104
static int const K
Number of columns of A and rows of B.
Definition: mm_kernel_outer_A.h:65
Definition: mm_kernel_outer_A.h:143
Ordering_col_wise Ordering_block_B
Definition: mm_kernel_outer_A.h:69
Pack< M_block, K_block, Ordering_block_A, typename T_gemm_kernel::Pack_type_A > Pack_type_A
Definition: mm_kernel_outer_A.h:72
Macros for inlining and static assertions and structs for access to matrix elements specifying the la...
static int const N_kernel
Number of columns of B and C kernels.
Definition: mm_kernel_outer_A.h:58
static int const N
Number of columns of B and C.
Definition: mm_kernel_outer_A.h:64
Template for matrix matrix multiplication that wraps around a kernel given as template argument...
Definition: mm_kernel_outer_A.h:53
static void pack(real const *const X, real *X_packed, int const rows_total_matrix, int const cols_total_matrix)
Convenience function for assignments to packed matrix.
Definition: mm_kernel_outer_A.h:181
Ordering_col_wise Ordering_block_A
Definition: mm_kernel_outer_A.h:68