diff --git a/test/Microsoft.ML.CpuMath.PerformanceTests/AvxPerformanceTests.cs b/test/Microsoft.ML.CpuMath.PerformanceTests/AvxPerformanceTests.cs index 2e4b598540..b4b1cf65fd 100644 --- a/test/Microsoft.ML.CpuMath.PerformanceTests/AvxPerformanceTests.cs +++ b/test/Microsoft.ML.CpuMath.PerformanceTests/AvxPerformanceTests.cs @@ -12,137 +12,92 @@ namespace Microsoft.ML.CpuMath.PerformanceTests public class AvxPerformanceTests : PerformanceTests { [Benchmark] - public void ManagedAddScalarUPerf() - { - AvxIntrinsics.AddScalarU(DEFAULT_SCALE, new Span(dst, 0, LEN)); - } + public void AddScalarU() + => AvxIntrinsics.AddScalarU(DEFAULT_SCALE, new Span(dst, 0, LEN)); [Benchmark] - public void ManagedScaleUPerf() - { - AvxIntrinsics.ScaleU(DEFAULT_SCALE, new Span(dst, 0, LEN)); - } + public void ScaleU() + => AvxIntrinsics.ScaleU(DEFAULT_SCALE, new Span(dst, 0, LEN)); [Benchmark] - public void ManagedScaleSrcUPerf() - { - AvxIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public void ScaleSrcU() + => AvxIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedScaleAddUPerf() - { - AvxIntrinsics.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, new Span(dst, 0, LEN)); - } + public void ScaleAddU() + => AvxIntrinsics.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, new Span(dst, 0, LEN)); [Benchmark] - public void ManagedAddScaleUPerf() - { - AvxIntrinsics.AddScaleU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public void AddScaleU() + => AvxIntrinsics.AddScaleU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedAddScaleSUPerf() - { - AvxIntrinsics.AddScaleSU(DEFAULT_SCALE, new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); - } + public void AddScaleSU() + => AvxIntrinsics.AddScaleSU(DEFAULT_SCALE, new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); [Benchmark] - public void ManagedAddScaleCopyUPerf() - { - AvxIntrinsics.AddScaleCopyU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN), new Span(result, 0, LEN)); - } + public void AddScaleCopyU() + => AvxIntrinsics.AddScaleCopyU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN), new Span(result, 0, LEN)); [Benchmark] - public void ManagedAddUPerf() - { - AvxIntrinsics.AddU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public void AddU() + => AvxIntrinsics.AddU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedAddSUPerf() - { - AvxIntrinsics.AddSU(new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); - } - + public void AddSU() + => AvxIntrinsics.AddSU(new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); [Benchmark] - public void ManagedMulElementWiseUPerf() - { - AvxIntrinsics.MulElementWiseU(new Span(src1, 0, LEN), new Span(src2, 0, LEN), + public void MulElementWiseU() + => AvxIntrinsics.MulElementWiseU(new Span(src1, 0, LEN), new Span(src2, 0, LEN), new Span(dst, 0, LEN)); - } [Benchmark] - public float ManagedSumUPerf() - { - return AvxIntrinsics.SumU(new Span(src, 0, LEN)); - } + public float SumU() + => AvxIntrinsics.SumU(new Span(src, 0, LEN)); [Benchmark] - public float ManagedSumSqUPerf() - { - return AvxIntrinsics.SumSqU(new Span(src, 0, LEN)); - } + public float SumSqU() + => AvxIntrinsics.SumSqU(new Span(src, 0, LEN)); [Benchmark] - public float ManagedSumSqDiffUPerf() - { - return AvxIntrinsics.SumSqDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } + public float SumSqDiffU() + => AvxIntrinsics.SumSqDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); [Benchmark] - public float ManagedSumAbsUPerf() - { - return AvxIntrinsics.SumAbsU(new Span(src, 0, LEN)); - } + public float SumAbsU() + => AvxIntrinsics.SumAbsU(new Span(src, 0, LEN)); [Benchmark] - public float ManagedSumAbsDiffUPerf() - { - return AvxIntrinsics.SumAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } + public float SumAbsDiffU() + => AvxIntrinsics.SumAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); [Benchmark] - public float ManagedMaxAbsUPerf() - { - return AvxIntrinsics.MaxAbsU(new Span(src, 0, LEN)); - } + public float MaxAbsU() + => AvxIntrinsics.MaxAbsU(new Span(src, 0, LEN)); [Benchmark] - public float ManagedMaxAbsDiffUPerf() - { - return AvxIntrinsics.MaxAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } + public float MaxAbsDiffU() + => AvxIntrinsics.MaxAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); [Benchmark] - public float ManagedDotUPerf() - { - return AvxIntrinsics.DotU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public float DotU() + => AvxIntrinsics.DotU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public float ManagedDotSUPerf() - { - return AvxIntrinsics.DotSU(new Span(src), new Span(dst), new Span(idx, 0, IDXLEN)); - } + public float DotSU() + => AvxIntrinsics.DotSU(new Span(src), new Span(dst), new Span(idx, 0, IDXLEN)); [Benchmark] - public float ManagedDist2Perf() - { - return AvxIntrinsics.Dist2(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public float Dist2() + => AvxIntrinsics.Dist2(new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedSdcaL1UpdateUPerf() - { - AvxIntrinsics.SdcaL1UpdateU(DEFAULT_SCALE, new Span(src, 0, LEN), DEFAULT_SCALE, new Span(dst, 0, LEN), new Span(result, 0, LEN)); - } + public void SdcaL1UpdateU() + => AvxIntrinsics.SdcaL1UpdateU(DEFAULT_SCALE, new Span(src, 0, LEN), DEFAULT_SCALE, new Span(dst, 0, LEN), new Span(result, 0, LEN)); [Benchmark] - public void ManagedSdcaL1UpdateSUPerf() - { - AvxIntrinsics.SdcaL1UpdateSU(DEFAULT_SCALE, new Span(src, 0, IDXLEN), new Span(idx, 0, IDXLEN), DEFAULT_SCALE, new Span(dst), new Span(result)); - } + public void SdcaL1UpdateSU() + => AvxIntrinsics.SdcaL1UpdateSU(DEFAULT_SCALE, new Span(src, 0, IDXLEN), new Span(idx, 0, IDXLEN), DEFAULT_SCALE, new Span(dst), new Span(result)); } } diff --git a/test/Microsoft.ML.CpuMath.PerformanceTests/NativePerformanceTests.cs b/test/Microsoft.ML.CpuMath.PerformanceTests/NativePerformanceTests.cs new file mode 100644 index 0000000000..b7eb3d233a --- /dev/null +++ b/test/Microsoft.ML.CpuMath.PerformanceTests/NativePerformanceTests.cs @@ -0,0 +1,232 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Running; +using Microsoft.ML.Runtime.Internal.CpuMath; + +namespace Microsoft.ML.CpuMath.PerformanceTests +{ + public class NativePerformanceTests : PerformanceTests + { + [Benchmark] + public unsafe void AddScalarU() + { + fixed (float* pdst = dst) + { + CpuMathNativeUtils.AddScalarU(DEFAULT_SCALE, pdst, LEN); + } + } + + [Benchmark] + public unsafe void ScaleU() + { + fixed (float* pdst = dst) + { + CpuMathNativeUtils.ScaleU(DEFAULT_SCALE, pdst, LEN); + } + } + + [Benchmark] + public unsafe void ScaleSrcU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + { + CpuMathNativeUtils.ScaleSrcU(DEFAULT_SCALE, psrc, pdst, LEN); + } + } + + [Benchmark] + public unsafe void ScaleAddU() + { + fixed (float* pdst = dst) + { + CpuMathNativeUtils.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, pdst, LEN); + } + } + + [Benchmark] + public unsafe void AddScaleU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + { + CpuMathNativeUtils.AddScaleU(DEFAULT_SCALE, psrc, pdst, LEN); + } + } + + [Benchmark] + public unsafe void AddScaleSU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (int* pidx = idx) + { + CpuMathNativeUtils.AddScaleSU(DEFAULT_SCALE, psrc, pidx, pdst, IDXLEN); + } + } + + [Benchmark] + public unsafe void AddScaleCopyU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (float* pres = result) + { + CpuMathNativeUtils.AddScaleCopyU(DEFAULT_SCALE, psrc, pdst, pres, LEN); + } + } + + [Benchmark] + public unsafe void AddU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + { + CpuMathNativeUtils.AddU(psrc, pdst, LEN); + } + } + + [Benchmark] + public unsafe void AddSU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (int* pidx = idx) + { + CpuMathNativeUtils.AddSU(psrc, pidx, pdst, IDXLEN); + } + } + + [Benchmark] + public unsafe void MulElementWiseU() + { + fixed (float* psrc1 = src1) + fixed (float* psrc2 = src2) + fixed (float* pdst = dst) + { + CpuMathNativeUtils.MulElementWiseU(psrc1, psrc2, pdst, LEN); + } + } + + [Benchmark] + public unsafe float SumU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.SumU(psrc, LEN); + } + } + + [Benchmark] + public unsafe float SumSqU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.SumSqU(psrc, LEN); + } + } + + [Benchmark] + public unsafe float SumSqDiffU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.SumSqDiffU(DEFAULT_SCALE, psrc, LEN); + } + } + + [Benchmark] + public unsafe float SumAbsU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.SumAbsU(psrc, LEN); + } + } + + [Benchmark] + public unsafe float SumAbsDiffU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.SumAbsDiffU(DEFAULT_SCALE, psrc, LEN); + } + } + + [Benchmark] + public unsafe float MaxAbsU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.MaxAbsU(psrc, LEN); + } + } + + [Benchmark] + public unsafe float MaxAbsDiffU() + { + fixed (float* psrc = src) + { + return CpuMathNativeUtils.MaxAbsDiffU(DEFAULT_SCALE, psrc, LEN); + } + } + + [Benchmark] + public unsafe float DotU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + { + return CpuMathNativeUtils.DotU(psrc, pdst, LEN); + } + } + + [Benchmark] + public unsafe float DotSU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (int* pidx = idx) + { + return CpuMathNativeUtils.DotSU(psrc, pdst, pidx, IDXLEN); + } + } + + [Benchmark] + public unsafe float Dist2() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + { + return CpuMathNativeUtils.Dist2(psrc, pdst, LEN); + } + } + + [Benchmark] + public unsafe void SdcaL1UpdateU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (float* pres = result) + { + CpuMathNativeUtils.SdcaL1UpdateU(DEFAULT_SCALE, psrc, DEFAULT_SCALE, pdst, pres, LEN); + } + } + + [Benchmark] + public unsafe void SdcaL1UpdateSU() + { + fixed (float* psrc = src) + fixed (float* pdst = dst) + fixed (float* pres = result) + fixed (int* pidx = idx) + { + CpuMathNativeUtils.SdcaL1UpdateSU(DEFAULT_SCALE, psrc, pidx, DEFAULT_SCALE, pdst, pres, IDXLEN); + } + } + } +} diff --git a/test/Microsoft.ML.CpuMath.PerformanceTests/Program.cs b/test/Microsoft.ML.CpuMath.PerformanceTests/Program.cs index 77656178c8..9ff474a9a1 100644 --- a/test/Microsoft.ML.CpuMath.PerformanceTests/Program.cs +++ b/test/Microsoft.ML.CpuMath.PerformanceTests/Program.cs @@ -2,6 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Running; +using BenchmarkDotNet.Toolchains.InProcess; + namespace Microsoft.ML.CpuMath.PerformanceTests { class Program @@ -13,7 +18,7 @@ public static void Main(string[] args) private static IConfig CreateCustomConfig() => DefaultConfig.Instance - .With(Job.ShortRun + .With(Job.Default .With(InProcessToolchain.Instance)); } } diff --git a/test/Microsoft.ML.CpuMath.PerformanceTests/SsePerformanceTests.cs b/test/Microsoft.ML.CpuMath.PerformanceTests/SsePerformanceTests.cs index 3188c64db9..21eb840bdc 100644 --- a/test/Microsoft.ML.CpuMath.PerformanceTests/SsePerformanceTests.cs +++ b/test/Microsoft.ML.CpuMath.PerformanceTests/SsePerformanceTests.cs @@ -12,355 +12,92 @@ namespace Microsoft.ML.CpuMath.PerformanceTests public class SsePerformanceTests : PerformanceTests { [Benchmark] - public unsafe void NativeAddScalarUPerf() - { - fixed (float* pdst = dst) - { - CpuMathNativeUtils.AddScalarU(DEFAULT_SCALE, pdst, LEN); - } - } - - [Benchmark] - public void ManagedAddScalarUPerf() - { - SseIntrinsics.AddScalarU(DEFAULT_SCALE, new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeScaleUPerf() - { - fixed (float* pdst = dst) - { - CpuMathNativeUtils.ScaleU(DEFAULT_SCALE, pdst, LEN); - } - } - - [Benchmark] - public void ManagedScaleUPerf() - { - SseIntrinsics.ScaleU(DEFAULT_SCALE, new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeScaleSrcUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - { - CpuMathNativeUtils.ScaleSrcU(DEFAULT_SCALE, psrc, pdst, LEN); - } - } - - [Benchmark] - public void ManagedScaleSrcUPerf() - { - SseIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeScaleAddUPerf() - { - fixed (float* pdst = dst) - { - CpuMathNativeUtils.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, pdst, LEN); - } - } - - [Benchmark] - public void ManagedScaleAddUPerf() - { - SseIntrinsics.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeAddScaleUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - { - CpuMathNativeUtils.AddScaleU(DEFAULT_SCALE, psrc, pdst, LEN); - } - } - - [Benchmark] - public void ManagedAddScaleUPerf() - { - SseIntrinsics.AddScaleU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeAddScaleSUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (int* pidx = idx) - { - CpuMathNativeUtils.AddScaleSU(DEFAULT_SCALE, psrc, pidx, pdst, IDXLEN); - } - } - + public void AddScalarU() + => SseIntrinsics.AddScalarU(DEFAULT_SCALE, new Span(dst, 0, LEN)); + [Benchmark] - public void ManagedAddScaleSUPerf() - { - SseIntrinsics.AddScaleSU(DEFAULT_SCALE, new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); - } - + public void ScaleU() + => SseIntrinsics.ScaleU(DEFAULT_SCALE, new Span(dst, 0, LEN)); + [Benchmark] - public unsafe void NativeAddScaleCopyUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (float* pres = result) - { - CpuMathNativeUtils.AddScaleCopyU(DEFAULT_SCALE, psrc, pdst, pres, LEN); - } - } + public void ScaleSrcU() + => SseIntrinsics.ScaleSrcU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedAddScaleCopyUPerf() - { - SseIntrinsics.AddScaleCopyU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN), new Span(result, 0, LEN)); - } - + public void ScaleAddU() + => SseIntrinsics.ScaleAddU(DEFAULT_SCALE, DEFAULT_SCALE, new Span(dst, 0, LEN)); + [Benchmark] - public unsafe void NativeAddUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - { - CpuMathNativeUtils.AddU(psrc, pdst, LEN); - } - } + public void AddScaleU() + => SseIntrinsics.AddScaleU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public void ManagedAddUPerf() - { - SseIntrinsics.AddU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } + public void AddScaleSU() + => SseIntrinsics.AddScaleSU(DEFAULT_SCALE, new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); [Benchmark] - public unsafe void NativeAddSUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (int* pidx = idx) - { - CpuMathNativeUtils.AddSU(psrc, pidx, pdst, IDXLEN); - } - } + public void AddScaleCopyU() + => SseIntrinsics.AddScaleCopyU(DEFAULT_SCALE, new Span(src, 0, LEN), new Span(dst, 0, LEN), new Span(result, 0, LEN)); [Benchmark] - public void ManagedAddSUPerf() - { - SseIntrinsics.AddSU(new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); - } - + public void AddU() + => SseIntrinsics.AddU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public unsafe void NativeMulElementWiseUPerf() - { - fixed (float* psrc1 = src1) - fixed (float* psrc2 = src2) - fixed (float* pdst = dst) - { - CpuMathNativeUtils.MulElementWiseU(psrc1, psrc2, pdst, LEN); - } - } + public void AddSU() + => SseIntrinsics.AddSU(new Span(src), new Span(idx, 0, IDXLEN), new Span(dst)); [Benchmark] - public void ManagedMulElementWiseUPerf() - { - SseIntrinsics.MulElementWiseU(new Span(src1, 0, LEN), new Span(src2, 0, LEN), + public void MulElementWiseU() + => SseIntrinsics.MulElementWiseU(new Span(src1, 0, LEN), new Span(src2, 0, LEN), new Span(dst, 0, LEN)); - } [Benchmark] - public unsafe float NativeSumUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.SumU(psrc, LEN); - } - } + public float SumU() + => SseIntrinsics.SumU(new Span(src, 0, LEN)); [Benchmark] - public float ManagedSumUPerf() - { - return SseIntrinsics.SumU(new Span(src, 0, LEN)); - } - + public float SumSqU() + => SseIntrinsics.SumSqU(new Span(src, 0, LEN)); + [Benchmark] - public unsafe float NativeSumSqUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.SumSqU(psrc, LEN); - } - } - + public float SumSqDiffU() + => SseIntrinsics.SumSqDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); + [Benchmark] - public float ManagedSumSqUPerf() - { - return SseIntrinsics.SumSqU(new Span(src, 0, LEN)); - } + public float SumAbsU() + => SseIntrinsics.SumAbsU(new Span(src, 0, LEN)); [Benchmark] - public unsafe float NativeSumSqDiffUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.SumSqDiffU(DEFAULT_SCALE, psrc, LEN); - } - } - + public float SumAbsDiffU() + => SseIntrinsics.SumAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); + [Benchmark] - public float ManagedSumSqDiffUPerf() - { - return SseIntrinsics.SumSqDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } - + public float MaxAbsU() + => SseIntrinsics.MaxAbsU(new Span(src, 0, LEN)); + [Benchmark] - public unsafe float NativeSumAbsUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.SumAbsU(psrc, LEN); - } - } - - [Benchmark] - public float ManagedSumAbsUPerf() - { - return SseIntrinsics.SumAbsU(new Span(src, 0, LEN)); - } - - [Benchmark] - public unsafe float NativeSumAbsDiffUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.SumAbsDiffU(DEFAULT_SCALE, psrc, LEN); - } - } - - [Benchmark] - public float ManagedSumAbsDiffUPerf() - { - return SseIntrinsics.SumAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } - + public float MaxAbsDiffU() + => SseIntrinsics.MaxAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); + [Benchmark] - public unsafe float NativeMaxAbsUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.MaxAbsU(psrc, LEN); - } - } - - [Benchmark] - public float ManagedMaxAbsUPerf() - { - return SseIntrinsics.MaxAbsU(new Span(src, 0, LEN)); - } - - [Benchmark] - public unsafe float NativeMaxAbsDiffUPerf() - { - fixed (float* psrc = src) - { - return CpuMathNativeUtils.MaxAbsDiffU(DEFAULT_SCALE, psrc, LEN); - } - } - - [Benchmark] - public float ManagedMaxAbsDiffUPerf() - { - return SseIntrinsics.MaxAbsDiffU(DEFAULT_SCALE, new Span(src, 0, LEN)); - } - + public float DotU() + => SseIntrinsics.DotU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); + [Benchmark] - public unsafe float NativeDotUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - { - return CpuMathNativeUtils.DotU(psrc, pdst, LEN); - } - } - - [Benchmark] - public float ManagedDotUPerf() - { - return SseIntrinsics.DotU(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe float NativeDotSUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (int* pidx = idx) - { - return CpuMathNativeUtils.DotSU(psrc, pdst, pidx, IDXLEN); - } - } - - [Benchmark] - public float ManagedDotSUPerf() - { - return SseIntrinsics.DotSU(new Span(src), new Span(dst), new Span(idx, 0, IDXLEN)); - } - - [Benchmark] - public unsafe float NativeDist2Perf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - { - return CpuMathNativeUtils.Dist2(psrc, pdst, LEN); - } - } - - [Benchmark] - public float ManagedDist2Perf() - { - return SseIntrinsics.Dist2(new Span(src, 0, LEN), new Span(dst, 0, LEN)); - } - - [Benchmark] - public unsafe void NativeSdcaL1UpdateUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (float* pres = result) - { - CpuMathNativeUtils.SdcaL1UpdateU(DEFAULT_SCALE, psrc, DEFAULT_SCALE, pdst, pres, LEN); - } - } - + public float DotSU() + => SseIntrinsics.DotSU(new Span(src), new Span(dst), new Span(idx, 0, IDXLEN)); + [Benchmark] - public void ManagedSdcaL1UpdateUPerf() - { - SseIntrinsics.SdcaL1UpdateU(DEFAULT_SCALE, new Span(src, 0, LEN), DEFAULT_SCALE, new Span(dst, 0, LEN), new Span(result, 0, LEN)); - } + public float Dist2() + => SseIntrinsics.Dist2(new Span(src, 0, LEN), new Span(dst, 0, LEN)); [Benchmark] - public unsafe void NativeSdcaL1UpdateSUPerf() - { - fixed (float* psrc = src) - fixed (float* pdst = dst) - fixed (float* pres = result) - fixed (int* pidx = idx) - { - CpuMathNativeUtils.SdcaL1UpdateSU(DEFAULT_SCALE, psrc, pidx, DEFAULT_SCALE, pdst, pres, IDXLEN); - } - } + public void SdcaL1UpdateU() + => SseIntrinsics.SdcaL1UpdateU(DEFAULT_SCALE, new Span(src, 0, LEN), DEFAULT_SCALE, new Span(dst, 0, LEN), new Span(result, 0, LEN)); [Benchmark] - public void ManagedSdcaL1UpdateSUPerf() - { - SseIntrinsics.SdcaL1UpdateSU(DEFAULT_SCALE, new Span(src, 0, IDXLEN), new Span(idx, 0, IDXLEN), DEFAULT_SCALE, new Span(dst), new Span(result)); - } + public void SdcaL1UpdateSU() + => SseIntrinsics.SdcaL1UpdateSU(DEFAULT_SCALE, new Span(src, 0, IDXLEN), new Span(idx, 0, IDXLEN), DEFAULT_SCALE, new Span(dst), new Span(result)); } }