CUDA 中的动态分配 - 比手写解决方案更少的争用?

发布于 2024-10-07 01:50:32 字数 168 浏览 0 评论 0原文

现在 CUDA 允许动态分配全局内存。但是,我找不到任何关于 malloc 函数可扩展性的参考:例如,它比预分配一块内存然后将下一个内存卡盘分配给线程更好吗?原子地递增全局整数?最后一个“自制”解决方案有效,但在可扩展性方面存在明显的问题,所以我想知道 malloc 是否以某种方式解决这个问题。

Now CUDA allows dynamic allocation on the global memory. However, I couldn't find any reference to the scalability of that malloc function: is it any better than, for instance, preallocate a chunk of memory and then just assign the next memory chuck to a thread by atomically incrementing a global integer? This last "home-made" solution works but there is an obvious problem with scalability, so I wonder whether malloc takes care of that somehow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两人的回忆 2024-10-14 01:50:32

我认为,虽然您的“自制”解决方案目前可能同样好,但对全局整数的并发调用可能会减慢速度,但 Malloc 将是我的选择。

这是因为它允许 Nvidia 处理令人头痛的可扩展性,并在硬件或软件实现方面进行改进,您只需在以后重新编译代码即可利用这些改进。

I think while your "home-made" solution might be just as good currently, although concurrent calls to a global integer might slow it down, Malloc would be my choice.

This is because it allows for Nvidia to deal with the headache of scalability and to make improvements, in either the hardware or software implementation, that you can taken advantage of just by re-compiling your code at a later date.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文