Skip to content

Commit 0caf143

Browse files
author
Wang, Long
committed
Fix the integer overflow issue for large matrix size
For large matrix, e.g. M=N=K, and M>1290, int mnk=M*N*K will overflow. This will lead to wrong branching to single-threading. The performance is downgraded significantly. Signed-off-by: Wang, Long <long1.wang@intel.com>
1 parent 73128f3 commit 0caf143

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

kernel/x86_64/sgemm_kernel_16x4_skylakex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ CNAME(BLASLONG m, BLASLONG n, BLASLONG k, float alpha, float * __restrict A, flo
12151215

12161216
int sgemm_kernel_direct_performant(BLASLONG M, BLASLONG N, BLASLONG K)
12171217
{
1218-
int mnk = M * N * K;
1218+
unsigned long mnk = M * N * K;
12191219
/* large matrixes -> not performant */
12201220
if (mnk >= 28 * 512 * 512)
12211221
return 0;

kernel/x86_64/sgemm_kernel_16x4_skylakex_2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ CNAME(BLASLONG m, BLASLONG n, BLASLONG k, float alpha, float * __restrict__ A, f
452452

453453
int sgemm_kernel_direct_performant(BLASLONG M, BLASLONG N, BLASLONG K)
454454
{
455-
int mnk = M * N * K;
455+
unsigned long mnk = M * N * K;
456456
/* large matrixes -> not performant */
457457
if (mnk >= 28 * 512 * 512)
458458
return 0;

0 commit comments

Comments
 (0)