Skip to content

Fix GPU segfaults in PW USPP calculations#7645

Closed
chengleizheng wants to merge 6 commits into
deepmodeling:developfrom
chengleizheng:develop
Closed

Fix GPU segfaults in PW USPP calculations#7645
chengleizheng wants to merge 6 commits into
deepmodeling:developfrom
chengleizheng:develop

Conversation

@chengleizheng

Copy link
Copy Markdown

Summary

Fix GPU segfaults in PW USPP calculations caused by CPU code accessing GPU
memory pointers. Added CPU intermediate buffers and D2H/H2D sync patterns
in three USPP-specific code paths.

Changes

  • hamilt_pw: sPsi reads qq_nt from CPU backup (qq_nt.ptr) instead of
    GPU pointer, fills a CPU buffer, then syncs to GPU for cuBLAS.

  • elecstate_pw (cal_becsum): becp computed on GPU via gemm then synced
    to CPU; auxk1/auxk2 use CPU vectors; aux_gk computed on GPU then synced
    to CPU; becsum allocated on CPU (consumed by CPU-only force/stress code).

  • elecstate_pw (add_usrho): Added D2H/H2D wrappers around real2recip
    and recip2real FFT calls, which read/write via CPU loops.

  • elecstate_pw (addusdens_g): Rewritten to use pure CPU computation
    (CPU BLAS zgemm_, CPU radial_fft_q); ylmk0 computed on GPU with H2D'd
    gcar then D2H'd back.

Test plan

  • Run PW USPP test cases (003, 008, 009) on GPU, verify no segfault
  • Run compute-sanitizer to confirm 0 GPU memory errors

chengleizheng and others added 6 commits May 29, 2026 16:51
…t2ia lookup arrays and added #pragma omp parallel for guarded by #ifdef _OPENMP in runner() coord building, runner() force assignment, and type_map() atype assignment.
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