Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is available OpenCL on iOS

Tags:

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 ?

like image 619
Ankuj Avatar asked Sep 17 '13 10:09

Ankuj


People also ask

Does iOS support OpenCL?

The OpenGL ES framework ( OpenGLES. framework ) in iOS provides implementations of versions 1.1, 2.0, and 3.0 of the OpenGL ES specification.

Is OpenGL deprecated on iOS?

Apple says that apps built using OpenGL ES will continue to run in iOS 12, but Open GL ES is deprecated in iOS 12. Games and graphics-intensive apps that previously used OpenGL ES should now adopt Metal.


1 Answers

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.

Output on iOS

ARM CPU Device

Output on OS X

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

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';     } } 

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.

like image 66
kiranpradeep Avatar answered Oct 24 '22 11:10

kiranpradeep