Skip to content

Commit 1f9c6eb

Browse files
Fix GPU, but so ugly...
1 parent d0c936b commit 1f9c6eb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@ void get_exx_potential(const K_Vectors* kv,
173173
}
174174

175175
// copy the potential to the device memory
176+
#ifdef __CUDA
177+
cudaError_t err = cudaHostRegister(pot_cpu, sizeof(Real) * npw, cudaHostRegisterPortable);
178+
if (err != cudaSuccess) {
179+
printf("临时锁定失败: %s\n", cudaGetErrorString(err));
180+
}
181+
#endif
176182
syncmem_real_c2d_op()(pot, pot_cpu, rhopw_dev->npw);
183+
#ifdef __CUDA
184+
cudaHostUnregister(pot_cpu);
185+
#endif
177186

178187
delete pot_cpu;
179188
}
@@ -341,7 +350,16 @@ void get_exx_stress_potential(const K_Vectors* kv,
341350
}
342351

343352
// copy the potential to the device memory
353+
#ifdef __CUDA
354+
cudaError_t err = cudaHostRegister(pot_cpu, sizeof(Real) * npw, cudaHostRegisterPortable);
355+
if (err != cudaSuccess) {
356+
printf("临时锁定失败: %s\n", cudaGetErrorString(err));
357+
}
358+
#endif
344359
syncmem_real_c2d_op()(pot, pot_cpu, rhopw_dev->npw);
360+
#ifdef __CUDA
361+
cudaHostUnregister(pot_cpu);
362+
#endif
345363

346364
delete pot_cpu;
347365
}

0 commit comments

Comments
 (0)