20#include <cuspatial/traits.hpp>
22#include <rmm/device_uvector.hpp>
24#include <thrust/for_each.h>
25#include <thrust/host_vector.h>
46template <
typename T,
typename Vector>
47thrust::host_vector<T> to_host(Vector
const& dvec)
49 if constexpr (std::is_same_v<Vector, rmm::device_uvector<T>>) {
50 thrust::host_vector<T> hvec(dvec.size());
51 cudaMemcpyAsync(hvec.data(),
53 dvec.size() *
sizeof(T),
54 cudaMemcpyKind::cudaMemcpyDeviceToHost,
56 dvec.stream().synchronize();
59 return thrust::host_vector<T>(dvec);
72template <
typename Iter,
typename T = cuspatial::iterator_value_type<Iter>>
73thrust::host_vector<T> to_host(Iter begin, Iter end)
75 return thrust::host_vector<T>(begin, end);
89template <
typename Iter>
90void print_device_range(Iter begin,
92 std::string_view pre =
"",
93 std::string_view post =
"\n")
95 auto hvec = to_host(begin, end);
98 std::for_each(hvec.begin(), hvec.end(), [](
auto const& x) { std::cout << x <<
" "; });
112template <
typename Vector>
113void print_device_vector(Vector
const& vec, std::string_view pre =
"", std::string_view post =
"\n")
115 using T =
typename Vector::value_type;
116 auto hvec = to_host<T>(vec);
119 std::for_each(hvec.begin(), hvec.end(), [](
auto const& x) { std::cout << x <<
" "; });