LinkDotNet.LinqSIMDExtensions
1.1.0
See the version list below for details.
dotnet add package LinkDotNet.LinqSIMDExtensions --version 1.1.0
NuGet\Install-Package LinkDotNet.LinqSIMDExtensions -Version 1.1.0
<PackageReference Include="LinkDotNet.LinqSIMDExtensions" Version="1.1.0" />
paket add LinkDotNet.LinqSIMDExtensions --version 1.1.0
#r "nuget: LinkDotNet.LinqSIMDExtensions, 1.1.0"
// Install LinkDotNet.LinqSIMDExtensions as a Cake Addin #addin nuget:?package=LinkDotNet.LinqSIMDExtensions&version=1.1.0 // Install LinkDotNet.LinqSIMDExtensions as a Cake Tool #tool nuget:?package=LinkDotNet.LinqSIMDExtensions&version=1.1.0
LinqSIMDExtensions
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. It leverages the generic math features introduced in .NET 7 to provide a wide range of data type support. With LinkDotNet.LinqSIMDExtensions, you can easily process large datasets in parallel, improving the performance of your applications.
It is not recommend to use this library for small datasets 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
andAverage
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.
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 |
| --------------- | ---------: | ------: | ------: | ----: |
| LinqSUM | 328.6 ns | 0.77 ns | 0.72 ns | 1.00 |
| LinqSIMDSUM | 118.9 ns | 0.57 ns | 0.51 ns | 0.36 |
| | | | | |
| LinqAverage | 1,050.7 ns | 1.04 ns | 0.98 ns | 1.00 |
| LinqSIMDAverage | 178.6 ns | 0.28 ns | 0.25 ns | 0.17 |
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 likeIEnumerable<T>
orIReadOnlyList<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 aList<int>
and callAverage
on it, the result will be aint
and not andouble
.
Product | Versions 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. |
-
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.