Skip to content

Faster OpenMP Reorder and Accumulation Kernels#329

Merged
kaanolgu merged 3 commits into
mainfrom
329_sumintox_reorder_cpu_enhance
Jun 29, 2026
Merged

Faster OpenMP Reorder and Accumulation Kernels#329
kaanolgu merged 3 commits into
mainfrom
329_sumintox_reorder_cpu_enhance

Conversation

@kaanolgu

Copy link
Copy Markdown
Collaborator

Speeds up the OpenMP reorder and sum_intox kernels by removing the per element index computation. The transpose used to call get_index_reordering for every element, which nests two more routines doing integer mod and division per element and blocks vectorisation

This 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 one SZ block and never crosses a mod or division boundary. One output index then advances by a fixed stride while the other two stay constant. Evaluating the map at i = 1 and i = 2 recovers the base and stride, and the inner loop reproduces the original writes exactly. This needs dims(1) == SZ (a directional field). A DIR_C field has a leading dimension of nx_padded, so the kernels guard on dims(1) == SZ and fall back to the per element loop there

Performance (TGV 256^3, 100 iterations, generic 2decomp FFT)

1 rank, 24 threads:

phase before (s) after (s) change
transeq 22.0 17.3 -21%
divergence 10.0 7.32 -27%
gradient 9.5 6.79 -28%
poisson FFT 113 111 (untouched)

8 ranks, 3 threads each:

phase before (s) after (s) change
transeq 19.1 15.35 -20%
divergence 8.55 6.22 -27%
gradient 7.8 5.68 -27%
poisson FFT 18.6 18.44 (untouched)
avg step 0.576 0.508 -12%

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

@kaanolgu kaanolgu self-assigned this Jun 23, 2026
@kaanolgu kaanolgu added enhancement New feature or request omp Related to openMP backend performance labels Jun 23, 2026
@kaanolgu kaanolgu requested a review from ia267 June 29, 2026 09:53

@ia267 ia267 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kaanolgu kaanolgu merged commit 84c750f into main Jun 29, 2026
2 checks passed
@kaanolgu kaanolgu deleted the 329_sumintox_reorder_cpu_enhance branch June 29, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request omp Related to openMP backend performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants