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
26 changes: 26 additions & 0 deletions src/benchmarks/micro/MicroBenchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,32 @@
<Compile Remove="sve\FP64Overflow.cs" />
</ItemGroup>

<!-- Remove SVE microbenchmarks using the net11.0 CreateWhileLessThanMask API on older TFMs -->
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net11.0'))">
<Compile Remove="sve\Clamp.cs" />
<Compile Remove="sve\ComplexDotProduct.cs" />
<Compile Remove="sve\ComplexMultiply.cs" />
<Compile Remove="sve\Exponent.cs" />
<Compile Remove="sve\FastDivision.cs" />
<Compile Remove="sve\FP64Overflow.cs" />
<Compile Remove="sve\GatherLoad.cs" />
<Compile Remove="sve\Logarithm.cs" />
<Compile Remove="sve\MultiplyAdd.cs" />
<Compile Remove="sve\MultiplyPow2.cs" />
<Compile Remove="sve\OddEvenSort.cs" />
<Compile Remove="sve\PairwiseAdd.cs" />
<Compile Remove="sve\Partition.cs" />
<Compile Remove="sve\ScatterStore.cs" />
<Compile Remove="sve\SobelFilter.cs" />
<Compile Remove="sve\SquareRoot.cs" />
<Compile Remove="sve\StrCmp.cs" />
<Compile Remove="sve\StrIndexOf.cs" />
<Compile Remove="sve\StrLen.cs" />
<Compile Remove="sve\TCPChecksum.cs" />
<Compile Remove="sve\UpscaleFilter.cs" />
<Compile Remove="sve\VectorMax.cs" />
</ItemGroup>

<!-- This is not removing things from older Net versions, it is removing from newer Net versions -->
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' Or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<Compile Remove="libraries\System.Drawing\*.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/benchmarks/micro/sve/Clamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public unsafe void SveClamp()
Vector<int> valVec = new Vector<int>(Size / 2);
Vector<int> minVec = Vector<int>.Indices;
Vector<int> pTrue = Sve.CreateTrueMaskInt32();
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, length);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(i, length);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<int> maxVec = Sve.ShiftLeftLogical(minVec, Vector<uint>.One);
Expand All @@ -99,7 +99,7 @@ public unsafe void SveClamp()
minVec = Sve.Add(minVec, new Vector<int>(cntw));

i += cntw;
pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, length);
pLoop = Sve.CreateWhileLessThanMaskInt32(i, length);
}
_output = (int)Sve.AddAcross(resVec).ToScalar();
}
Expand All @@ -116,7 +116,7 @@ public unsafe void SveTail()
Vector<int> minVec = Vector<int>.Indices;
for (; i < length; i += cntw)
{
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, length);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(i, length);
Vector<int> maxVec = Sve.ShiftLeftLogical(minVec, Vector<uint>.One);
Vector<int> tmpVec = Sve.Min(Sve.Max(valVec, minVec), maxVec);
resVec = Sve.ConditionalSelect(pLoop, Sve.Add(resVec, tmpVec), resVec);
Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/micro/sve/ComplexDotProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public unsafe void SveComplexDotProduct()
// Create mask for the imaginary half of a word.
Vector<short> imMask = (Vector<short>)(new Vector<uint>(0xFFFF0000u));
Vector<int> pTrue = Sve.CreateTrueMaskInt32();
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
// Load inputs.
Expand Down Expand Up @@ -248,7 +248,7 @@ public unsafe void SveComplexDotProduct()

// Handle loop.
i += cntw;
pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskInt32(i, Size);
}
}
}
Expand All @@ -263,7 +263,7 @@ public unsafe void Sve2ComplexDotProduct()
int cntw = (int)Sve.Count32BitElements();

Vector<int> pTrue = Sve.CreateTrueMaskInt32();
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<sbyte> a1 = (Vector<sbyte>)Sve.LoadVector(pLoop, (int*)(a + 4 * i));
Expand All @@ -276,7 +276,7 @@ public unsafe void Sve2ComplexDotProduct()

// Handle loop.
i += cntw;
pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskInt32(i, Size);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/micro/sve/ComplexMultiply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public unsafe void SveComplexMultiply()

// Handle remaining elements using predicates.
lmt = Size * 2;
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(i, lmt);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(i, lmt);
if (Sve.TestFirstTrue(pTrue, pLoop))
{
// Compute the predicate for elements in i + cntw.
Vector<uint> pTail = Sve.CreateWhileLessThanMask32Bit(i + cntw, lmt);
Vector<uint> pTail = Sve.CreateWhileLessThanMaskUInt32(i + cntw, lmt);
// Unzip the predicates pLoop and pTail for 2xVector load/store.
Vector<uint> pInner = Sve.UnzipEven(pLoop, pTail);

Expand Down Expand Up @@ -190,7 +190,7 @@ public unsafe void Sve2ComplexMultiply()

// Handle remaining elements.
lmt = Size;
Vector<ulong> pLoop = Sve.CreateWhileLessThanMask64Bit(i, lmt);
Vector<ulong> pLoop = Sve.CreateWhileLessThanMaskUInt64(i, lmt);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<uint> a1 = (Vector<uint>)Sve2.LoadVector(pLoop, (ulong*)a + i);
Expand All @@ -201,7 +201,7 @@ public unsafe void Sve2ComplexMultiply()
Sve.StoreAndZip(pLoop, (ulong*)c + i, (Vector<ulong>)(c1));

i += cntd;
pLoop = Sve.CreateWhileLessThanMask64Bit(i, lmt);
pLoop = Sve.CreateWhileLessThanMaskUInt64(i, lmt);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/Exponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public unsafe void SveExponent()
Vector<float> constVec = new Vector<float>(new ReadOnlySpan<float>(&d[3], 4));

Vector<uint> pTrue = Sve.CreateTrueMaskUInt32();
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<float> x = (Vector<float>)Sve.LoadVector(pLoop, (uint*)(input + i));
Expand Down Expand Up @@ -197,7 +197,7 @@ public unsafe void SveExponent()

// Handle loop.
i += cntw;
pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/micro/sve/FP64Overflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public unsafe void SveFP64Overflow()
Vector<long> maskVec = new Vector<long>(1023);

Vector<ulong> pTrue = Sve.CreateTrueMaskUInt64();
Vector<ulong> pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
Vector<ulong> pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
// Load Vector<input1> as ulong then convert to Vector<double>.
Expand All @@ -178,7 +178,7 @@ public unsafe void SveFP64Overflow()

// Handle loop.
i += cntd;
pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
}
}
}
Expand All @@ -193,7 +193,7 @@ public unsafe void Sve2FP64Overflow()
int cntd = (int)Sve.Count64BitElements();

Vector<ulong> pTrue = Sve.CreateTrueMaskUInt64();
Vector<ulong> pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
Vector<ulong> pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
// Load input vectors.
Expand All @@ -214,7 +214,7 @@ public unsafe void Sve2FP64Overflow()

// Handle loop.
i += cntd;
pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/FastDivision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public unsafe void SveFastDivision()
int cntd = (int)Sve.Count64BitElements();

Vector<ulong> pTrue = Sve.CreateTrueMaskUInt64();
Vector<ulong> pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
Vector<ulong> pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<double> input1Vec = (Vector<double>)Sve.LoadVector(pLoop, (ulong*)input1 + i);
Expand All @@ -145,7 +145,7 @@ public unsafe void SveFastDivision()
Sve.StoreAndZip(pLoop, (ulong*)output + i, (Vector<ulong>)outVec);

i += cntd;
pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/GatherLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public unsafe void SveGatherLoad()

Vector<uint> resVec = Vector<uint>.Zero;
Vector<uint> pTrue = Sve.CreateTrueMaskUInt32();
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
// Load indices
Expand All @@ -91,7 +91,7 @@ public unsafe void SveGatherLoad()
resVec = Sve.Add(resVec, objVec);

i += cntw;
pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);
}
// Add up all elements in resVec.
uint res = (uint)Sve.AddAcross(resVec).ToScalar();
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/Logarithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public unsafe void SveLogarithm()

Vector<uint> pTrue = Sve.CreateTrueMaskUInt32();
Vector<float> pTruef = Sve.CreateTrueMaskSingle();
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<float> x = (Vector<float>)Sve.LoadVector(pLoop, (uint*)(input + i));
Expand Down Expand Up @@ -239,7 +239,7 @@ public unsafe void SveLogarithm()

// Handle loop.
i += cntw;
pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/MultiplyAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public unsafe void SveMultiplyAdd()

// Handle remaining elements using predicates.
lmt = Size;
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, lmt);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(i, lmt);
while (Sve.TestAnyTrue(pTrue, pLoop))
{
Vector<int> aVec = Sve.LoadVector(pLoop, a + i);
Expand All @@ -165,7 +165,7 @@ public unsafe void SveMultiplyAdd()

// Increment by a vector length.
i += cntw;
pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, lmt);
pLoop = Sve.CreateWhileLessThanMaskInt32(i, lmt);
}

// Sum up all elements in the 4 result vectors.
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/MultiplyPow2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public unsafe void SveMultiplyPow2()
int cntd = (int)Sve.Count64BitElements();

Vector<ulong> pTrue = Sve.CreateTrueMaskUInt64();
Vector<ulong> pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
Vector<ulong> pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
// Cast the array pointers to ulong so the predicate can be shared.
Expand All @@ -129,7 +129,7 @@ public unsafe void SveMultiplyPow2()

// Handle loop.
i += cntd;
pLoop = Sve.CreateWhileLessThanMask64Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt64(i, Size);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/OddEvenSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public unsafe void SveOddEvenSort()
for (; j < n - 1; j += (cntw << 1))
{
// Get predicate for elements to load/store.
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, (n - j) / 2);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, (n - j) / 2);
// Interleaved load elements.
(Vector<uint> a0, Vector<uint> a1) = Sve.Load2xVectorAndUnzip(pLoop, source + j);

Expand Down Expand Up @@ -248,7 +248,7 @@ public unsafe void SveTail()
// Handle tail using predicates.
for (; j < n - 1; j += (cntw << 1))
{
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, (n - j) / 2);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, (n - j) / 2);
(Vector<uint> a0, Vector<uint> a1) = Sve.Load2xVectorAndUnzip(pLoop, source + j);

Vector<uint> pCmp = Sve.ConditionalSelect(pLoop, Sve.CompareGreaterThan(a0, a1), Sve.CreateFalseMaskUInt32());
Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/micro/sve/PairwiseAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public unsafe void SvePairwiseAdd()

// Handle remaining elements using predicates.
lmt = Size * 2;
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, lmt);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(i, lmt);
if (Sve.TestFirstTrue(pTrue, pLoop))
{
// Compute the predicate for elements in i + cntw.
Vector<int> pTail = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i + cntw, lmt);
Vector<int> pTail = Sve.CreateWhileLessThanMaskInt32(i + cntw, lmt);
// Unzip the predicates pLoop and pTail for 2xVector load/store.
Vector<int> pInner = Sve.UnzipEven(pLoop, pTail);

Expand Down Expand Up @@ -181,15 +181,15 @@ public unsafe void Sve2PairwiseAdd()

// Handle remaining elements.
lmt = Size * 2;
Vector<int> pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, lmt);
Vector<int> pLoop = Sve.CreateWhileLessThanMaskInt32(i, lmt);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<int> a0 = Sve.LoadVector(pLoop, a + i);
Vector<int> b0 = Sve.LoadVector(pLoop, b + i);
Vector<int> c0 = Sve2.AddPairwise(a0, b0);
Sve.StoreAndZip(pLoop, c + i, c0);
i += cntw;
pLoop = (Vector<int>)Sve.CreateWhileLessThanMask32Bit(i, lmt);
pLoop = Sve.CreateWhileLessThanMaskInt32(i, lmt);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/Partition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public unsafe ulong SvePartition()
);

// Create a predicate for the loop.
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);

while (Sve.TestAnyTrue(Sve.CreateTrueMaskUInt32(), pLoop))
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public unsafe ulong SvePartition()
indexRight = Sve.SaturatingIncrementByActiveElementCount(indexRight, pInner);

i = Sve.SaturatingIncrementBy32BitElementCount(i, 1);
pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);
}

return indexRight;
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/micro/sve/ScatterStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public unsafe void SveScatterStore()

Vector<uint> ones = Vector<uint>.One;
Vector<uint> pTrue = Sve.CreateTrueMaskUInt32();
Vector<uint> pLoop = Sve.CreateWhileLessThanMask32Bit(0, Size);
Vector<uint> pLoop = Sve.CreateWhileLessThanMaskUInt32(0, Size);
while (Sve.TestFirstTrue(pTrue, pLoop))
{
Vector<uint> idxVec = Sve.LoadVector(pLoop, indices + i);
Expand All @@ -89,7 +89,7 @@ public unsafe void SveScatterStore()
Sve.Scatter(pLoop, objects, idxVec, ones);

i += cntw;
pLoop = Sve.CreateWhileLessThanMask32Bit(i, Size);
pLoop = Sve.CreateWhileLessThanMaskUInt32(i, Size);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/benchmarks/micro/sve/SobelFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public unsafe void SveSobelFilter()

Vector<float> resVec;
// Load coefficients of the filter into vectors.
Vector<float> kxVec = Sve.LoadVector((Vector<float>)Sve.CreateWhileLessThanMask32Bit(0, 3), kx);
Vector<float> kyVec = Sve.LoadVector((Vector<float>)Sve.CreateWhileLessThanMask32Bit(0, 3), ky);
Vector<float> kxVec = Sve.LoadVector(Sve.CreateWhileLessThanMaskSingle(0, 3), kx);
Vector<float> kyVec = Sve.LoadVector(Sve.CreateWhileLessThanMaskSingle(0, 3), ky);
for (int j = 0; j < img_size; j++)
{
// Load the elements from input and output the intermediate result to temp.
Expand All @@ -205,7 +205,7 @@ public unsafe void SveSobelFilter()

for (int i = 0; i < out_size; i += cntw)
{
Vector<float> pRow = (Vector<float>)Sve.CreateWhileLessThanMask32Bit(i, out_size);
Vector<float> pRow = Sve.CreateWhileLessThanMaskSingle(i, out_size);

// Load input elements from the next 3 columns.
Vector<float> col0 = Sve.LoadVector(pRow, in_ptr + i);
Expand All @@ -228,7 +228,7 @@ public unsafe void SveSobelFilter()

for (int i = 0; i < out_size; i += cntw)
{
Vector<float> pRow = (Vector<float>)Sve.CreateWhileLessThanMask32Bit(i, out_size);
Vector<float> pRow = Sve.CreateWhileLessThanMaskSingle(i, out_size);

// Load input elements from the next 3 rows.
Vector<float> row0 = Sve.LoadVector(pRow, in_ptr + i);
Expand Down
Loading
Loading