Update math library
This commit is contained in:
@@ -39,8 +39,8 @@ public unsafe class SPMDBenchmark
|
||||
job.Run(_SIZE * _SIZE, 0);
|
||||
}
|
||||
|
||||
//[Benchmark]
|
||||
public void VectorNoise()
|
||||
[Benchmark]
|
||||
public void VectorJobNoise()
|
||||
{
|
||||
var job = new Jobs.NoiseJobVector
|
||||
{
|
||||
@@ -53,35 +53,23 @@ public unsafe class SPMDBenchmark
|
||||
_scheduler.WaitComplete(handle);
|
||||
}
|
||||
|
||||
//[Benchmark]
|
||||
public void MathNoise()
|
||||
[Benchmark]
|
||||
public void ParallelVectorNoise()
|
||||
{
|
||||
var job = new Jobs.NoiseJobMath
|
||||
var job = new Jobs.NoiseJobVector
|
||||
{
|
||||
buffers = _buf,
|
||||
width = _SIZE,
|
||||
height = _SIZE,
|
||||
};
|
||||
|
||||
var handle = _scheduler.ScheduleParallel(ref job, _SIZE * _SIZE, 64);
|
||||
_scheduler.WaitComplete(handle);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void ManualSPMDNoise()
|
||||
{
|
||||
var job = new Jobs.NoiseJobMathV
|
||||
Parallel.For(0, _SIZE * _SIZE, (i) =>
|
||||
{
|
||||
buffers = _buf,
|
||||
width = _SIZE,
|
||||
height = _SIZE,
|
||||
};
|
||||
|
||||
var iterations = (_SIZE * _SIZE + 8 - 1) / 8;
|
||||
var handle = _scheduler.ScheduleParallel(ref job, iterations, 64);
|
||||
_scheduler.WaitComplete(handle);
|
||||
job.Execute(i, 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public void SPMDNoise()
|
||||
{
|
||||
|
||||
@@ -1,59 +1,2 @@
|
||||
using Misaki.HighPerformance;
|
||||
using Misaki.HighPerformance.Jobs;
|
||||
using Misaki.HighPerformance.LowLevel;
|
||||
using Misaki.HighPerformance.LowLevel.Utilities;
|
||||
using Misaki.HighPerformance.Mathematics.SPMD;
|
||||
using Misaki.HighPerformance.Test.UnitTest.Jobs;
|
||||
using System.Numerics;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Text;
|
||||
|
||||
BenchmarkDotNet.Running.BenchmarkRunner.Run<Misaki.HighPerformance.Test.Benchmark.SPMDBenchmark>();
|
||||
//return;
|
||||
//using Misaki.HighPerformance.Collections;
|
||||
//using Misaki.HighPerformance.LowLevel.Buffer;
|
||||
//using Misaki.HighPerformance.LowLevel.Collections;
|
||||
|
||||
//AllocationManager.EnableDebugLayer();
|
||||
//using var csm = new UnsafeSlotMap<int>(4, Allocator.Persistent);
|
||||
//AllocationManager.Dispose();
|
||||
|
||||
//using Misaki.HighPerformance.Mathematics;
|
||||
//using System.Numerics;
|
||||
|
||||
//var a = new Misaki.HighPerformance.Mathematics.float4x4(
|
||||
// 1, 2, 3, 4,
|
||||
// 5, 6, 7, 8,
|
||||
// 9, 10, 11, 12,
|
||||
// 13, 14, 15, 16);
|
||||
//var b = new Misaki.HighPerformance.Mathematics.float4x4(
|
||||
// 16, 15, 14, 13,
|
||||
// 12, 11, 10, 9,
|
||||
// 8, 7, 6, 5,
|
||||
// 4, 3, 2, 1);
|
||||
|
||||
//Console.WriteLine(math.mul(a, b));
|
||||
|
||||
//var ma = new Matrix4x4(
|
||||
// 1, 2, 3, 4,
|
||||
// 5, 6, 7, 8,
|
||||
// 9, 10, 11, 12,
|
||||
// 13, 14, 15, 16);
|
||||
//var mb = new Matrix4x4(
|
||||
// 16, 15, 14, 13,
|
||||
// 12, 11, 10, 9,
|
||||
// 8, 7, 6, 5,
|
||||
// 4, 3, 2, 1);
|
||||
//Console.WriteLine(Matrix4x4.Multiply(ma, mb));
|
||||
|
||||
//int[] arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
//int[] arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
||||
//unsafe
|
||||
//{
|
||||
// fixed (int* p1 = arr1)
|
||||
// fixed (int* p2 = arr2)
|
||||
// {
|
||||
// Console.WriteLine(MemoryUtility.MemCmp(p1, p2, (nuint)(arr1.Length * sizeof(int))));
|
||||
// }
|
||||
//}
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Misaki.HighPerformance.Mathematics;
|
||||
using Misaki.HighPerformance.Mathematics;
|
||||
|
||||
namespace Misaki.HighPerformance.Test.UnitTest.Mathematics;
|
||||
|
||||
@@ -10,28 +10,18 @@ public class TestBool2
|
||||
{
|
||||
// Default constructor
|
||||
var v1 = new bool2();
|
||||
Assert.IsFalse(v1.x);
|
||||
Assert.IsFalse(v1.y);
|
||||
Assert.AreNotEqual(math.TRUE, v1.x);
|
||||
Assert.AreNotEqual(math.TRUE, v1.y);
|
||||
|
||||
// Single value constructor
|
||||
var v2 = new bool2(true);
|
||||
Assert.IsTrue(v2.x);
|
||||
Assert.IsTrue(v2.y);
|
||||
Assert.AreEqual(math.TRUE, v2.x);
|
||||
Assert.AreEqual(math.TRUE, v2.y);
|
||||
|
||||
// Component constructor
|
||||
var v3 = new bool2(true, false);
|
||||
Assert.IsTrue(v3.x);
|
||||
Assert.IsFalse(v3.y);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestLogicalOperators()
|
||||
{
|
||||
var a = new bool2(true, false);
|
||||
var b = new bool2(false, true);
|
||||
|
||||
// Note: bool types don't typically have bitwise operators in this implementation
|
||||
// They are primarily used for conditional operations with math functions
|
||||
Assert.AreEqual(math.TRUE, v3.x);
|
||||
Assert.AreNotEqual(math.TRUE, v3.y);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -54,12 +44,12 @@ public class TestBool2
|
||||
{
|
||||
var v = new bool2(true, false);
|
||||
|
||||
Assert.IsTrue(v.x);
|
||||
Assert.IsFalse(v.y);
|
||||
Assert.AreEqual(math.TRUE, v.x);
|
||||
Assert.AreNotEqual(math.TRUE, v.y);
|
||||
|
||||
var xy = v.xy;
|
||||
Assert.IsTrue(xy.x);
|
||||
Assert.IsFalse(xy.y);
|
||||
Assert.AreEqual(math.TRUE, xy.x);
|
||||
Assert.AreNotEqual(math.TRUE, xy.y);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -89,7 +79,7 @@ public class TestBool2
|
||||
{
|
||||
var v = new bool2(true, false);
|
||||
|
||||
Assert.IsTrue(v[0]);
|
||||
Assert.IsFalse(v[1]);
|
||||
Assert.AreEqual(math.TRUE, v[0]);
|
||||
Assert.AreNotEqual(math.TRUE, v[1]);
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class TestMathFunctions
|
||||
var a = new float3(1f, 2f, 3f);
|
||||
var b = new float3(4f, 5f, 6f);
|
||||
|
||||
var result = math.select(b, a, condition);
|
||||
var result = math.select(a, b, condition);
|
||||
|
||||
Assert.AreEqual(1f, result.x, 1e-6f); // condition is true, so select a.x
|
||||
Assert.AreEqual(5f, result.y, 1e-6f); // condition is false, so select b.y
|
||||
|
||||
Reference in New Issue
Block a user