diff --git a/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp b/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp index 89918e16c8d..8c2c6dd1402 100644 --- a/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp +++ b/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp @@ -173,7 +173,16 @@ void get_exx_potential(const K_Vectors* kv, } // copy the potential to the device memory +#ifdef __CUDA + cudaError_t err = cudaHostRegister(pot_cpu, sizeof(Real) * npw, cudaHostRegisterPortable); + if (err != cudaSuccess) { + throw std::runtime_error("failed to register potential CPU memory operations"); + } +#endif syncmem_real_c2d_op()(pot, pot_cpu, rhopw_dev->npw); +#ifdef __CUDA + cudaHostUnregister(pot_cpu); +#endif delete pot_cpu; } @@ -341,7 +350,16 @@ void get_exx_stress_potential(const K_Vectors* kv, } // copy the potential to the device memory +#ifdef __CUDA + cudaError_t err = cudaHostRegister(pot_cpu, sizeof(Real) * npw, cudaHostRegisterPortable); + if (err != cudaSuccess) { + throw std::runtime_error("failed to register potential CPU memory operations"); + } +#endif syncmem_real_c2d_op()(pot, pot_cpu, rhopw_dev->npw); +#ifdef __CUDA + cudaHostUnregister(pot_cpu); +#endif delete pot_cpu; }