Browse Source

Revert naming

pull/2917/head
James Jackson-South 9 months ago
parent
commit
71ca954e35
  1. 2
      src/ImageSharp/Common/Helpers/SimdUtils.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  3. 48
      tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs
  4. 4
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs

2
src/ImageSharp/Common/Helpers/SimdUtils.cs

@ -38,7 +38,7 @@ internal static partial class SimdUtils
/// </summary>
/// <param name="v">The vector</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static Vector<float> RoundToNearestInteger(this Vector<float> v)
internal static Vector<float> FastRound(this Vector<float> v)
{
if (Avx2.IsSupported && Vector<float>.Count == Vector256<float>.Count)
{

2
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

@ -588,6 +588,6 @@ internal partial struct Block8x8F : IEquatable<Block8x8F>
row += off;
row = Vector.Max(row, Vector<float>.Zero);
row = Vector.Min(row, max);
return row.RoundToNearestInteger();
return row.FastRound();
}
}

48
tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs

@ -67,21 +67,21 @@ public unsafe class Block8x8F_Round
ref Block8x8F b = ref this.block;
ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V0L);
row0 = row0.RoundToNearestInteger();
row0 = row0.FastRound();
ref Vector<float> row1 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V1L);
row1 = row1.RoundToNearestInteger();
row1 = row1.FastRound();
ref Vector<float> row2 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V2L);
row2 = row2.RoundToNearestInteger();
row2 = row2.FastRound();
ref Vector<float> row3 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V3L);
row3 = row3.RoundToNearestInteger();
row3 = row3.FastRound();
ref Vector<float> row4 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V4L);
row4 = row4.RoundToNearestInteger();
row4 = row4.FastRound();
ref Vector<float> row5 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V5L);
row5 = row5.RoundToNearestInteger();
row5 = row5.FastRound();
ref Vector<float> row6 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V6L);
row6 = row6.RoundToNearestInteger();
row6 = row6.FastRound();
ref Vector<float> row7 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V7L);
row7 = row7.RoundToNearestInteger();
row7 = row7.FastRound();
}
[Benchmark]
@ -90,21 +90,21 @@ public unsafe class Block8x8F_Round
ref Block8x8F b = ref Unsafe.AsRef<Block8x8F>(this.alignedPtr);
ref Vector<float> row0 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V0L);
row0 = row0.RoundToNearestInteger();
row0 = row0.FastRound();
ref Vector<float> row1 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V1L);
row1 = row1.RoundToNearestInteger();
row1 = row1.FastRound();
ref Vector<float> row2 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V2L);
row2 = row2.RoundToNearestInteger();
row2 = row2.FastRound();
ref Vector<float> row3 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V3L);
row3 = row3.RoundToNearestInteger();
row3 = row3.FastRound();
ref Vector<float> row4 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V4L);
row4 = row4.RoundToNearestInteger();
row4 = row4.FastRound();
ref Vector<float> row5 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V5L);
row5 = row5.RoundToNearestInteger();
row5 = row5.FastRound();
ref Vector<float> row6 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V6L);
row6 = row6.RoundToNearestInteger();
row6 = row6.FastRound();
ref Vector<float> row7 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V7L);
row7 = row7.RoundToNearestInteger();
row7 = row7.FastRound();
}
[Benchmark]
@ -117,20 +117,20 @@ public unsafe class Block8x8F_Round
ref Vector<float> row2 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V2L);
ref Vector<float> row3 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V3L);
row0 = row0.RoundToNearestInteger();
row1 = row1.RoundToNearestInteger();
row2 = row2.RoundToNearestInteger();
row3 = row3.RoundToNearestInteger();
row0 = row0.FastRound();
row1 = row1.FastRound();
row2 = row2.FastRound();
row3 = row3.FastRound();
row0 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V4L);
row1 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V5L);
row2 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V6L);
row3 = ref Unsafe.As<Vector4, Vector<float>>(ref b.V7L);
row0 = row0.RoundToNearestInteger();
row1 = row1.RoundToNearestInteger();
row2 = row2.RoundToNearestInteger();
row3 = row3.RoundToNearestInteger();
row0 = row0.FastRound();
row1 = row1.FastRound();
row2 = row2.FastRound();
row3 = row3.FastRound();
}
[Benchmark]

4
tests/ImageSharp.Tests/Common/SimdUtilsTests.cs

@ -73,7 +73,7 @@ public partial class SimdUtilsTests
public void FastRound()
{
Vector<float> v = CreateExactTestVector1();
Vector<float> r = v.RoundToNearestInteger();
Vector<float> r = v.FastRound();
this.Output.WriteLine(r.ToString());
@ -90,7 +90,7 @@ public partial class SimdUtilsTests
public void FastRound_RandomValues(int seed, float scale)
{
Vector<float> v = CreateRandomTestVector(seed, -scale * 0.5f, scale * 0.5f);
Vector<float> r = v.RoundToNearestInteger();
Vector<float> r = v.FastRound();
this.Output.WriteLine(v.ToString());
this.Output.WriteLine(r.ToString());

Loading…
Cancel
Save