在混合供应商的硬件上运行 OpenCL
我一直在他们的 Stream 2.0 beta 中使用 ATI OpenCL 实现。当前测试版中的 OpenCL 目前仅使用 CPU,下一版本应该支持 GPU 内核。我下载 Stream 是因为我的工作机器上有 ATI GPU。
我编写的软件可以通过使用 GPU 获得巨大收益。然而,该软件在客户计算机上运行,我没有奢侈(正如许多科学计算环境所拥有的那样)来选择要为其开发和优化的确切硬件。所以我的问题是,如果我将 ATI OpenCL 实现与我的应用程序一起分发,这是否意味着它将永远无法使用 NVidia 显卡等?如果我使用 NVidia OpenCL SDK,它永远不会在 AMD 芯片上以最佳状态运行(考虑 ATI/AMD 链接)?
换句话说,最终谁负责提供OpenCL的实现?用户是否能够为其 NVidia 显卡安装 OpenCL“驱动程序”以及为他们的 AMD CPU 提供最佳性能的“驱动程序”?
顺便说一句,除了 Khronos 留言板之外,OpenCL 是否还有任何好的/活跃的支持论坛,或者这是一个可以去的地方?我看到 ATI 有一块主板,NVidia 大概也有自己的主板,OpenCL 用户/开发人员社区在哪里闲逛?难道已经合并到一处了吗?
I've been playing with the ATI OpenCL implementation in their Stream 2.0 beta. The OpenCL in the current beta only uses the CPU for now, the next version is supposed to support GPU kernels. I downloaded Stream because I have an ATI GPU in my work machine.
I write software that would benefit hugely from gains by using the GPU. However this software runs on customer machines, I don't have the luxury (as many scientific computing environments have) to choose the exact hardware to develop for, and optimize for that. So my question is, if I distribute the ATI OpenCL implementation with my application, will that mean it will never be able to use e.g. NVidia video cards? And if I use the NVidia OpenCL SDK, that it will never run optimally on AMD chips (considering the ATI/AMD link)?
On other words, who is in the end responsible for providing the OpenCL implementation? Will users be able to e.g. install an OpenCL 'driver' for their NVidia video card, alongside a 'driver' that gives them optimal performance on their AMD CPU?
As an aside, are there any good/active support forums for OpenCL apart from the Khronos message boards, or is that the place to go? I've seen that ATI has a board, and NVidia presumably has their own, where does the OpenCL user/developer community hang out? Has it already consolidated into one place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个老问题,上面有旧答案。我想我会用最新的答案来更新它。
是的,只要正确编写平台和设备枚举代码,OpenCL 内核和代码的一种实现就可以在当今的各种设备上运行。编写正确的平台和设备枚举代码非常容易,棘手的部分是选择哪个平台或设备。您可能应该在应用程序中提供一个配置选项,用户可以在其中选择一个,或者针对每个选项运行微基准测试并动态选择一个并缓存基准结果。
人们可以而且将会拥有多个平台。例如,我的系统有 GTX 580 SLI,因此它在 NVidia 平台上有两个设备。它还具有 Intel OpenCL SDK,因此我的 CoreI7 990x Extreme CPU 也作为 Intel 平台中的设备出现。
是的,使用 NVidia OpenCL SDK 等开发和构建的二进制文件将在 ATI 或 Intel OpenCL 上运行,反之亦然。不用再担心这个了。
显然,最终用户可能没有任何 OpenCL,因此您可能需要延迟加载或 LoadLibrary opencl.dll 和动态链接。
我强烈建议在 NVidia GPU 和 AMD GPU 上针对 Intel OpenCL SDK 测试您的代码。您可能会发现在一个平台上导致问题的错误,但在其他平台上运行良好。您还可能会发现,由于驱动程序错误,完全良好的代码在这些平台之一上神秘地无法给出正确的结果。
I know this is an old question with old answers above. Thought I would update it with an up to date answer.
Yes, one implementation of OpenCL kernels and code will work on a wide variety of devices today with correctly written platform and device enumeration code. It is pretty easy to write correct platform and device enumeration code, the tricky part is selecting which platform or device. You should probably present a configuration option in your app where the user can select one, or run a microbenchmark against each one and dynamically select one and cache the bench result.
People can and will have more than one platform. For example, my system has GTX 580 SLI, so it has two devices in the NVidia platform. It also has the Intel OpenCL SDK, so my CoreI7 990x Extreme CPU also comes up as a device in the Intel platform.
Yes a binary developed and built using, for example, the NVidia OpenCL SDK, will work on ATI or Intel OpenCL, and vice versa. No need to worry about that anymore.
Obviously, an end user might have no OpenCL whatsoever, so you may need to delay-load or LoadLibrary opencl.dll and dynamic link.
I stronly suggest testing your code against the Intel OpenCL SDK, on NVidia GPUs, AND on AMD GPUs. You will probably find bugs that cause problems on one platform, but works fine on others. You will also probably find that totally fine code mysteriously doesn't give correct results on one of those platforms, due to driver bugs.
最终,OpenCL 将以与 OpenGL 相同的方式工作。也就是说,用户将安装来自其硬件供应商(ATI、NVIDIA、Intel)的最新驱动程序。作为开发人员,您在构建应用程序时只需链接 OpenCL 库即可。当用户运行您的应用程序时,应用程序将重定向到驱动程序提供的适当供应商特定库。
这就是它的工作方式,但它还没有以这种方式工作。
另一件需要记住的重要事情是,您可能仍然需要提供供应商特定的代码路径,因为使用 OpenCL 在 CPU 上运行的代码可能会使用与在 GPU 上运行的代码不同的优化内核参数。 GPU 供应商之间的差异可能也是如此。
Ultimately, OpenCL will work the same way as OpenGL. That is, users will install the current drivers from their hardware vendors (ATI, NVIDIA, Intel). You as the developer will simply link against an OpenCL library when building your applications. When users run your application, the application will redirect to the appropriate vendor specific libraries provided by the drivers.
This is the way it will work, but it does not yet work in this way.
Another important thing to keep in mind is that you will still probably have to provide vendor specific code paths as code running on the CPU using OpenCL will probably use different optimized kernel parameters than code running on the GPU. The same is probably true for differences between GPU vendors.