Skip to content

[WIP] [2.0] A maths and hardware intrinsics library for Silk.NET and .NET 5 #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Input.Extensions", "src\Input\Extensions\Silk.NET.Input.Extensions\Silk.NET.Input.Extensions.csproj", "{8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Maths", "Maths", "{BF404427-19B2-4EE3-A5C9-E61E5BE2B099}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Intrinsics", "src\Maths\Silk.NET.Intrinsics\Silk.NET.Intrinsics.csproj", "{511FCC01-660C-409C-A7DF-B370FCF69443}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Maths", "src\Maths\Silk.NET.Maths\Silk.NET.Maths.csproj", "{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1790,6 +1796,30 @@ Global
{8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB}.Release|x64.Build.0 = Release|Any CPU
{8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB}.Release|x86.ActiveCfg = Release|Any CPU
{8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB}.Release|x86.Build.0 = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|Any CPU.Build.0 = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|x64.ActiveCfg = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|x64.Build.0 = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|x86.ActiveCfg = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Debug|x86.Build.0 = Debug|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|Any CPU.ActiveCfg = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|Any CPU.Build.0 = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|x64.ActiveCfg = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|x64.Build.0 = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|x86.ActiveCfg = Release|Any CPU
{511FCC01-660C-409C-A7DF-B370FCF69443}.Release|x86.Build.0 = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|x64.ActiveCfg = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|x64.Build.0 = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|x86.ActiveCfg = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Debug|x86.Build.0 = Debug|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|Any CPU.Build.0 = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|x64.ActiveCfg = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|x64.Build.0 = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|x86.ActiveCfg = Release|Any CPU
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BFE429EB-4C2E-4BF3-A302-C9C5A2FDA6D7} = {23324041-2076-477C-A4BF-B385B8066C6C}
Expand Down Expand Up @@ -1923,5 +1953,7 @@ Global
{77AA84B4-6D0A-4FCB-8268-18B2812D7955} = {E1F91563-7277-4E9B-A3B7-8D5FD9802A4A}
{8D84B804-168F-4EAA-BC09-F55A35A29887} = {FA9D1C95-5585-4DEC-B226-1447A486C376}
{8DCB2EB4-D0DE-4EF9-ACB3-332055D594CB} = {8D84B804-168F-4EAA-BC09-F55A35A29887}
{511FCC01-660C-409C-A7DF-B370FCF69443} = {BF404427-19B2-4EE3-A5C9-E61E5BE2B099}
{2CE6F4A3-AD5F-41BC-B03D-1E8ECCCE192E} = {BF404427-19B2-4EE3-A5C9-E61E5BE2B099}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions Silk.NET.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ You may modify and distribute Silk.NET under the terms
of the MIT license. See the LICENSE file for details.
</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deadzone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lerp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Thumbstick/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Thumbsticks/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Vulkan/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
330 changes: 330 additions & 0 deletions src/Maths/Silk.NET.Intrinsics/Avx/AvxRegister.Double.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
// This file is part of Silk.NET.
//
// You may modify and distribute Silk.NET under the terms
// of the MIT license. See the LICENSE file for details.

namespace Silk.NET.Intrinsics.Avx
{
public partial struct AvxRegister : IRegister<double>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "Register" mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is poorly chosen, but in the context of the intrinsics library a register is a class capable of performing mathematical operations for a given type using a SIMD register such as AVX or SSE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe IVector or something would be a better name?

Is Avx referring to VEX encoded (128-bit or 256-bit) vectors or strictly 256-bit vectors? If the latter, it might also benefit from a clearer name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah VEX-encoded, but I don't want that leaking out to the user as I want this to be relatively easy to use and not try to introduce too many new concepts to the user - all the user needs to know is "fast maths ooh shiney"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it being VEX encoded an important detail? The operation is ultimately the same, just with better codegen under VEX.
It normally only gets interesting when the size changes, since that changes how much you are processing, etc.

{
public WorkUnit<double> LengthSquared(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Length(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Normalize2(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NormalizeApprox2(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Normalize3(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NormalizeApprox3(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Normalize4(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NormalizeApprox4(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Conjugate(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Inverse(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> DotProduct2(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> DotProduct3(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> DotProduct4(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Add(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Subtract(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Equal(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NotEqual(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Negate(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Lerp(WorkUnit<double> left, WorkUnit<double> right, WorkUnit<double> amount)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Slerp(WorkUnit<double> left, WorkUnit<double> right, WorkUnit<double> amount)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Concatenate(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Multiply(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Transform2(WorkUnit<double> value, WorkUnit<double> quaternion)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Transform3(WorkUnit<double> value, WorkUnit<double> quaternion)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Transform4(WorkUnit<double> value, WorkUnit<double> quaternion)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Abs(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> HorizontalAdd(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Shuffle(WorkUnit<double> value, byte control)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> X(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Y(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Z(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> W(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Sin(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> SinApprox(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Cos(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> CosApprox(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Tan(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> TanApprox(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public void SinCos(WorkUnit<double> vector, out WorkUnit<double> sin, out WorkUnit<double> cos)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Shuffle(WorkUnit<double> left, WorkUnit<double> right, byte control)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> MultiplyAddFused(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> MultiplyAddFast(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NegateMultiplyAddFused(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NegateMultiplyAddFast(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> MultiplySubtractFused(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> MultiplySubtractFast(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NegateMultiplySubtractFused(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> NegateMultiplySubtractFast(WorkUnit<double> x, WorkUnit<double> y, WorkUnit<double> z)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Divide(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Sqrt(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Max(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> Min(WorkUnit<double> vector)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> GreaterThan(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> LessThan(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> GreaterThanOrEqualTo(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public WorkUnit<double> LessThanOrEqualTo(WorkUnit<double> left, WorkUnit<double> right)
{
throw new System.NotImplementedException();
}

public unsafe void StoreScalar(WorkUnit<double> vector, double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe void StoreVector2(WorkUnit<double> vector, double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe void StoreVector3(WorkUnit<double> vector, double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe void StoreVector4(WorkUnit<double> vector, double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe WorkUnit<double> ToScalar(double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe WorkUnit<double> ToVector2(double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe WorkUnit<double> ToVector3(double* ptr)
{
throw new System.NotImplementedException();
}

public unsafe WorkUnit<double> ToVector4(double* ptr)
{
throw new System.NotImplementedException();
}
}
}
Loading