Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions source/source_pw/module_pwdft/op_pw_exx_pot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,23 @@ 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");
if (PARAM.inp.device == "gpu")
{
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);
if (PARAM.inp.device == "gpu")
{
cudaHostUnregister(pot_cpu);
}
#endif

delete pot_cpu;
delete[] pot_cpu;
}

template <typename Real, typename Device>
Expand Down Expand Up @@ -369,17 +375,23 @@ 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");
if (PARAM.inp.device == "gpu")
{
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);
if (PARAM.inp.device == "gpu")
{
cudaHostUnregister(pot_cpu);
}
#endif

delete pot_cpu;
delete[] pot_cpu;
}

double exx_divergence(Conv_Coulomb_Pot_K::Coulomb_Type coulomb_type,
Expand Down
Loading