可以在iOS上使用OpenCL

编程入门 行业动态 更新时间:2024-10-28 08:17:29
本文介绍了可以在iOS上使用OpenCL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在论坛上发现了这个帖子是IPad还是IPhone能够使用OpenCL?但是它已经很老了。另外,我可以收集的是,OpenCL可用于iOS的系统库,但不适用于公共。是否有更多信息或更新?

I found this thread on the forum Are either the IPad or IPhone capable of OpenCL? but is it quite old. Also, what I can gather that OpenCL is available to system libraries of iOS but not to public. Is there more info in this regard or any update ?

推荐答案

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

Even with using OpenCL as private framework, on iOS it won't give you the benefits of GPU ( or others like DSPs/FPGAs if existing ). It just gives you multiple cores available on arm processor. I ran the below code to verify the OpenCL devices accessible in iOS and OS X.

iOS上的输出

ARM CPU设备

ARM CPU Device

OS X上的输出

Radeon HD 4670 英特尔(R)酷睿(TM)i3 CPU 540 @ 3.07GHz

Radeon HD 4670 Intel(R) Core(TM) i3 CPU 540 @ 3.07GHz

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

Source with error checks excluded. Using OpenCL headers available(1) and linking OpenCL from (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/PrivateFrameworks)

#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 )。仍然不确定,出于什么原因/目的将OpenCL作为私有框架复制到iPhone上。

Suggestion: As of now, we will need to use either OpenGL(2) or Accelerate framework(3). Still not sure, for what reason/purpose OpenCL is copied in as private framework on iPhone.

更多推荐

可以在iOS上使用OpenCL

本文发布于:2023-10-24 05:57:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523111.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:iOS   OpenCL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!