mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Box Simd (#6193)
* Box Simd * Add 256 bit version of GetAABB * Add AABB bechmarks * No real diff between 128 & 256, so removing 256 | Method | Mean | Error | StdDev | Ratio | |----------- |----------:|----------:|----------:|------:| | GetAABB | 5.8107 ns | 0.0154 ns | 0.0137 ns | 1.00 | | GetAABB128 | 0.4927 ns | 0.0003 ns | 0.0002 ns | 0.08 | | GetAABB256 | 0.4332 ns | 0.0006 ns | 0.0006 ns | 0.07 | * Add Box2Rotated.Transform Benchmark * Results 20% faster and much smaller code. Also I don't think it inlined RotateVec * Add Matrix3x2Helper.TransformBox() benchmark new: | Method | Mean | Error | StdDev | Code Size | |---------- |---------:|----------:|----------:|----------:| | Transform | 2.463 ns | 0.0766 ns | 0.0679 ns | 216 B | old: | Method | Mean | Error | StdDev | Median | Code Size | |---------- |---------:|----------:|----------:|---------:|----------:| | Transform | 9.469 ns | 0.2140 ns | 0.5408 ns | 9.206 ns | 621 B | * Fix polygon constructor * SlimPolygonBenchmark * use new SimdHelper for other methods * Fix bugs * Use new methods * Simd SlimPolygon.ComputeAABB * Move simd transform to physics * Cleanup * Remove uneccesary Unsafe.SkipInit * These tests all work on master * Add Transform.MulSimd test * Add SlimPolygon constructor tests * Add ComputeAABB test --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
19
Robust.Benchmarks/NumericsHelpers/Box2Benchmark.cs
Normal file
19
Robust.Benchmarks/NumericsHelpers/Box2Benchmark.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Numerics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Benchmarks.NumericsHelpers;
|
||||
|
||||
[Virtual, DisassemblyDiagnoser]
|
||||
public class Box2Benchmark
|
||||
{
|
||||
public Box2 Box = new();
|
||||
public Matrix3x2 Matrix = new();
|
||||
|
||||
[Benchmark]
|
||||
public Box2 Transform()
|
||||
{
|
||||
return Matrix.TransformBox(Box);
|
||||
}
|
||||
}
|
||||
18
Robust.Benchmarks/NumericsHelpers/Box2RotatedBenchmark.cs
Normal file
18
Robust.Benchmarks/NumericsHelpers/Box2RotatedBenchmark.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Numerics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Benchmarks.NumericsHelpers;
|
||||
|
||||
[Virtual, DisassemblyDiagnoser]
|
||||
public class Box2RotatedBenchmark
|
||||
{
|
||||
public Box2Rotated Box = new();
|
||||
|
||||
[Benchmark]
|
||||
public Matrix3x2 GetTransform()
|
||||
{
|
||||
return Box.Transform;
|
||||
}
|
||||
}
|
||||
25
Robust.Benchmarks/NumericsHelpers/GetAABBBenchmark.cs
Normal file
25
Robust.Benchmarks/NumericsHelpers/GetAABBBenchmark.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Runtime.Intrinsics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Benchmarks.NumericsHelpers;
|
||||
|
||||
[Virtual, DisassemblyDiagnoser]
|
||||
public class GetAABBBenchmark
|
||||
{
|
||||
public Vector128<float> X;
|
||||
public Vector128<float> Y;
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public Vector128<float> GetAABB_NoAvx()
|
||||
{
|
||||
return SimdHelpers.GetAABBSlow(X, Y);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Vector128<float> GetAABB_Avx()
|
||||
{
|
||||
return SimdHelpers.GetAABBAvx(X, Y);
|
||||
}
|
||||
}
|
||||
21
Robust.Benchmarks/NumericsHelpers/SlimPolygonBenchmark.cs
Normal file
21
Robust.Benchmarks/NumericsHelpers/SlimPolygonBenchmark.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Shapes;
|
||||
|
||||
namespace Robust.Benchmarks.NumericsHelpers;
|
||||
|
||||
// SlimPolyon is internal, so this won't compile without changes.
|
||||
/*
|
||||
[Virtual, DisassemblyDiagnoser]
|
||||
public class SlimPolygonBenchmark
|
||||
{
|
||||
public Box2Rotated RotBox = new();
|
||||
|
||||
[Benchmark]
|
||||
public SlimPolygon RotatedBox()
|
||||
{
|
||||
return new SlimPolygon(in RotBox);
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user