Skip to content

Commit 7f4752f

Browse files
Merge pull request #18 from MrUnbelievable92/2.9.0
Version 2.9.0
2 parents f59e9c2 + a991a2c commit 7f4752f

File tree

1,139 files changed

+324297
-139336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,139 files changed

+324297
-139336
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2020 - 2021 Maximilian Kalimon
189+
Copyright 2020 - 2024 Maximilian Kalimon
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# MaxMath
2-
A C# SIMD math library for use with Unity only, supplementary to Unity.Mathematics using Unity.Burst.
3-
4-
It adds (s)byte, (u)short and (u)long SIMD vectors and matrices to the ones already provided by Unity.Mathematics.
5-
Almost all functions present in Unity.Mathematics have been transcribed to work with the new vector and matrix types in addition to many useful functions having been added.
6-
7-
Note:
8-
- [C Sharp Dev Tools](https://github.com/MrUnbelievable92/C-Sharp-Dev-Tools) (conditionally compiled runtime checks) is required. Unit tests for this library are included in this repository.
9-
- This library utilizes Avx2 as often as possible. Optimized fallback procedures for Sse4 and Sse2 are included, aswell as a managed C# implementation. There are currently no plans for supporting ARM or other instruction sets in the future, although Burst/LLVM is generally good at vectorizing some of the code for them.
10-
- The "float8" type does not support deterministic compilation across all platforms with Unity.Burst. Split up the vector into two "float4" vectors via the properties "myfloat8.v4_0" and "myfloat8.v4_4" to take advantage of deterministic compilation instead.
1+
#MaxMath
2+
MaxMath is the most powerful and extensive SIMD math library available to Unity developers. Built on top of Unity.Mathematics and utilizing Unity.Burst, it introduces the following key features:
3+
4+
- **Support For All Primitive Data Types:** MaxMath adds support for `(s)byte`, `(u)short`, and `(u)long` vectors and matrices. These data types come with specialized overloads for all functions in Unity.Mathematics. Additionally, specialized `Random8/16/32/64/128` types are available for efficient pseudo-random number generation.
5+
- **Wider Vectors With Full Hardware Support:** Vector types are expanded to 256 bits, enabling types like `byte32`, `short16`, `int8`, and `float8`. This allows you to leverage the full potential of SIMD computation.
6+
- **Many Additional Functions:** MaxMath includes a massive library of mathematical functions not found in Unity.Mathematics, with about five times as many highly optimized functions at your disposal. Each function is fully documented with XML annotations. A full list is provided further below.
7+
- **Exotic Data Types:** MaxMath introduces data types such as `(U)Int128` (scalar only), 128-bit `quadruple` precision floats (scalar only), and 8-bit `quarter` precision floats (in both scalar and vector forms). Additionally, `Divider<T>` offers highly optimized integer division operations, extending and outperforming specialized libraries like libdivide.
8+
- **Written Entirely With Hardware Intrinsics:** MaxMath guarantees optimal performance by utilizing specialized CPU instructions for both ARM and x86 ISAs, while abstracting these complexities away from the user entirely.
9+
- **Extends The Burst Compiler:** MaxMath integrates deeply with Unity.Burst and LLVM, leveraging `Unity.Burst.CompilerServices.Constant.IsConstantExpression<T>()` to include code typically only found in optimizing compilers. This functionality allows MaxMath to choose more optimized code paths at compile time, and users can influence this behavior via the optional `Promise` enum parameter available in many functions.
10+
- **Easy To Use:** MaxMath is just as easy to use as Unity.Mathematics. It supports features like `implicit` and `explicit` type conversions, making it seamless for you to use if you expect typical C# behavior of primitive types.
11+
- **Extensive Test Coverage:** MaxMath is backed by 250,000 lines of unit tests for its 400,000 lines of code, as well as `DEBUG` only runtime checks where appropriate, together ensuring it is _production ready_.
1112

1213

1314
# How To Use This Library

Runtime/AssemblyInfo.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,29 @@
33
using System.Runtime.CompilerServices;
44
using System.Diagnostics.CodeAnalysis;
55

6-
// General Information about an assembly is controlled through the following
7-
// set of attributes. Change these attribute values to modify the information
8-
// associated with an assembly.
96
[assembly: AssemblyTitle("MaxMath")]
107
[assembly: AssemblyDescription("")]
118
[assembly: AssemblyConfiguration("")]
129
[assembly: AssemblyCompany("")]
1310
[assembly: AssemblyProduct("MaxMath")]
14-
[assembly: AssemblyCopyright("Copyright © 2020 - 2022 Maximilian Kalimon")]
11+
[assembly: AssemblyCopyright("Copyright © 2020 - 2024 Maximilian Kalimon")]
1512
[assembly: AssemblyTrademark("")]
1613
[assembly: AssemblyCulture("")]
17-
[assembly: InternalsVisibleTo("MaxMath.Tests")]
18-
[assembly: InternalsVisibleTo("SIMD Algorithms")]
1914

20-
// Setting ComVisible to false makes the types in this assembly not visible
21-
// to COM components. If you need to access a type in this assembly from
22-
// COM, set the ComVisible attribute to true on that type.
2315
[assembly: ComVisible(false)]
2416

25-
// The following GUID is for the ID of the typelib if this project is exposed to COM
2617
[assembly: Guid("d3cc711d-084c-435c-8c84-7d624992dc10")]
2718

28-
// Version information for an assembly consists of the following four values:
29-
//
30-
// Major Version
31-
// Minor Version
32-
// Build Number
33-
// Revision
34-
//
35-
[assembly: AssemblyVersion("2.3.5")]
36-
[assembly: AssemblyFileVersion("2.3.5")]
37-
[assembly: AssemblyInformationalVersion("2.3.5 Release")]
19+
[assembly: AssemblyVersion("2.9.0")]
20+
[assembly: AssemblyFileVersion("2.9.0")]
21+
[assembly: AssemblyInformationalVersion("2.9.0 Release")]
22+
23+
// Style
24+
[assembly: SuppressMessage("Style", "IDE1006: Naming Styles", Justification = "Unity.Mathematics API consistency")]
25+
[assembly: SuppressMessage("Style", "IDE0034: Simplify 'default' expression", Justification = "Coding Guidelines")]
26+
[assembly: SuppressMessage("Style", "IDE0066: Use 'switch' expression", Justification = "Coding Guidelines")]
27+
[assembly: SuppressMessage("Style", "IDE0090: Simplify 'new' expression", Justification = "Compatibility with C#8 or less")]
3828

39-
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity.Mathematics API consistency")]
29+
// Compilation
30+
[assembly: InternalsVisibleTo("MaxMath.Tests")]
4031
[assembly: CompilationRelaxationsAttribute(CompilationRelaxations.NoStringInterning)]
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//#define TESTING
2+
3+
using Unity.Burst;
4+
5+
namespace MaxMath
6+
{
7+
internal static class COMPILATION_OPTIONS
8+
{
9+
internal static OptimizeFor OPTIMIZE_FOR
10+
{
11+
get;
12+
#if TESTING
13+
set;
14+
#endif
15+
} = OptimizeFor.Performance;
16+
17+
internal static FloatMode FLOAT_MODE
18+
{
19+
get;
20+
#if TESTING
21+
set;
22+
#endif
23+
} = FloatMode.Default;
24+
25+
internal static FloatPrecision FLOAT_PRECISION
26+
{
27+
get;
28+
#if TESTING
29+
set;
30+
#endif
31+
} = FloatPrecision.Standard;
32+
33+
34+
internal static bool FLOAT_SIGNED_ZERO => FLOAT_MODE != FloatMode.Fast;
35+
internal static bool FLOAT_NO_NAN => FLOAT_MODE == FloatMode.Fast;
36+
internal static bool FLOAT_NO_INF => FLOAT_MODE == FloatMode.Fast;
37+
internal static bool FLOAT_DENORMALS_ARE_ZERO => FLOAT_PRECISION == FloatPrecision.Low;
38+
}
39+
}

Runtime/XSE Core/Constant/Macros/Vector Assume Intrinsic Helper.cs.meta renamed to Runtime/Compiler Extensions/Compilation Options.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/Editor/Types/Unity.meta renamed to Runtime/Compiler Extensions/constexpr.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Runtime.CompilerServices;
2+
using Unity.Burst.CompilerServices;
3+
4+
namespace MaxMath.Intrinsics
5+
{
6+
public static partial class constexpr
7+
{
8+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9+
public static bool IS_CONST<T>(T value)
10+
where T : unmanaged
11+
{
12+
return Constant.IsConstantExpression(value);
13+
}
14+
15+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
16+
public static bool IS_TRUE(bool condition)
17+
{
18+
return IS_CONST(condition) && condition;
19+
}
20+
21+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
22+
public static bool IS_FALSE(bool condition)
23+
{
24+
return IS_CONST(condition) && !condition;
25+
}
26+
}
27+
}
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//#define TESTING
2+
3+
using System.Runtime.CompilerServices;
4+
using Unity.Burst.CompilerServices;
5+
using DevTools;
6+
7+
namespace MaxMath.Intrinsics
8+
{
9+
public static partial class constexpr
10+
{
11+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
12+
public static void ASSUME(bool value)
13+
{
14+
#if TESTING
15+
Assert.IsTrue(value);
16+
#endif
17+
Hint.Assume(value);
18+
}
19+
}
20+
}

Runtime/XSE Core/Constant/Macros/Check const Vector value helpers.cs.meta renamed to Runtime/Compiler Extensions/constexpr/Validated Assume.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)