Skip to content

Commit

Permalink
Fixed the bug with illegal memory access in test_large_sizes.py with …
Browse files Browse the repository at this point in the history
…4 GPUs. (dmlc#3068)

- thrust::copy() called from dvec::copy() for gpairs invoked a GPU kernel instead of
  cudaMemcpy()
- this resulted in illegal memory access if the GPU running the kernel could not access
  the data being copied
- new version of dvec::copy() for thrust::device_ptr iterators calls cudaMemcpy(),
  avoiding the problem.
  • Loading branch information
canonizer authored and RAMitchell committed Feb 1, 2018
1 parent 98be9ae commit 24c2e41
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/common/device_helpers.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ class dvec {
}
thrust::copy(begin, end, this->tbegin());
}

void copy(thrust::device_ptr<T> begin, thrust::device_ptr<T> end) {
safe_cuda(cudaSetDevice(this->device_idx()));
if (end - begin != size()) {
throw std::runtime_error(
"Cannot copy assign vector to dvec, sizes are different");
}
safe_cuda(cudaMemcpy(this->data(), begin.get(),
size() * sizeof(T), cudaMemcpyDefault));
}
};

/**
Expand Down

0 comments on commit 24c2e41

Please sign in to comment.