Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit b6d5d81

Browse files
committed
Merge branch 'main' of https://github.com/Cysharp/SimdLinq
2 parents 518926d + 4cf7566 commit b6d5d81

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ This library is distributed via NuGet.
1717

1818
> PM> Install-Package [SimdLinq](https://www.nuget.org/packages/SimdLinq)
1919
20-
Currently supporting target framework is only **.NET 7** or above because this library using static abstract members and .NET 7 SIMD API improvement.
20+
Note that this library requires **.NET 7** or above because this library uses static abstract members and the new cross platform **.NET 7** SIMD Api.
2121

2222
```csharp
2323
using SimdLinq; // enable SimdLinq extension methods
2424
2525
var array = Enumerable.Range(1, 100000).ToArray();
2626

27-
var sum = array.Sum(); // used SimdLinqExtensions.Sum
27+
var sum = array.Sum(); // uses SimdLinqExtensions.Sum
2828
```
2929

30-
To enable SimdLinq per file, uses `using SimdLinq;` namespace. To enable SimdLinq per project, uses global usings in csproj.
30+
To enable SimdLinq per file, add the `using SimdLinq;` using directive. To enable SimdLinq across the project, use global usings in the csproj file.
3131

3232
```xml
3333
<ItemGroup>
3434
<Using Include="SimdLinq" />
3535
</ItemGroup>
3636
```
3737

38-
`SimdLinqExtensions` has methods for concrete types(`int[]`, `Span<double`, etc...) that same name defined in LINQ, so that if a method is used that can effectively use SIMD (such as `Sum` of `int[]`), it will be executed.
38+
`SimdLinqExtensions` has methods for concrete data types, like `int[]` or `Span<double>`, with the same names as LINQ's methods. If a method is eligible for SIMD optimization (such as the Sum of int[]), the `SimdLinqExtensions` method will be used for improved performance.
3939

40-
`Span<T>` has no LINQ methods but SimdLinq has it so you can call `Sum`, `Min` etc in `Span<T>`/`ReadOnlySpan<T>`.
40+
Unlike base LINQ, SimdLinq supports `Span<T>`, allowing you to call methods such as `Sum`, `Min`, etc. on `Span<T>` or `ReadOnlySpan<T>` collections.
4141

4242
```csharp
4343
(double Min, double Max) GetMinMax(Span<double> span)
@@ -46,27 +46,27 @@ To enable SimdLinq per file, uses `using SimdLinq;` namespace. To enable SimdLin
4646
}
4747
```
4848

49-
`MinMax` is a original extension of SimdLinq, that returns tuple of `Min` and `Max`.
49+
`MinMax` is an original SimdLinq extension, that returns a tuple of `Min` and `Max`.
5050

5151
Compatibility
5252
---
53-
One of the reasons why LINQ's SIMD support in .NET 7 is incomplete, is compatibility. SimdLinq top priority is SIMD enablement to fastest operation so sacrifices compatibility and some safety features. Please note the following.
53+
One of the reasons why LINQ's SIMD support in .NET 7 is incomplete, is compatibility. SimdLinq prioritises performance over some safety features and full compatibility with LINQ. Please note the following differences.
5454

5555
### Sum/Average
5656

57-
LINQ Sum is `checked` but SimdLinq is `unchecked`(SIMD operation is not supported overflow). To reduce the risk of overflow, `Sum` and `Average` supported types are 32-bit or higher(`int`, `long`, `uint`, `ulong`, `double`, `float`).
57+
LINQ Sum is `checked` but SimdLinq is `unchecked`(SIMD operation is not supported overflow). To reduce the risk of overflow, `Sum` and `Average` only support types that are 32-bit or higher(`int`, `long`, `uint`, `ulong`, `double`, `float`).
5858

5959
SimdLinq provides `LongSum` for `int` and `uint`, that returns `long`/`ulong` so avoid overflow.
6060

6161
### float/double
6262

63-
LINQ Min/Max of float/double checks `NaN` but SimdLinq does not. Also, the order in which Sum is calculated is not sequential. This results in floating-point operations that are different from those in regular LINQ. For example, with LINQ `1.5710588F` but SIMD `1.5710589F`. If compatibility is not important, this is not a problem, but be aware that very small tolerance can occur.
63+
Unlike LINQ, SimdLinq does not check for NaN in float/double Min/Max calculations. Additionally, the order of calculation for Sum is not sequential, leading to slight differences in floating-point operations compared to regular LINQ. For instance, LINQ returns 1.5710588F, while SimdLinq returns 1.5710589F. If compatibility is not a concern, this difference is not significant, but be aware of potential small tolerance differences.
6464

65-
Supporting collection
65+
Supported collections
6666
---
6767
`T[]`, `List<T>`, `Span<T>`, `ReadOnlySpan<T>`, `Memory<T>`, `ReadOnlyMemory<T>`, `Span<T>`, `ReadOnlySpan<T>`.
6868

69-
Supporting methods
69+
Supported methods
7070
---
7171
* `Sum` for `int`, `uint`, `long`, `ulong`, `float`, `double`
7272
* `LongSum` for `int`, `uint`

0 commit comments

Comments
 (0)