Skip to content

Commit 3b9d407

Browse files
authored
Minimum Vector size check added (#2428)
* Minimum size check added * aggressive inlining added * precision corrected * MinVectorSize => MinInputSize * adam approach * tanners feedback * increasing array sizes to test all 3 paths * checking sse is supported is good enough check * Test for non-accelerated path
1 parent 6077e18 commit 3b9d407

File tree

9 files changed

+260
-289
lines changed

9 files changed

+260
-289
lines changed

src/Microsoft.ML.CpuMath/AvxIntrinsics.cs

-37
Original file line numberDiff line numberDiff line change
@@ -466,22 +466,6 @@ public static unsafe void Scale(float scale, Span<float> dst)
466466
int length = dst.Length;
467467
Vector256<float> scaleVector256 = Vector256.Create(scale);
468468

469-
if (length < 8)
470-
{
471-
// Handle cases where we have less than 256-bits total and can't ever use SIMD acceleration.
472-
switch (length)
473-
{
474-
case 7: dst[6] *= scale; goto case 6;
475-
case 6: dst[5] *= scale; goto case 5;
476-
case 5: dst[4] *= scale; goto case 4;
477-
case 4: dst[3] *= scale; goto case 3;
478-
case 3: dst[2] *= scale; goto case 2;
479-
case 2: dst[1] *= scale; goto case 1;
480-
case 1: dst[0] *= scale; break;
481-
}
482-
return;
483-
}
484-
485469
nuint address = (nuint)(pd);
486470
int misalignment = (int)(address % 32);
487471
int remainder = 0;
@@ -993,27 +977,6 @@ public static unsafe float Sum(ReadOnlySpan<float> src)
993977
{
994978
float* pValues = pSrc;
995979
int length = src.Length;
996-
997-
if (length < 8)
998-
{
999-
// Handle cases where we have less than 256-bits total and can't ever use SIMD acceleration.
1000-
1001-
float res = 0;
1002-
1003-
switch (length)
1004-
{
1005-
case 7: res += pValues[6]; goto case 6;
1006-
case 6: res += pValues[5]; goto case 5;
1007-
case 5: res += pValues[4]; goto case 4;
1008-
case 4: res += pValues[3]; goto case 3;
1009-
case 3: res += pValues[2]; goto case 2;
1010-
case 2: res += pValues[1]; goto case 1;
1011-
case 1: res += pValues[0]; break;
1012-
}
1013-
1014-
return res;
1015-
}
1016-
1017980
Vector256<float> result = Vector256<float>.Zero;
1018981

1019982
nuint address = (nuint)(pValues);

0 commit comments

Comments
 (0)