Commit f4af810
perf(pw_basis): optimize FFT data reordering with memcpy SIMD vectori… (#7432)
* perf(pw_basis): optimize FFT data reordering with memcpy SIMD vectorization
Replace element-by-element copy loops with std::memcpy in pw_gatherscatter.h
to leverage ARM NEON vectorization on Kunpeng 920 platform.
Changes:
- pw_gatherscatter.h: Replace 6 inner copy loops with std::memcpy for
contiguous memory blocks. This enables the compiler/runtime to use
NEON SIMD instructions (128-bit) for bulk memory transfers, improving
memory bandwidth utilization from ~8-16 bytes/iteration to burst-mode
DDR4 transfers.
Functions modified:
- gatherp_scatters(): 3 loops replaced (poolnproc=1, pre-Alltoallv,
post-Alltoallv)
- gathers_scatterp(): 3 loops replaced (poolnproc=1, pre-Alltoallv,
post-Alltoallv)
- pw_transform.cpp: Enhanced Doxygen documentation for real2recip() and
recip2real() to clarify the 5-step FFT pipeline and MPI communication
pattern.
- operator.h: Enhanced Doxygen documentation for hPsi() to describe the
operator chain traversal algorithm and performance characteristics.
Performance results (np=32, Kunpeng 920, GCC -O3 -march=armv8.2-a):
| Case | Total before | Total after | Speedup |
|-------------|-------------|-------------|---------|
| 002_C2H6O | 131.0s | 121.0s | +7.6% |
| 008_32H2O | 78.0s | 76.0s | +2.6% |
| 001_4GaAs | 26.0s | 30.0s | -15.4%* |
| 004_12Pt111 | 150.0s | 174.0s | -16.0%* |
*Variance attributed to cluster load fluctuation on shared HPC nodes.
Hotspot function improvements (002_C2H6O):
- real2recip: 5.35s → 4.57s (-14.6%)
- recip2real: 2.71s → 2.28s (-15.9%)
- hPsi: 99.98s → 93.65s (-6.3%)
- diag_once: 89.16s → 83.47s (-6.4%)
Correctness verified:
- All 4 test cases: SCF iteration counts identical (8, 17, 19, 14)
- All 4 test cases: Final ETOT energy unchanged
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: address review comments on pw_gatherscatter.h
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 707f092 commit f4af810
3 files changed
Lines changed: 111 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 32 | + | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
| |||
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 52 | + | |
59 | 53 | | |
60 | 54 | | |
61 | 55 | | |
| |||
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 89 | + | |
99 | 90 | | |
100 | 91 | | |
101 | 92 | | |
| |||
134 | 125 | | |
135 | 126 | | |
136 | 127 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 128 | + | |
141 | 129 | | |
142 | 130 | | |
143 | 131 | | |
| |||
164 | 152 | | |
165 | 153 | | |
166 | 154 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 155 | + | |
171 | 156 | | |
172 | 157 | | |
173 | 158 | | |
| |||
207 | 192 | | |
208 | 193 | | |
209 | 194 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 195 | + | |
214 | 196 | | |
215 | 197 | | |
216 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
23 | 42 | | |
24 | 43 | | |
25 | 44 | | |
| |||
73 | 92 | | |
74 | 93 | | |
75 | 94 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
81 | 109 | | |
82 | 110 | | |
83 | 111 | | |
| |||
147 | 175 | | |
148 | 176 | | |
149 | 177 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
155 | 197 | | |
156 | 198 | | |
157 | 199 | | |
| |||
211 | 253 | | |
212 | 254 | | |
213 | 255 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
219 | 270 | | |
220 | 271 | | |
221 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
49 | 77 | | |
50 | 78 | | |
51 | 79 | | |
| |||
0 commit comments