matrix mul matrix is full function

This commit is contained in:
Nitload
2025-12-16 23:17:30 +08:00
26 changed files with 1049 additions and 861 deletions
+54 -8
View File
@@ -8,16 +8,16 @@ DECLARE_BUILD_PANEL(avx, float)
const int has_right = (col_index + 1) < col_length;
const int has_bottom = (row_index + 1) < row_length;
const MAT_KERNEL(float) *const k_lt = matrix + (col_index * row_length + row_index);
const MAT_KERNEL(float) *const k_lt = matrix + (row_index * col_length + col_index);
const MAT_KERNEL(float) *const k_rt =
has_right ? (matrix + ((col_index + 1) * row_length + row_index)) :
has_right ? (matrix + (row_index * col_length + (col_index + 1))) :
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
const MAT_KERNEL(float) *const k_lb =
has_bottom ? (matrix + (col_index * row_length + (row_index + 1))) :
has_bottom ? (matrix + ((row_index + 1) * col_length + col_index)) :
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
const MAT_KERNEL(float) *const k_rb =
(has_right && has_bottom) ?
(matrix + ((col_index + 1) * row_length + (row_index + 1))) :
(matrix + ((row_index + 1) * col_length + (col_index + 1))) :
(const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
register __m128 top128, bot128;
@@ -41,11 +41,18 @@ DECLARE_BUILD_PANEL(avx, float)
}
}
<<<<<<< HEAD
<<<<<<< HEAD
DECLARE_BUILD_PANEL(sse, float)
{
/* Single kernel -> 4 columns, each is one __m128 column vector. */
const MAT_KERNEL(float) *src = matrix + (col_index * row_length + row_index);
=======
DECLARE_BUILD_PANEL(sse, float)
{
/* Single kernel -> 4 columns, each is one __m128 column vector. */
const MAT_KERNEL(float) *src = matrix + (row_index * col_length + col_index);
>>>>>>> stgsharp-dev/giga
for (int pc = 0; pc < 4; ++pc) {
PANEL_COL_VEC((*panel), pc, 0) = src->xmm[pc];
@@ -55,22 +62,35 @@ DECLARE_BUILD_PANEL(sse, float)
DECLARE_BUILD_PANEL(512, float)
{
const MAT_KERNEL(float) *const zero = (const MAT_KERNEL(float) *)&SN_ZERO_KERNEL;
<<<<<<< HEAD
const MAT_KERNEL(float) *k[4][4];
=======
const MAT_KERNEL(float) * k[4][4];
>>>>>>> stgsharp-dev/giga
for (int kc = 0; kc < 4; ++kc) {
for (int kr = 0; kr < 4; ++kr) {
const int col = col_index + kc;
const int row = row_index + kr;
k[kc][kr] = (col < col_length && row < row_length) ?
<<<<<<< HEAD
(matrix + (col * row_length + row)) :
=======
(matrix + (row * col_length + col)) :
>>>>>>> stgsharp-dev/giga
zero;
}
}
/* Each panel column corresponds to a kernel column (0..3) within a block col (0..3). */
for (int pc = 0; pc < 16; ++pc) {
<<<<<<< HEAD
const int blk_col = pc >> 2; /* which kernel column block (0..3) */
const int kc_col = pc & 3; /* column inside a 4x4 kernel */
=======
const int blk_col = pc >> 2; /* which kernel column block (0..3) */
const int kc_col = pc & 3; /* column inside a 4x4 kernel */
>>>>>>> stgsharp-dev/giga
const __m128 r0 = k[blk_col][0]->xmm[kc_col];
const __m128 r1 = k[blk_col][1]->xmm[kc_col];
@@ -87,8 +107,11 @@ DECLARE_BUILD_PANEL(512, float)
}
}
<<<<<<< HEAD
=======
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
=======
>>>>>>> stgsharp-dev/giga
DECLARE_STORE_PANEL(avx, float)
{
const int Q = 8; /* fixed for AVX float panel */
@@ -100,19 +123,19 @@ DECLARE_STORE_PANEL(avx, float)
const int has_bottom = (row_index + 1) < row_length;
MAT_KERNEL(float) *const k_lt = (col_index < col_length && row_index < row_length) ?
(matrix + (col_index * row_length + row_index)) :
(matrix + (row_index * col_length + col_index)) :
&zero;
MAT_KERNEL(float) *const k_rt =
has_right && (row_index < row_length) ?
(matrix + ((col_index + 1) * row_length + row_index)) :
(matrix + (row_index * col_length + (col_index + 1))) :
&zero;
MAT_KERNEL(float) *const k_lb =
has_bottom && (col_index < col_length) ?
(matrix + (col_index * row_length + (row_index + 1))) :
(matrix + ((row_index + 1) * col_length + col_index)) :
&zero;
MAT_KERNEL(float) *const k_rb =
(has_right && has_bottom) ?
(matrix + ((col_index + 1) * row_length + (row_index + 1))) :
(matrix + ((row_index + 1) * col_length + (col_index + 1))) :
&zero;
register __m128 top128, bot128;
@@ -145,10 +168,17 @@ DECLARE_STORE_PANEL(avx, float)
}
}
<<<<<<< HEAD
<<<<<<< HEAD
DECLARE_STORE_PANEL(sse, float)
{
MAT_KERNEL(float) *dst = matrix + (col_index * row_length + row_index);
=======
DECLARE_STORE_PANEL(sse, float)
{
MAT_KERNEL(float) *dst = matrix + (row_index * col_length + col_index);
>>>>>>> stgsharp-dev/giga
for (int pc = 0; pc < 4; ++pc) {
const __m128 col = PANEL_COL_VEC((*panel), pc, 0);
@@ -159,21 +189,34 @@ DECLARE_STORE_PANEL(sse, float)
DECLARE_STORE_PANEL(512, float)
{
MAT_KERNEL(float) zero;
<<<<<<< HEAD
MAT_KERNEL(float) *k[4][4];
=======
MAT_KERNEL(float) * k[4][4];
>>>>>>> stgsharp-dev/giga
for (int kc = 0; kc < 4; ++kc) {
for (int kr = 0; kr < 4; ++kr) {
const int col = col_index + kc;
const int row = row_index + kr;
k[kc][kr] = (col < col_length && row < row_length) ?
<<<<<<< HEAD
(matrix + (col * row_length + row)) :
=======
(matrix + (row * col_length + col)) :
>>>>>>> stgsharp-dev/giga
&zero;
}
}
for (int pc = 0; pc < 16; ++pc) {
<<<<<<< HEAD
const int blk_col = pc >> 2; /* which kernel column block (0..3) */
const int kc_col = pc & 3; /* column inside a 4x4 kernel */
=======
const int blk_col = pc >> 2; /* which kernel column block (0..3) */
const int kc_col = pc & 3; /* column inside a 4x4 kernel */
>>>>>>> stgsharp-dev/giga
const __m512 col = PANEL_COL_VEC((*panel), pc, 0);
@@ -191,5 +234,8 @@ DECLARE_STORE_PANEL(512, float)
k[blk_col][3]->xmm[kc_col] = r3;
}
}
<<<<<<< HEAD
=======
>>>>>>> 7bcb460a3994dda40f24cae0044b5a36f4f16515
=======
>>>>>>> stgsharp-dev/giga