Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

cross_system_copy_n: Dont attempt a copy if we're tyring to copy 0 elements #1329

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions testing/vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,19 @@ DECLARE_VECTOR_UNITTEST(TestVectorReserving)



template <class Vector>
void TestVectorUninitialisedCopy(void)
{
thrust::device_vector<int> v;
std::vector<int> std_vector;

v = std_vector;

ASSERT_EQUAL(v.size(), static_cast<size_t>(0));
}
DECLARE_VECTOR_UNITTEST(TestVectorUninitialisedCopy);


template <class Vector>
void TestVectorShrinkToFit(void)
{
Expand Down
13 changes: 7 additions & 6 deletions thrust/system/cuda/detail/internal/copy_cross_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ namespace __copy {

{
typedef typename iterator_traits<InputIt>::value_type InputTy;

trivial_device_copy(derived_cast(sys1),
derived_cast(sys2),
reinterpret_cast<InputTy*>(thrust::raw_pointer_cast(&*result)),
reinterpret_cast<InputTy const*>(thrust::raw_pointer_cast(&*begin)),
n);
if (n > 0) {
trivial_device_copy(derived_cast(sys1),
derived_cast(sys2),
reinterpret_cast<InputTy*>(thrust::raw_pointer_cast(&*result)),
reinterpret_cast<InputTy const*>(thrust::raw_pointer_cast(&*begin)),
n);
}

return result + n;
}
Expand Down