diff --git a/src/cuda/api/memory.hpp b/src/cuda/api/memory.hpp index 89f35dc3..d0001a2e 100644 --- a/src/cuda/api/memory.hpp +++ b/src/cuda/api/memory.hpp @@ -776,7 +776,7 @@ status_t multidim_copy(context::handle_t context_handle, copy_parameters_t{}, params); } -} // namespace detail +} // namespace detail_ /** * Synchronously copies data from a CUDA array into non-array memory. @@ -829,7 +829,7 @@ void copy(T *destination, const array_t& source) } template -void copy(array_t destination, array_t source) +void copy(const array_t& destination, const array_t& source) { detail_::copy_parameters_t params{}; auto dims = source.dimensions(); @@ -845,7 +845,6 @@ void copy(array_t destination, array_t sourc throw_if_error_lazy(status, "Copying from a CUDA array into a regular memory region"); } - template void copy(region_t destination, const array_t& source) { @@ -855,6 +854,15 @@ void copy(region_t destination, const array_t& source) copy(destination.start(), source); } +template +void copy(const array_t& destination, const_region_t & source) +{ + if (destination.size_bytes() < source.size()) { + throw ::std::logic_error("Attempt to copy into an array from a source region larger than the array's size"); + } + copy(destination, source.start()); +} + /** * Synchronously copies a single (typed) value between two memory locations. *