是否有任何 OpenCL 主机拥有多个平台?
Khronos 的 OpenCL 1.0 和 1.1 规范中平台的定义:
平台:主机加上由 OpenCL 框架管理的设备集合,允许应用程序共享资源并在平台中的设备上执行内核。
OpenCL 函数 clGetPlatformIDs 创建一个数组平台的数量,意味着可以有多个平台。假设给定的 OpenCL 主机只有一个平台是否安全?
换句话说,这样做我会在任何主机上丢失任何东西吗:
cl_platform_id platform_id;
cl_uint num_platforms;
errcode = clGetPlatformIDs(1, &platform_id, &num_platforms);
The definition of a platform in Khronos' OpenCL 1.0 and 1.1 specification:
Platform: The host plus a collection of devices managed by the OpenCL framework that allow an application to share resources and execute kernels on devices in the platform.
The OpenCL function clGetPlatformIDs creates an array of platforms, implying that multiple platforms are possible. Is it safe to assume that a given OpenCL host has only one platform?
In other words, will I lose anything on any host by doing this:
cl_platform_id platform_id;
cl_uint num_platforms;
errcode = clGetPlatformIDs(1, &platform_id, &num_platforms);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不会依赖只有一个平台。当您在一个系统上有多个 OpenCL 实现时(这应该可以通过 OpenCL ICD 实现,尽管我不确定这是否只是计划中或已经完成),您应该获得多个平台,每个 opencl 实现一个。可能有多个 opencl 实现的一个例子是,nvidia 实现在 gpu 上运行 opencl,而 amd 实现在 cpu 上运行,因此它也不是那么牵强。
编辑:查看 http://developer.amd.com /support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71(更好)对此的描述
I wouldn't rely on there being only one Platform. When you have multiple OpenCL implementations on one system (which should be possible with the OpenCL ICD, although I'm not sure if that is only planned or already finished), you should get multiple platforms, one for each opencl implementation. One example where there could be multiple opencl implementations would be an nvidia implementation to run opencl on gpu and an amd implementation to run on cpu, so that it not that far fetched either.
edit: look at http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71 for (better) desciption of this
用一个例子来补充 Tim Child 的答案(安装了 AMD 和 Intel SDK 的 Thinkpad X201):
To complement the answer of Tim Child with an example (Thinkpad X201 with both AMD and Intel SDK's installed):
是的,每个供应商的 OpenCL 安装都有一个平台 ID。因此,如果您安装 AMD 和 Intel 的 OpenCL SDK,您将获得每个平台的一个平台 ID。
Yes, there is one Platform Id for each vendors OpenCL installation. So if you install AMD's and Intel's OpenCL SDK's you will get one Platform Id for each.
即使您假设主机只有一个平台,您也必须在调用 clGetPlatformInfo。因此,最好调用 clGetPlatformIDs,选择默认或用户提供的平台,然后调用 clGetPlatformInfo。
Even if you assume that a host has only one platform, you would have to figure out what the Id of that platform is, before calling clGetPlatformInfo. So its better if you call clGetPlatformIDs, pick up a default or user supplied platform and then call clGetPlatformInfo.