如果我使用 Nvidia 供应商的 OpenCL 编写程序,Opencl 是否仍然可以在 AMD GPU 上运行?

发布于 2025-01-13 20:50:51 字数 95 浏览 3 评论 0原文

所以我从 Nvidia 供应商下载了 OpenCL,并编写了一个程序。所以我想知道我的程序是否仍然可以在 AMD GPU 上运行,或者我需要安装 AMD 版本的 OpenCL?

So I downloaded OpenCL from Nvidia vendor, and I wrote a program. So I was wondering can my program still run on AMD GPU or I need to install AMD version of OpenCL?

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

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

发布评论

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

评论(1

厌倦 2025-01-20 20:50:51

简而言之:是的,使用 来自 Nvidia 工具包的 OpenCL 标头开发的程序也可以在 AMD 和 Intel GPU 上运行。 Nvidia GPU 的程序始终采用 OpenCL C 1.2,AMD/Intel GPU 支持 OpenCL C 1.2/2.0/2.1/2.2,始终向后兼容 OpenCL C 1.2。


但是,由于硬件的差异,您可能会遇到一些罕见的问题。

一个例子:Nvidia GPU 使用 32 个线程的“warps”,因此如果您选择工作组大小 32 或 32 的倍数,您将充分利用硬件。 AMD GCN GPU 至少需要工作组大小为 64 或 64 的倍数才能充分利用硬件。如果工作组大小只有 32,您只能获得一半的算术性能。

另一个例子:对于 Nvidia GPU,您可以在私有内存中保留相当大的表,如果太多,您会溢出到全局内存中(使其非常慢,但仍然可以正常工作而不会出现错误) 。一些 AMD GPU 无法容纳这么多私有变量,并且会在编译过程中抛出错误,因此您必须将表移动到constant内存中(然后这可以与AMD 和 Nvidia)。

In short: Yes, programs developed with the OpenCL headers from Nvidia toolkit will also work on AMD and Intel GPUs. Programs for Nvidia GPUs are always in OpenCL C 1.2, and AMD/Intel GPUs support OpenCL C 1.2/2.0/2.1/2.2, which always is backwards-compatible with OpenCL C 1.2.


However there are some rare issues that you could encounter, based on differences in the hardware.

One example: Nvidia GPUs work with "warps" of 32 threads, so if you choose the workgroup size 32 or a multiple of 32, you will fully use the hardware. AMD GCN GPUs need at least workgroup size 64 or a multiple of 64 to fully use the hardware. With only workgroup size 32 you only get half the arithmetic performance.

Another example: For Nvidia GPUs, you can have quite large tables still in private memory, and if it is too much you get a spilling into global memory (makes it very slow, but still works without error). Some AMD GPUs can't fit so many private variables and will throw an error during compiling, so you'd have to move the table in constant memory (this then works with both AMD and Nvidia).

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