Skip to content

Commit

Permalink
Ensure we call Exp and that the methods are properly inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Jan 18, 2024
1 parent a5909ef commit 7b04a92
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,8 @@ public static bool EqualsAny<T>(Vector128<T> left, Vector128<T> right)
|| Vector64.EqualsAny(left._upper, right._upper);
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector64.Exp(Vector64{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<double> Exp(Vector128<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1438,15 +1437,14 @@ public static Vector128<double> Exp(Vector128<double> vector)
else
{
return Create(
Vector64.Log(vector._lower),
Vector64.Log(vector._upper)
Vector64.Exp(vector._lower),
Vector64.Exp(vector._upper)
);
}
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector64.Exp(Vector64{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<float> Exp(Vector128<float> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1456,8 +1454,8 @@ public static Vector128<float> Exp(Vector128<float> vector)
else
{
return Create(
Vector64.Log(vector._lower),
Vector64.Log(vector._upper)
Vector64.Exp(vector._lower),
Vector64.Exp(vector._upper)
);
}
}
Expand Down Expand Up @@ -1818,6 +1816,7 @@ internal static Vector128<ushort> LoadUnsafe(ref char source, nuint elementOffse
LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset);

/// <inheritdoc cref="Vector64.Log(Vector64{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<double> Log(Vector128<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1834,6 +1833,7 @@ public static Vector128<double> Log(Vector128<double> vector)
}

/// <inheritdoc cref="Vector64.Log(Vector64{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<float> Log(Vector128<float> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1850,6 +1850,7 @@ public static Vector128<float> Log(Vector128<float> vector)
}

/// <inheritdoc cref="Vector64.Log2(Vector64{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<double> Log2(Vector128<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1866,6 +1867,7 @@ public static Vector128<double> Log2(Vector128<double> vector)
}

/// <inheritdoc cref="Vector64.Log2(Vector64{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector128<float> Log2(Vector128<float> vector)
{
if (IsHardwareAccelerated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,8 @@ public static bool EqualsAny<T>(Vector256<T> left, Vector256<T> right)
|| Vector128.EqualsAny(left._upper, right._upper);
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector128.Exp(Vector128{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<double> Exp(Vector256<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1420,9 +1419,8 @@ public static Vector256<double> Exp(Vector256<double> vector)
}
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector128.Exp(Vector128{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<float> Exp(Vector256<float> vector)
{
if (IsHardwareAccelerated)
Expand Down Expand Up @@ -1792,6 +1790,7 @@ internal static Vector256<ushort> LoadUnsafe(ref char source, nuint elementOffse
LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset);

/// <inheritdoc cref="Vector128.Log(Vector128{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<double> Log(Vector256<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1808,6 +1807,7 @@ public static Vector256<double> Log(Vector256<double> vector)
}

/// <inheritdoc cref="Vector128.Log(Vector128{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<float> Log(Vector256<float> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1824,6 +1824,7 @@ public static Vector256<float> Log(Vector256<float> vector)
}

/// <inheritdoc cref="Vector128.Log2(Vector128{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<double> Log2(Vector256<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1840,6 +1841,7 @@ public static Vector256<double> Log2(Vector256<double> vector)
}

/// <inheritdoc cref="Vector128.Log2(Vector128{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector256<float> Log2(Vector256<float> vector)
{
if (IsHardwareAccelerated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1453,23 +1453,8 @@ public static bool EqualsAny<T>(Vector512<T> left, Vector512<T> right)
|| Vector256.EqualsAny(left._upper, right._upper);
}

internal static Vector512<T> Exp<T>(Vector512<T> vector)
where T : IExponentialFunctions<T>
{
Unsafe.SkipInit(out Vector512<T> result);

for (int index = 0; index < Vector512<T>.Count; index++)
{
T value = T.Exp(vector.GetElement(index));
result.SetElementUnsafe(index, value);
}

return result;
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector256.Exp(Vector256{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<double> Exp(Vector512<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1485,9 +1470,8 @@ public static Vector512<double> Exp(Vector512<double> vector)
}
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <inheritdoc cref="Vector256.Exp(Vector256{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<float> Exp(Vector512<float> vector)
{
if (IsHardwareAccelerated)
Expand Down Expand Up @@ -1857,6 +1841,7 @@ internal static Vector512<ushort> LoadUnsafe(ref char source, nuint elementOffse
LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset);

/// <inheritdoc cref="Vector256.Log(Vector256{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<double> Log(Vector512<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1873,6 +1858,7 @@ public static Vector512<double> Log(Vector512<double> vector)
}

/// <inheritdoc cref="Vector256.Log(Vector256{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<float> Log(Vector512<float> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1889,6 +1875,7 @@ public static Vector512<float> Log(Vector512<float> vector)
}

/// <inheritdoc cref="Vector256.Log2(Vector256{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<double> Log2(Vector512<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1905,6 +1892,7 @@ public static Vector512<double> Log2(Vector512<double> vector)
}

/// <inheritdoc cref="Vector256.Log2(Vector256{float})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector512<float> Log2(Vector512<float> vector)
{
if (IsHardwareAccelerated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,9 +1170,10 @@ internal static Vector64<T> Exp<T>(Vector64<T> vector)
return result;
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <summary>Computes the exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <returns>A vector whose elements are the exp of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<double> Exp(Vector64<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1185,9 +1186,10 @@ public static Vector64<double> Exp(Vector64<double> vector)
}
}

/// <summary>Computes the Exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its Exp computed.</param>
/// <returns>A vector whose elements are the Exp of the elements in <paramref name="vector" />.</returns>
/// <summary>Computes the exp of each element in a vector.</summary>
/// <param name="vector">The vector that will have its exp computed.</param>
/// <returns>A vector whose elements are the exp of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<float> Exp(Vector64<float> vector)
{
if (IsHardwareAccelerated)
Expand Down Expand Up @@ -1632,6 +1634,7 @@ internal static Vector64<T> Log<T>(Vector64<T> vector)
/// <summary>Computes the log of each element in a vector.</summary>
/// <param name="vector">The vector that will have its log computed.</param>
/// <returns>A vector whose elements are the log of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<double> Log(Vector64<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1647,6 +1650,7 @@ public static Vector64<double> Log(Vector64<double> vector)
/// <summary>Computes the log of each element in a vector.</summary>
/// <param name="vector">The vector that will have its log computed.</param>
/// <returns>A vector whose elements are the log of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<float> Log(Vector64<float> vector)
{
if (IsHardwareAccelerated)
Expand Down Expand Up @@ -1676,6 +1680,7 @@ internal static Vector64<T> Log2<T>(Vector64<T> vector)
/// <summary>Computes the log2 of each element in a vector.</summary>
/// <param name="vector">The vector that will have its log2 computed.</param>
/// <returns>A vector whose elements are the log2 of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<double> Log2(Vector64<double> vector)
{
if (IsHardwareAccelerated)
Expand All @@ -1691,6 +1696,7 @@ public static Vector64<double> Log2(Vector64<double> vector)
/// <summary>Computes the log2 of each element in a vector.</summary>
/// <param name="vector">The vector that will have its log2 computed.</param>
/// <returns>A vector whose elements are the log2 of the elements in <paramref name="vector" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector64<float> Log2(Vector64<float> vector)
{
if (IsHardwareAccelerated)
Expand Down

0 comments on commit 7b04a92

Please sign in to comment.