Skip to content

perf(xc): distribute Libxc batches across OpenMP threads - #35

Draft
Stardust0831 wants to merge 1 commit into
review/ri-performance-base-20261101from
perf/libxc-omp-batches
Draft

Stardust0831 wants to merge 1 commit into
review/ri-performance-base-20261101from
perf/libxc-omp-batches

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What's changed?

Libxc loops already process 1024 grid points per iteration. Scheduling another 1024 iterations per OpenMP chunk can leave most threads idle. Use schedule(static) in the four existing loops so batches are distributed across threads.

This changes four pragmas in libxc_pot.cpp. It applies to the shared CPU Libxc evaluation used by LCAO and PW; there is no new option or dependency.

Performance

System Stage Baseline (s) This PR (s) Paired speedup
Si32 Libxc evaluation 77.87–88.66 19.51–22.70 3.91–3.99x
Si32 Effective potential 98.46–110.97 40.89–46.17 2.40–2.41x
Si32 Complete SCF + forces + stress 182.22–203.71 122.53–138.02 1.48–1.49x
CsPbI3 Libxc evaluation 42.56–42.75 10.29–10.86 3.94–4.13x
CsPbI3 Effective potential 47.81–48.09 15.34–16.11 2.98–3.12x
CsPbI3 Complete SCF + forces + stress 424.48–426.14 391.86–396.49 1.07–1.08x

Ranges cover two paired runs in separate allocations; speedups are computed within each pair.

HSE SCF, forces and stress on Si32 and CsPbI3 (5 atoms), using one V100, one MPI rank, four physical CPU cores/OpenMP threads and serial BLAS on SAI. Libxc 7.0.0; cuSOLVER diagonalization and CPU LibRI contractions in both versions. Each candidate is compared with unmodified d20090cc137f; two repetitions reverse the execution order. Reported performance pairs have identical SCF iteration counts.

The Libxc timer measures the changed evaluation loops. Potential::cal_veff includes other potential work. These nested timers are reported separately.

Unit Tests and/or Case Tests for my changes

Maximum differences across the 29 completed calculations are 2.2e-11 eV/atom, 2.3e-09 eV/Angstrom and 9.6e-09 kbar. These checks establish agreement with the baseline, not absolute force accuracy. All matched SCF iteration counts agree. Validation includes one-thread controls, CPU execution, a build with CUDA disabled, and complex tensors on a 2x1x1 k mesh with two MPI ranks/GPUs.

The standalone CUDA executable and existing XC tests pass. Commands, with paths relative to the build root:

cmake --build build --target abacus_std_gpu MODULE_HAMILT_XCTest_VXC --parallel 24
OMP_NUM_THREADS=1 ctest --test-dir build -V -R '^(MODULE_HAMILT_XCTest_VXC)$'
OMP_NUM_THREADS=4 ctest --test-dir build -V -R '^(MODULE_HAMILT_XCTest_VXC)$'

Inputs, individual timings, numerical comparisons and test logs. All benchmark executables enable the same existing full-precision timer JSON output; that instrumentation is absent from these PRs.

Linked Issue

Related performance study: #30. Independently reviewable part of #32.

Governance Notes

Companion changes: integral evaluation and radial tables. All three branches start at the same frozen develop commit, have no prerequisite PR, and merge in all six orders without conflicts or differences in the resulting tree.

No documentation update required: numerical settings, INPUT metadata and interfaces are unchanged. Core impact is limited to OpenMP scheduling in XC evaluation. No governance exception is requested.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant