Commit 4b847b6
[Fix] Eliminate unnecessary vkb CPU allocation on GPU path (#7296)
* [Fix] Skip unnecessary vkb CPU allocation on GPU path in pseudopot_cell_vnl
On GPU path, vkb.create(nkb, npwx) allocates CPU ComplexMatrix memory
that is never used — getvnl() writes directly to GPU buffers (c_vkb/z_vkb).
The only consumer of vkb.nc metadata is the leading dimension in gemm/gemv.
This wastes nkb*npwx*16 bytes of CPU memory (~3.2 GB for large systems).
Changes:
- Add vkbnc member to store column dimension independently
- Guard vkb.create() behind !use_gpu_ in init()
- Replace all ppcell->vkb.nc with ppcell->vkbnc (op_pw_nl.cpp, hamilt_pw.cpp)
- Add lazy-allocation guard in getgradq_vnl() for GPU Velocity path
Tested: GPU build + 28/28 kernel UTs + 38/40 GPU integration tests
(2 pre-existing failures: scf_bpcg, scf_out_wf)
* Update source/source_pw/module_pwdft/vnl_pw_grad.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update source/source_pw/module_pwdft/vnl_pw_grad.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Revert "Update source/source_pw/module_pwdft/vnl_pw_grad.cpp"
This reverts commit b71e3fe.
* Revert "Update source/source_pw/module_pwdft/vnl_pw_grad.cpp"
This reverts commit a0f43dc.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent e882c33 commit 4b847b6
5 files changed
Lines changed: 26 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
379 | | - | |
| 379 | + | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | | - | |
220 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
221 | 228 | | |
222 | 229 | | |
223 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| |||
0 commit comments