Add all 4 variations of the SBGEMM to compare_sgemm_sbgemm

This commit is contained in:
Chip Kerchner 2024-07-10 13:07:48 -05:00
parent cb154832f8
commit f708944fea
1 changed files with 58 additions and 34 deletions

View File

@ -86,7 +86,7 @@ main (int argc, char *argv[])
{
blasint m, n, k;
int i, j, l;
blasint x;
blasint x, y;
int ret = 0;
int loop = 100;
char transA = 'N', transB = 'N';
@ -94,6 +94,18 @@ main (int argc, char *argv[])
for (x = 0; x <= loop; x++)
{
for (y = 0; y < 4; y++)
{
if ((y == 0) || (y == 2)) {
transA = 'N';
} else {
transA = 'T';
}
if ((y == 0) || (y == 1)) {
transB = 'N';
} else {
transB = 'T';
}
m = k = n = x;
float A[m * k];
float B[k * n];
@ -126,14 +138,25 @@ main (int argc, char *argv[])
for (j = 0; j < m; j++)
if (fabs (CC[i * m + j] - C[i * m + j]) > 1.0)
ret++;
if (transA == 'N' && transB == 'N')
{
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
for (l = 0; l < k; l++)
if (transA == 'N' && transB == 'N')
{
DD[i * m + j] +=
float16to32 (AA[l * m + j]) * float16to32 (BB[l + k * i]);
} else if (transA == 'T' && transB == 'N')
{
DD[i * m + j] +=
float16to32 (AA[k * j + l]) * float16to32 (BB[l + k * i]);
} else if (transA == 'N' && transB == 'T')
{
DD[i * m + j] +=
float16to32 (AA[l * m + j]) * float16to32 (BB[i + l * n]);
} else if (transA == 'T' && transB == 'T')
{
DD[i * m + j] +=
float16to32 (AA[k * j + l]) * float16to32 (BB[i + l * n]);
}
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
@ -141,6 +164,7 @@ main (int argc, char *argv[])
ret++;
}
}
if (ret != 0)
fprintf (stderr, "FATAL ERROR SBGEMM - Return code: %d\n", ret);
return ret;