perf: improve fsum speed via multiple accumulators (issue #824)#826
Open
perf: improve fsum speed via multiple accumulators (issue #824)#826
Conversation
Use FSUM_N_ACC=4 independent accumulators in fsum_double_impl and fsum_double_omp_impl (no-NA path). This breaks the serial dependency chain on a single sum variable, allowing the compiler's auto-vectorizer to emit SIMD instructions. On macOS without OpenMP configured, #pragma omp simd is silently ignored leaving no SIMD; the multiple accumulator approach provides ~7x speedup in that case. On Linux with OpenMP+AVX the same approach gives ~2x speedup even over the existing omp simd path. Closes #824 Co-authored-by: Sebastian Krantz <SebKrantz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incorporates the loop unrolling optimization proposed in #824 by @TylerSagendorf.
Adds
#define FSUM_N_ACC 4and uses 4 independent accumulators in thena.rm = FALSEpath offsum_double_implandfsum_double_omp_impl.Why it helps: A single accumulator creates a serial data dependency chain that prevents SIMD vectorization. Multiple independent accumulators break this chain, allowing the compiler's auto-vectorizer to issue SIMD instructions. On macOS without OpenMP,
#pragma omp simdis silently ignored so this is the only way to get SIMD.Closes #824
Generated with Claude Code