Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unordered_maps with complex containers #242

Open
suds12 opened this issue May 14, 2021 · 1 comment
Open

Unordered_maps with complex containers #242

suds12 opened this issue May 14, 2021 · 1 comment

Comments

@suds12
Copy link

suds12 commented May 14, 2021

Don't know if this feature already exists but do unordered_maps support structures other than <int,int> like <int,stdgpu::unordered_set>. Similarly can unordered_set support <pair<int,int>> using a hashing function from boost::hash<pair<int, int>> or vectors using your own hashing function for vectors.

This library is excellent btw! Solves so many issues with support for STL like containers for GPU :)

@stotko
Copy link
Owner

stotko commented May 14, 2021

Yes, in principle arbitrary types for the Key and T types of stdgpu::unordered_map container (stdgpu::unordered_setlikewise) are supported. int, int is just one very simple choice in the examples. You can use any type with the corresponding hash function. The only requirement is that the hash function is callable both on the host and the device, i.e. it should have the __host__ __device__ attribute for CUDA code or the portable STDGPU_HOST_DEVICE version.

Nesting containers, i.e. stdgpu::unordered_map<int, stdgpu::unordered_map<int, float>, is not prohibited, but not fully supported as in the C++ standard library due to the more complicated memory handling for GPU code. stdgpu::unordered_map<thrust::pair<int, int>, float> might be better in such cases.

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

No branches or pull requests

2 participants