Skip to content

Commit

Permalink
Don't use intrinsics if only one pair fits in the vector
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmada committed Jan 2, 2024
1 parent 59dfe7e commit 33eefcc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/NetFabric.Numerics.Tensors/AggregatePairs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static ValueTuple<T, T> AggregatePairs<T, TOperator>(ReadOnlySpan<T> sour

if (Vector.IsHardwareAccelerated &&
Vector<T>.IsSupported &&
Vector<T>.Count > 2 &&
Vector<T>.Count % 2 is 0 &&
source.Length >= Vector<T>.Count)
{
Expand Down
1 change: 1 addition & 0 deletions src/NetFabric.Numerics.Tensors/ApplyBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static void Apply<T, TOperator>(ReadOnlySpan<T> x, ValueTuple<T, T> y, Sp
if (useIntrinsics &&
Vector.IsHardwareAccelerated &&
Vector<T>.IsSupported &&
Vector<T>.Count > 2 &&
Vector<T>.Count % 2 is 0 &&
x.Length >= Vector<T>.Count)
{
Expand Down
3 changes: 3 additions & 0 deletions src/NetFabric.Numerics.Tensors/ApplyTernary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public static void Apply<T, TOperator>(ReadOnlySpan<T> x, ValueTuple<T, T> y, Re
if (useIntrinsics &&
Vector.IsHardwareAccelerated &&
Vector<T>.IsSupported &&
Vector<T>.Count > 2 &&
Vector<T>.Count % 2 is 0 &&
x.Length >= Vector<T>.Count)
{
Expand Down Expand Up @@ -270,6 +271,7 @@ public static void Apply<T, TOperator>(ReadOnlySpan<T> x, ReadOnlySpan<T> y, Val
if (useIntrinsics &&
Vector.IsHardwareAccelerated &&
Vector<T>.IsSupported &&
Vector<T>.Count > 2 &&
Vector<T>.Count % 2 is 0 &&
x.Length >= Vector<T>.Count)
{
Expand Down Expand Up @@ -383,6 +385,7 @@ public static void Apply<T, TOperator>(ReadOnlySpan<T> x, ValueTuple<T, T> y, Va
if (useIntrinsics &&
Vector.IsHardwareAccelerated &&
Vector<T>.IsSupported &&
Vector<T>.Count > 2 &&
Vector<T>.Count % 2 is 0 &&
x.Length >= Vector<T>.Count)
{
Expand Down

0 comments on commit 33eefcc

Please sign in to comment.