From 71ca954e3575d25bf287cb0d7dc7056e3f867b73 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 5 May 2025 15:24:35 +1000 Subject: [PATCH] Revert naming --- src/ImageSharp/Common/Helpers/SimdUtils.cs | 2 +- .../Formats/Jpeg/Components/Block8x8F.cs | 2 +- .../Jpeg/BlockOperations/Block8x8F_Round.cs | 48 +++++++++---------- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 4 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 950c8b33f..ea5a4c07e 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -38,7 +38,7 @@ internal static partial class SimdUtils /// /// The vector [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector RoundToNearestInteger(this Vector v) + internal static Vector FastRound(this Vector v) { if (Avx2.IsSupported && Vector.Count == Vector256.Count) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs index aa9249be5..018df5f9f 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs @@ -588,6 +588,6 @@ internal partial struct Block8x8F : IEquatable row += off; row = Vector.Max(row, Vector.Zero); row = Vector.Min(row, max); - return row.RoundToNearestInteger(); + return row.FastRound(); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs index 92faa50d2..1d8385168 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_Round.cs +++ b/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 row0 = ref Unsafe.As>(ref b.V0L); - row0 = row0.RoundToNearestInteger(); + row0 = row0.FastRound(); ref Vector row1 = ref Unsafe.As>(ref b.V1L); - row1 = row1.RoundToNearestInteger(); + row1 = row1.FastRound(); ref Vector row2 = ref Unsafe.As>(ref b.V2L); - row2 = row2.RoundToNearestInteger(); + row2 = row2.FastRound(); ref Vector row3 = ref Unsafe.As>(ref b.V3L); - row3 = row3.RoundToNearestInteger(); + row3 = row3.FastRound(); ref Vector row4 = ref Unsafe.As>(ref b.V4L); - row4 = row4.RoundToNearestInteger(); + row4 = row4.FastRound(); ref Vector row5 = ref Unsafe.As>(ref b.V5L); - row5 = row5.RoundToNearestInteger(); + row5 = row5.FastRound(); ref Vector row6 = ref Unsafe.As>(ref b.V6L); - row6 = row6.RoundToNearestInteger(); + row6 = row6.FastRound(); ref Vector row7 = ref Unsafe.As>(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(this.alignedPtr); ref Vector row0 = ref Unsafe.As>(ref b.V0L); - row0 = row0.RoundToNearestInteger(); + row0 = row0.FastRound(); ref Vector row1 = ref Unsafe.As>(ref b.V1L); - row1 = row1.RoundToNearestInteger(); + row1 = row1.FastRound(); ref Vector row2 = ref Unsafe.As>(ref b.V2L); - row2 = row2.RoundToNearestInteger(); + row2 = row2.FastRound(); ref Vector row3 = ref Unsafe.As>(ref b.V3L); - row3 = row3.RoundToNearestInteger(); + row3 = row3.FastRound(); ref Vector row4 = ref Unsafe.As>(ref b.V4L); - row4 = row4.RoundToNearestInteger(); + row4 = row4.FastRound(); ref Vector row5 = ref Unsafe.As>(ref b.V5L); - row5 = row5.RoundToNearestInteger(); + row5 = row5.FastRound(); ref Vector row6 = ref Unsafe.As>(ref b.V6L); - row6 = row6.RoundToNearestInteger(); + row6 = row6.FastRound(); ref Vector row7 = ref Unsafe.As>(ref b.V7L); - row7 = row7.RoundToNearestInteger(); + row7 = row7.FastRound(); } [Benchmark] @@ -117,20 +117,20 @@ public unsafe class Block8x8F_Round ref Vector row2 = ref Unsafe.As>(ref b.V2L); ref Vector row3 = ref Unsafe.As>(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>(ref b.V4L); row1 = ref Unsafe.As>(ref b.V5L); row2 = ref Unsafe.As>(ref b.V6L); row3 = ref Unsafe.As>(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] diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 77c9889ae..36b301264 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -73,7 +73,7 @@ public partial class SimdUtilsTests public void FastRound() { Vector v = CreateExactTestVector1(); - Vector r = v.RoundToNearestInteger(); + Vector 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 v = CreateRandomTestVector(seed, -scale * 0.5f, scale * 0.5f); - Vector r = v.RoundToNearestInteger(); + Vector r = v.FastRound(); this.Output.WriteLine(v.ToString()); this.Output.WriteLine(r.ToString());