Register GPU transfer buffers as pinned host memory
This commit is contained in:
@@ -789,6 +789,11 @@ int bssn_cuda_rk4_boundary_var(int *ex, double dT,
|
||||
double *stage_ptr = nullptr;
|
||||
const double *mapped_stage_ptr = need_stage_input ? bssn_gpu_find_device_buffer(stage_data) : nullptr;
|
||||
|
||||
bssn_gpu_prepare_host_buffer(state0, n);
|
||||
if (need_boundary_input) bssn_gpu_prepare_host_buffer(boundary_src, n);
|
||||
if (need_stage_input) bssn_gpu_prepare_host_buffer(stage_data, n);
|
||||
bssn_gpu_prepare_host_buffer(rhs_accum, n);
|
||||
|
||||
ok = ok &&
|
||||
(!refresh_state0 || copy_to_device_preferring_device(cache.state0, state0, bytes)) &&
|
||||
(!need_boundary_input || copy_to_device_preferring_device(cache.boundary, boundary_src, bytes)) &&
|
||||
@@ -931,6 +936,7 @@ int bssn_cuda_lowerbound(int *ex, double *chi, double tinny, bool download_to_ho
|
||||
bssn_gpu_register_device_buffer(chi, device_chi);
|
||||
if (download_to_host)
|
||||
{
|
||||
bssn_gpu_prepare_host_buffer(chi, n);
|
||||
cudaError_t err = cudaMemcpy(chi, device_chi, bytes, cudaMemcpyDeviceToHost);
|
||||
if (err != cudaSuccess) report_cuda_error("cudaMemcpy(D2H) chi", err);
|
||||
ok = err == cudaSuccess;
|
||||
@@ -945,7 +951,9 @@ int bssn_cuda_download_buffer(int *ex, double *host_ptr)
|
||||
if (!device_ptr)
|
||||
return 1;
|
||||
|
||||
const size_t bytes = static_cast<size_t>(count_points(ex)) * sizeof(double);
|
||||
const int n = count_points(ex);
|
||||
bssn_gpu_prepare_host_buffer(host_ptr, n);
|
||||
const size_t bytes = static_cast<size_t>(n) * sizeof(double);
|
||||
cudaError_t err = cudaMemcpy(host_ptr, device_ptr, bytes, cudaMemcpyDeviceToHost);
|
||||
if (err != cudaSuccess)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user