Faster OpenMP Reorder and Accumulation Kernels#329
Merged
Conversation
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.
Speeds up the OpenMP
reorderandsum_intoxkernels by removing the per element index computation. The transpose used to callget_index_reorderingfor every element, which nests two more routines doing integermodand division per element and blocks vectorisationThis addresses the same bottleneck as #131 (related to #78), where reorders and accumulations were measured at roughly half of the transeq runtime while the per element path sustains only 10 to 20% of peak bandwidth. #131 specialises the hot transeq mappings with explicit cache blocked kernels. This PR takes an alternative, more general route: the index map advances by a fixed stride along the leading index, so the kernels compute a base and stride once per column and run a plain inner loop. Because the same routine covers every directional mapping rather than a selected few, the speedup extends across the divergence and gradient reorders as well as transeq, broadening the gain over the full step while keeping the implementation compact
Padded dimensions are exact multiples of
SZ, so the leading index stays inside oneSZblock and never crosses amodor division boundary. One output index then advances by a fixed stride while the other two stay constant. Evaluating the map ati = 1andi = 2recovers the base and stride, and the inner loop reproduces the original writes exactly. This needsdims(1) == SZ(a directional field). ADIR_Cfield has a leading dimension ofnx_padded, so the kernels guard ondims(1) == SZand fall back to the per element loop therePerformance (TGV 256^3, 100 iterations, generic 2decomp FFT)
1 rank, 24 threads:
8 ranks, 3 threads each:
At one rank the generic FFT is about 74% of the step so the total barely moves. At eight ranks the FFT has scaled down and the saving becomes a 12% step reduction, so the benefit grows with rank count