We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider implementing time-series vector method (reverted due to minor floating-point related test errors, from diff of parallel calculations)
... double sum = 0; int start = i - lookbackPeriods + 1; int end = i + 1; // SIMD optimization int vectorSize = Vector<double>.Count; int simdEnd = start + ((end - start) / vectorSize * vectorSize); for (int p = start; p < simdEnd; p += vectorSize) { Vector<double> vector = new(values, p); sum += Vector.Sum(vector); } for (int p = simdEnd; p < end; p++) { sum += values[p]; } sma = sum / lookbackPeriods; ...
Note
.NET blogs say this is 10x faster and more stable in the upcoming .NET 9 release (November)
Originally posted by @DaveSkender in #1230 (comment)
The text was updated successfully, but these errors were encountered:
Also consider FMA, but requires minimum.NET 7 targeting for better outcomes
using System.Numerics; public static float DotProductFMA(float[] a, float[] b) { var sum = new Vector<float>(0); int i = 0; for (; i <= a.Length - Vector<float>.Count; i += Vector<float>.Count) { sum = Vector<float>.FusedMultiplyAdd(new Vector<float>(a, i), new Vector<float>(b, i), sum); } float result = Vector.Sum(sum); for (; i < a.Length; i++) { result += a[i] * b[i]; } return result; }
Sorry, something went wrong.
No branches or pull requests
Consider implementing time-series vector method (reverted due to minor floating-point related test errors, from diff of parallel calculations)
Note
.NET blogs say this is 10x faster and more stable in the upcoming .NET 9 release (November)
Originally posted by @DaveSkender in #1230 (comment)
The text was updated successfully, but these errors were encountered: