Hi,
I would like to read back the data from an unordered map to a host vector. Before having custom pair implementation, the following code worked:
thrust::host_vector<stdgpu::pair<T1, T2>> host_vector(hash_map.size());
auto range_map = hash_map.device_range();
thrust::copy(range_map.begin(), range_map.end(), host_vector.begin());
But now it fails to compile, that there is no assignement function which takes a thrust::reference<...> object.
The best I came up with:
thrust::device_vector<stdgpu::pair<T1, T2>> device_vector(hash_map.size());
auto range_map = hash_map.device_range();
thrust::copy(range_map.begin(), range_map.end(), device_vector.begin());
thrust::host_vector<stdgpu::pair<T1, T2>> host_vector = device_vector;
But in this way, I have to duplicate memory allocation on the gpu (device_vector), which can be an issue if the map takes lots of memory.
Do you have any solution to how to copy an unordered map back to host memory? Maybe there is a very simple solution, I cannot see.
Thanks for your help.
Best, Csaba
Hi,
I would like to read back the data from an unordered map to a host vector. Before having custom
pairimplementation, the following code worked:But now it fails to compile, that there is no assignement function which takes a
thrust::reference<...>object.The best I came up with:
But in this way, I have to duplicate memory allocation on the gpu (device_vector), which can be an issue if the map takes lots of memory.
Do you have any solution to how to copy an unordered map back to host memory? Maybe there is a very simple solution, I cannot see.
Thanks for your help.
Best, Csaba