mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-14 03:55:42 +00:00
[ci skip] style: reformat & cleanup solution
This commit is contained in:
parent
436f56d912
commit
4dd31ec1b6
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using X10D.Collections;
|
using X10D.Collections;
|
||||||
using X10D.Core;
|
using X10D.Core;
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ public class SpanTest
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Pack8Bit_Should_Pack_Correctly()
|
public void Pack8Bit_Should_Pack_Correctly()
|
||||||
{
|
{
|
||||||
Span<bool> span = stackalloc bool[8] { true, true, false, false, true, true, false, false };
|
Span<bool> span = stackalloc bool[8] {true, true, false, false, true, true, false, false};
|
||||||
Assert.AreEqual(0b00110011, span.PackByte());
|
Assert.AreEqual(0b00110011, span.PackByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ public class SpanTest
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Pack16Bit_Should_Pack_Correctly()
|
public void Pack16Bit_Should_Pack_Correctly()
|
||||||
{
|
{
|
||||||
ReadOnlySpan<bool> span = stackalloc bool[16] {
|
ReadOnlySpan<bool> span = stackalloc bool[16]
|
||||||
false, false, true, false, true, false, true, true,
|
{
|
||||||
true, false, true, true, false, true, false, false,
|
false, false, true, false, true, false, true, true, true, false, true, true, false, true, false, false,
|
||||||
};
|
};
|
||||||
Assert.AreEqual(0b00101101_11010100, span.PackInt16());
|
Assert.AreEqual(0b00101101_11010100, span.PackInt16());
|
||||||
}
|
}
|
||||||
@ -51,11 +51,10 @@ public class SpanTest
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Pack32Bit_Should_Pack_Correctly()
|
public void Pack32Bit_Should_Pack_Correctly()
|
||||||
{
|
{
|
||||||
ReadOnlySpan<bool> span = stackalloc bool[] {
|
ReadOnlySpan<bool> span = stackalloc bool[]
|
||||||
false, true, false, true, false, true, false, true,
|
{
|
||||||
true, false, true, false, true, false, true, false,
|
false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false,
|
||||||
false, true, false, true, false, true, false, true,
|
true, false, true, false, true, false, true, true, false, true, false, true, false, true, false,
|
||||||
true, false, true, false, true, false, true, false,
|
|
||||||
};
|
};
|
||||||
Assert.AreEqual(0b01010101_10101010_01010101_10101010, span.PackInt32());
|
Assert.AreEqual(0b01010101_10101010_01010101_10101010, span.PackInt32());
|
||||||
}
|
}
|
||||||
@ -75,15 +74,12 @@ public class SpanTest
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Pack64Bit_Should_Pack_Correctly()
|
public void Pack64Bit_Should_Pack_Correctly()
|
||||||
{
|
{
|
||||||
ReadOnlySpan<bool> span = stackalloc bool[] {
|
ReadOnlySpan<bool> span = stackalloc bool[]
|
||||||
true, false, true, false, false, true, false, true,
|
{
|
||||||
false, false, true, true, false, true, false, false,
|
true, false, true, false, false, true, false, true, false, false, true, true, false, true, false, false, true,
|
||||||
true, true, true, false, true, false, false, true,
|
true, true, false, true, false, false, true, false, true, false, false, true, false, false, false, false, true,
|
||||||
false, true, false, false, true, false, false, false,
|
true, false, true, false, true, true, true, false, false, true, false, true, true, false, false, true, true,
|
||||||
false, true, true, false, true, false, true, true,
|
false, true, false, true, true, true, false, true, false, true, false, true, false,
|
||||||
true, false, false, true, false, true, true, false,
|
|
||||||
false, true, true, false, true, false, true, true,
|
|
||||||
true, false, true, false, true, false, true, false,
|
|
||||||
};
|
};
|
||||||
Assert.AreEqual(0b01010101_11010110_01101001_11010110_00010010_10010111_00101100_10100101, span.PackInt64());
|
Assert.AreEqual(0b01010101_11010110_01101001_11010110_00010010_10010111_00101100_10100101, span.PackInt64());
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ public static class Vector4Extensions
|
|||||||
public static System.Numerics.Vector4 ToSystemVector(this Vector4 vector)
|
public static System.Numerics.Vector4 ToSystemVector(this Vector4 vector)
|
||||||
{
|
{
|
||||||
return UnsafeUtility.As<Vector4, System.Numerics.Vector4>(ref vector);
|
return UnsafeUtility.As<Vector4, System.Numerics.Vector4>(ref vector);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -49,6 +49,7 @@ public static class Int32Extensions
|
|||||||
Avx2Implementation(value, destination);
|
Avx2Implementation(value, destination);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ssse3.IsSupported)
|
if (Ssse3.IsSupported)
|
||||||
{
|
{
|
||||||
Ssse3Implementation(value, destination);
|
Ssse3Implementation(value, destination);
|
||||||
@ -85,6 +86,7 @@ public static class Int32Extensions
|
|||||||
Avx.Store((byte*)pDestination, correctness);
|
Avx.Store((byte*)pDestination, correctness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe static void Ssse3Implementation(int value, Span<bool> destination)
|
unsafe static void Ssse3Implementation(int value, Span<bool> destination)
|
||||||
{
|
{
|
||||||
fixed (bool* pDestination = destination)
|
fixed (bool* pDestination = destination)
|
||||||
|
@ -22,6 +22,7 @@ public static class SpanExtensions
|
|||||||
{
|
{
|
||||||
#if NETCOREAPP3_0_OR_GREATER
|
#if NETCOREAPP3_0_OR_GREATER
|
||||||
private const ulong IntegerPackingMagic = 0x0102040810204080;
|
private const ulong IntegerPackingMagic = 0x0102040810204080;
|
||||||
|
|
||||||
private static Vector64<ulong> IntegerPackingMagicV64
|
private static Vector64<ulong> IntegerPackingMagicV64
|
||||||
{
|
{
|
||||||
get => Vector64.Create(IntegerPackingMagic);
|
get => Vector64.Create(IntegerPackingMagic);
|
||||||
@ -174,7 +175,8 @@ public static class SpanExtensions
|
|||||||
goto default;
|
goto default;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed (bool* pSource = source) {
|
fixed (bool* pSource = source)
|
||||||
|
{
|
||||||
// TODO: .NET 8.0 Wasm support.
|
// TODO: .NET 8.0 Wasm support.
|
||||||
|
|
||||||
if (Sse2.IsSupported)
|
if (Sse2.IsSupported)
|
||||||
@ -336,6 +338,7 @@ public static class SpanExtensions
|
|||||||
|
|
||||||
return (int)or2.GetElement(0);
|
return (int)or2.GetElement(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Sse2.IsSupported)
|
if (Sse2.IsSupported)
|
||||||
{
|
{
|
||||||
Vector128<byte> load = Sse2.LoadVector128((byte*)pSource);
|
Vector128<byte> load = Sse2.LoadVector128((byte*)pSource);
|
||||||
@ -357,6 +360,7 @@ public static class SpanExtensions
|
|||||||
|
|
||||||
return (int)or2.GetElement(0);
|
return (int)or2.GetElement(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AdvSimd.IsSupported)
|
if (AdvSimd.IsSupported)
|
||||||
{
|
{
|
||||||
// Hasn't been tested since March 6th 2023 (Reason: Unavailable hardware).
|
// Hasn't been tested since March 6th 2023 (Reason: Unavailable hardware).
|
||||||
|
@ -84,7 +84,8 @@ public static class RuneExtensions
|
|||||||
{
|
{
|
||||||
return string.Create(count * 2, value, (span, rune) =>
|
return string.Create(count * 2, value, (span, rune) =>
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe
|
||||||
|
{
|
||||||
Span<byte> bytes = stackalloc byte[4];
|
Span<byte> bytes = stackalloc byte[4];
|
||||||
value.EncodeToUtf8(bytes);
|
value.EncodeToUtf8(bytes);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user