Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/compare_sgemm_bgemm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ main (int argc, char *argv[])
blasint x, y;
blasint one = 1;
int ret = 0;
int ret2 = 0;
int loop = BGEMM_LARGEST;
char transA = 'N', transB = 'N';
float alpha = 1.0, beta = 1.0;
Expand Down Expand Up @@ -143,6 +144,7 @@ main (int argc, char *argv[])
printf("Mismatch at i=%d, j=%d, k=%d: CC=%.6f, DD=%.6f\n",
i, j, k, float16to32(CC[i * m + j]), truncate_float32_to_bfloat16(DD[i * m + j]));
#endif
ret2++;
ret++;
}

Expand All @@ -158,7 +160,7 @@ main (int argc, char *argv[])
}

if (ret != 0) {
fprintf(stderr, "BGEMM FAILURES: %d\n", ret);
fprintf(stderr, "BGEMM FAILURES: %d (%d of which in comparison to naive loop)\n", ret,ret2);
return 1;
}

Expand Down
14 changes: 9 additions & 5 deletions test/compare_sgemm_shgemm.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ main (int argc, char *argv[])
(float)AA[k * j + l] * (float)BB[i + l * n];
}
if (!is_close(CC[i * m + j], C[i * m + j], 0.01, 0.001)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really an absolute difference (AKA 0.01)? I would think the difference would be related to the maximum value in the output?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.01 plus C scaled by 0.001 like I wrote in the ticket - not sure if ARM's "Mousius" came up with this, or if he just copied it from an existing test

Copy link
Copy Markdown
Contributor

@ChipKerchner ChipKerchner Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scaled should probably be at least 8 times bigger than the BF16 version since there are 3 less bits in the fraction. So I think 0.01 for the scale value might work. Same for BGEMM

fprintf(stderr,"CC %f C %f \n",(float)CC[i*m+j],C[i*m+j]);
ret++;
#ifdef DEBUG
fprintf(stderr,"CC %f C %f \n",(float)CC[i*m+j],C[i*m+j]);
#endif
ret++;
}
if (!is_close(CC[i * m + j], DD[i * m + j], 0.001, 0.0001)) {
fprintf(stderr,"CC %f DD %f \n",(float)CC[i*m+j],(float)DD[i*m+j]);
ret++;
if (!is_close(CC[i * m + j], DD[i * m + j], 0.01, 0.001)) {
#ifdef DEBUG
fprintf(stderr,"CC %f DD %f \n",(float)CC[i*m+j],(float)DD[i*m+j]);
#endif
ret++;
}
}
}
Expand Down
Loading