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);
Run Code Online (Sandbox Code Playgroud)
Gri*_*zly 10
我不会依赖只有一个平台.如果在一个系统上有多个OpenCL实现(这应该可以使用OpenCL ICD,虽然我不确定它是仅计划还是已经完成),您应该获得多个平台,每个opencl实现一个平台.可能有多个opencl实现的一个例子是在gpu上运行opencl的nvidia实现和在cpu上运行的amd实现,因此它也不是那么遥远.
编辑:查看http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71以获取(更好)解释此内容
为了补充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
Run Code Online (Sandbox Code Playgroud)