LinkDotNet.LinqSIMDExtensions 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LinkDotNet.LinqSIMDExtensions --version 1.3.0                
NuGet\Install-Package LinkDotNet.LinqSIMDExtensions -Version 1.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LinkDotNet.LinqSIMDExtensions" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LinkDotNet.LinqSIMDExtensions --version 1.3.0                
#r "nuget: LinkDotNet.LinqSIMDExtensions, 1.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LinkDotNet.LinqSIMDExtensions as a Cake Addin
#addin nuget:?package=LinkDotNet.LinqSIMDExtensions&version=1.3.0

// Install LinkDotNet.LinqSIMDExtensions as a Cake Tool
#tool nuget:?package=LinkDotNet.LinqSIMDExtensions&version=1.3.0                

LinqSIMDExtensions

.NET Nuget GitHub tag

LinqSIMDExtensions is a high-performance library that combines the power of SIMD (Single Instruction, Multiple Data) and the elegance of LINQ (Language Integrated Query) syntax. SIMD uses features like AVX, SSE, NEON, etc. to process multiple data in parallel. The performance depends on the hardware and the data type. Some extensions like AVX-512 are only available on x86/x64 architectures.

LinqSIMDExtensions leverages the generic math features introduced in .NET 7 to provide a wide range of data type support. With LinkDotNet.LinqSIMDExtensions, you can efficiently process large datasets in parallel, improving the performance of your applications.

Using this library for small datasets is not recommended as the overhead of the SIMD operations is not worth it.

Features

  • Leverage SIMD operations for fast and parallel processing of data
  • Support for a wide range of data types (thanks to generic math)
  • LINQ syntax so you can almost use it as drop-in replacement
  • Currently supports: Min, Max, Sum, SequenceEqual, Average, Contains

Installation

To install the package via NuGet, run the following command :

dotnet add package LinkDotNet.LinqSIMDExtensions

Usage

First you have to import the namespace:

using LinkDotNet.LinqSIMDExtensions;

Then you can use the extension methods:

List<int> numbers = GetNumbers();
var result = numbers.Min();

Benchmark

You can head over to benchmark section to see the setup. The following section will show you some results of different machines and architectures. Keep in mind to test against your specific use case with the hardware that will run it! SIMD can vary a lot depending on the hardware. Newer hardware tends to have better support for SIMD (if x86/x64 is used).

Here are the benchmarks for a M1 Pro. Keep in mind that the M1 (arm64) does not support all SIMD operations. So the performance is not as good as on a x64 machine.

BenchmarkDotNet=v0.13.5, OS=macOS Ventura 13.2.1 (22D68) [Darwin 22.3.0]
Apple M1 Pro, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.202
  [Host]     : .NET 7.0.4 (7.0.423.11508), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 7.0.4 (7.0.423.11508), Arm64 RyuJIT AdvSIMD


| Method          |        Mean |    Error |   StdDev | Ratio |
| --------------- | ----------: | -------: | -------: | ----: |
| LinqMin         |   176.93 ns | 0.783 ns | 0.732 ns |  1.00 |
| LinqSIMDMin     |    65.48 ns | 0.255 ns | 0.238 ns |  0.37 |
|                 |             |          |          |       |
| LinqAverage     | 1,058.29 ns | 5.354 ns | 5.008 ns |  1.00 |
| LinqSIMDAverage |    80.97 ns | 0.465 ns | 0.435 ns |  0.08 |

Constraints

As we are using SIMD the following constraints apply:

  • The collection type has to be contiguous memory (e.g. List<T>, T[], Span<T>). Types like IEnumerable<T> or IReadOnlyList<T> are not supported.
  • The underlying number has to implement specific interfaces (like IMinMaxValue) to be able to determine the min/max value of the type.
  • Some functions like Average can not return a more specific type than the input. This means that if you have a List<int> and call Average on it, the result will be a int and not an double.
  • There are no arithmetic checks. So it is prune to overflow or underflow.
  • Contains on List<T> has to be invoked like this: LinqSIMDExtensions.Contains(list, value). This is due to the fact that the Contains method is already defined on List<T> and the compiler can not resolve the correct method.
  • The underlying data type has to be supported by the SIMD instruction. For example Complex is not supported as it is not a primitive type.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 596 1/8/2024
1.4.1 134 1/7/2024
1.4.0 173 7/23/2023
1.3.0 158 5/7/2023
1.2.2 169 4/12/2023
1.2.1 187 4/10/2023
1.2.0 181 4/4/2023
1.1.0 184 4/4/2023
1.0.0 192 4/1/2023