首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在iOS上是否提供OpenCL

在iOS上是否提供OpenCL
EN

Stack Overflow用户
提问于 2013-09-17 18:21:55
回答 2查看 14.1K关注 0票数 22

我在论坛Are either the IPad or IPhone capable of OpenCL?上发现了这个帖子,但是它是不是很老了?此外,我可以收集到的是,OpenCL可用于iOS的系统库,但不能用于公共库。在这方面有更多的信息或任何更新吗?

EN

回答 2

Stack Overflow用户

发布于 2015-02-02 14:40:13

即使使用OpenCL作为私有框架,基于iOS的也不会给你带来GPU (或者其他像DSP/FPGA,如果存在)的好处。它只是在arm处理器上提供了多个可用内核。我运行了以下代码来验证在iOS和OS中可以访问的OpenCL设备。

iOS上的输出

ARM处理器设备

OS X上的输出

Radeon HD 4670

英特尔(R)酷睿(TM) i3处理器540 @3.07 540

排除了错误检查的源。使用可用的OpenCL标头()和从(/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/PrivateFrameworks)链接OpenCL

代码语言:javascript
运行
复制
#include "OpenCL/cl.h"
#include <iostream>

cl_context_properties prop[] = { CL_CONTEXT_PLATFORM, 0, 0 };    
//get num of platforms
cl_uint num;
cl_int err = clGetPlatformIDs(0, 0, &num);


//get each platform
cl_platform_id *platforms = new cl_platform_id[num];
err = clGetPlatformIDs(num, platforms, &num);

//create context for platform
prop[1] = (cl_context_properties) platforms[0];
cl_context context = clCreateContextFromType(prop, CL_DEVICE_TYPE_ALL, NULL, NULL, &err);


//get num devices
size_t numDevices=0;
clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &numDevices);
cl_device_id *devices = new cl_device_id[ numDevices ];

//get every device
clGetContextInfo(context, CL_CONTEXT_DEVICES, numDevices, devices, 0);

//get info of every device
for( int idx=0; idx < numDevices; ++idx) {

    size_t bufSize=0;
    clGetDeviceInfo(devices[idx], CL_DEVICE_NAME, 0, NULL, &bufSize);
    if( bufSize > 0 ) {
        char* devName = new char[ bufSize ];
        clGetDeviceInfo(devices[idx], CL_DEVICE_NAME, bufSize, devName, 0);
        std::cout << "Device Name: " << devName << '\n';
    }
}

建议:到目前为止,我们需要使用OpenGL(2)或加速框架(3)。仍然不确定,出于什么原因/目的,在iPhone上复制OpenCL作为私有框架。

票数 13
EN

Stack Overflow用户

发布于 2013-09-17 18:48:19

只能通过内网接口获取。

F.e.https://github.com/linusyang/opencl-test-ios

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18847255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档