是否有任何 OpenCL 主机拥有多个平台?

发布于 2024-09-13 18:51:49 字数 574 浏览 4 评论 0原文

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 技术交流群。

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

发布评论

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

评论(4

伤痕我心 2024-09-20 18:51:49

我不会依赖只有一个平台。当您在一个系统上有多个 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

厌倦 2024-09-20 18:51:49

用一个例子来补充 Tim Child 的答案(安装了 AMD 和 Intel SDK 的 Thinkpad X201):

$ python /usr/share/doc/python-pyopencl/examples/benchmark-all.py
Execution time of test without OpenCL:  10.9563219547 s
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 1.1 AMD-APP-SDK-v2.5 (684.213)
---------------------------------------------------------------
Device name: Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
Device type: CPU
Device memory:  7799 MB
Device max clock speed: 2399 MHz
Device compute units: 2
Execution time of test: 0.00842799 s
Results OK
===============================================================
Platform name: Intel(R) OpenCL
Platform profile: FULL_PROFILE
Platform vendor: Intel(R) Corporation
Platform version: OpenCL 1.1 LINUX
---------------------------------------------------------------
Device name: Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
Device type: CPU
Device memory:  7799 MB
Device max clock speed: 2400 MHz
Device compute units: 2
Execution time of test: 0.00260659 s
Results OK

To complement the answer of Tim Child with an example (Thinkpad X201 with both AMD and Intel SDK's installed):

$ python /usr/share/doc/python-pyopencl/examples/benchmark-all.py
Execution time of test without OpenCL:  10.9563219547 s
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 1.1 AMD-APP-SDK-v2.5 (684.213)
---------------------------------------------------------------
Device name: Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
Device type: CPU
Device memory:  7799 MB
Device max clock speed: 2399 MHz
Device compute units: 2
Execution time of test: 0.00842799 s
Results OK
===============================================================
Platform name: Intel(R) OpenCL
Platform profile: FULL_PROFILE
Platform vendor: Intel(R) Corporation
Platform version: OpenCL 1.1 LINUX
---------------------------------------------------------------
Device name: Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
Device type: CPU
Device memory:  7799 MB
Device max clock speed: 2400 MHz
Device compute units: 2
Execution time of test: 0.00260659 s
Results OK
清晰传感 2024-09-20 18:51:49

是的,每个供应商的 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.

最终幸福 2024-09-20 18:51:49

即使您假设主机只有一个平台,您也必须在调用 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.

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