9

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);
4

4 回答 4

10

我不会依赖只有一个平台。当您在一个系统上有多个 OpenCL 实现时(使用 OpenCL ICD 应该可以实现,尽管我不确定这是否只是计划中的还是已经完成),您应该获得多个平台,每个 opencl 实现一个平台。可能有多个 opencl 实现的一个示例是在 gpu 上运行 opencl 的 nvidia 实现和在 cpu 上运行的 amd 实现,因此它也不是那么牵强。

编辑:查看http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71以获得(更好的)描述

于 2010-08-26T02:45:59.573 回答
8

用一个例子来补充 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
于 2012-01-17T21:37:13.330 回答
3

是的,每个供应商的 OpenCL 安装都有一个平台 ID。因此,如果您安装 AMD 和 Intel 的 OpenCL SDK,您将分别获得一个平台 ID。

于 2011-07-28T18:09:32.087 回答
0

即使您假设主机只有一个平台,您也必须在调用clGetPlatformInfo之前弄清楚该平台的 Id 是什么。因此,最好调用 clGetPlatformIDs,选择默认或用户提供的平台,然后调用 clGetPlatformInfo。

于 2010-08-10T12:30:17.973 回答