Skip to content

Question aboout host copy #432

Description

@siposcsaba89

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions