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 o
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.
Available only through private API.
F.e. https://github.com/linusyang/opencl-test-ios