CUDA - 实现设备哈希映射? [英] CUDA - Implementing Device Hash Map?

查看:33
本文介绍了CUDA - 实现设备哈希映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有在 CUDA 设备上实现哈希映射的经验?具体来说,我想知道如何在设备上分配内存并将结果复制回主机,或者是否有任何有用的库可以促进这项任务.

Does anyone have any experience implementing a hash map on a CUDA Device? Specifically, I'm wondering how one might go about allocating memory on the Device and copying the result back to the Host, or whether there are any useful libraries that can facilitate this task.

似乎我需要先验知道哈希映射的最大大小才能分配设备内存.我之前的所有 CUDA 尝试都使用了数组和 memcpys,因此相当简单.

It seems like I would need to know the maximum size of the hash map a priori in order to allocate Device memory. All my previous CUDA endeavors have used arrays and memcpys and therefore been fairly straightforward.

感谢您对此问题的任何见解.谢谢.

Any insight into this problem are appreciated. Thanks.

推荐答案

Jason Sanders 和 Edward Kandrot 在CUDA 示例"中介绍了一个 GPU 哈希表实现.

There is a GPU Hash Table implementation presented in "CUDA by example", from Jason Sanders and Edward Kandrot.

幸运的是,您可以在此页面上获取有关本书的信息并免费下载示例源代码:
http://developer.nvidia.com/object/cuda-by-example.html

Fortunately, you can get information on this book and download the examples source code freely on this page:
http://developer.nvidia.com/object/cuda-by-example.html

在此实现中,表在 CPU 上预先分配,安全的多线程访问由基于原子函数 atomicCAS(比较和交换)的锁定函数确保.

In this implementation, the table is pre-allocated on CPU and safe multithreaded access is ensured by a lock function based upon the atomic function atomicCAS (Compare And Swap).

此外,与 CUDA >= 4.0 相结合的较新硬件一代(从 2.0 开始)应该能够在 GPU 上直接使用 new/delete 运算符(http://developer.nvidia.com/object/cuda_4_0_RC_downloads.html?utm_source=http://forums.nvidia.com&utm_medium=http://forums.nvidia.com&utm_term=Developers&utm_content=Developers&utm_campaign=CUDA4 ),其中可以为您的实施服务.我还没有测试过这些功能.

Moreover, newer hardware generation (from 2.0) combined with CUDA >= 4.0 are supposed to be able to use directly new/delete operators on the GPU ( http://developer.nvidia.com/object/cuda_4_0_RC_downloads.html?utm_source=http://forums.nvidia.com&utm_medium=http://forums.nvidia.com&utm_term=Developers&utm_content=Developers&utm_campaign=CUDA4 ), which could serve your implementation. I haven't tested these features yet.

这篇关于CUDA - 实现设备哈希映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆