OpenCL 1.1 for iOS Device

Hi, all.

I’m trying to implement OpenCL for my project.


err = clGetPlatformIDs(0, 0, &num);
    if (err != CL_SUCCESS)
    {
        printf("Error: Failed to get platforms!
");
        return EXIT_FAILURE;
    }
    platforms = (cl_platform_id *) malloc(sizeof(cl_platform_id) * num);
    err = clGetPlatformIDs(num, platforms, &num);
    if (err != CL_SUCCESS)
    {
        printf("Error: Failed to get platform ID!
");
        return EXIT_FAILURE;
    }
    prop[1] = (cl_context_properties) platforms[0];
    mContext = clCreateContextFromType(prop, CL_DEVICE_TYPE_DEFAULT, NULL, NULL, &err);
    if (!mContext)
    {
        printf("Error: Failed to create a compute context!
");
        return EXIT_FAILURE;
    }
    clGetContextInfo(mContext, CL_CONTEXT_DEVICES, 0, NULL, &cb);
    devices = (cl_device_id *) malloc(cb);
    clGetContextInfo(mContext, CL_CONTEXT_DEVICES, cb, devices, 0);
    device_id = devices[0];
    clGetDeviceInfo(device_id, CL_DEVICE_NAME, 0, NULL, &cb);
    devname = (char *) malloc(cb);
    clGetDeviceInfo(device_id, CL_DEVICE_NAME, cb, devname, 0);
    printf("[Device Name: %s]
", devname);
    
    char *devvendor; devvendor = (char *) malloc(cb);
    clGetDeviceInfo(device_id, CL_DEVICE_VENDOR, cb, devvendor, 0);
    printf("[Device VENDOR: %s]
", devvendor);
    
    char *devVERSION; devVERSION = (char *) malloc(cb);
    clGetDeviceInfo(device_id, CL_DEVICE_VERSION, cb, devVERSION, 0);
    printf("[Device VERSION: %s]
", devVERSION);
    
    char *driVERSION; driVERSION = (char *) malloc(cb);
    clGetDeviceInfo(device_id, CL_DRIVER_VERSION, cb, driVERSION, 0);
    printf("[Driver VERSION: %s]
", driVERSION);

I have the following log:
[Device Name: ARM CPU Compute Device]
[Device VENDOR: Apple]
[Device VERSION: OpenCL 1.1 ]
[Driver VERSION: 1.1]

My *.cl file:


__kernel void sine_wave(__global float4* pos, unsigned int width, unsigned int height, float time)
{
    unsigned int x = get_global_id(0);
    unsigned int y = get_global_id(1);

    // calculate uv coordinates
    float u = x / (float) width;
    float v = y / (float) height;
    u = u*2.0f - 1.0f;
    v = v*2.0f - 1.0f;

    // calculate simple sine wave pattern
    float freq = 4.0f;
    float w = sin(u*freq + time) * cos(v*freq + time) * 0.5f;

    // write output vertex
    pos[y*width+x] = (float4)(u, w, v, 1.0f);
}


size_t program_length;
    char *programSource = oclLoadProgSource("AnimatedTexture.cl", "", &program_length);
    
    // create the program
    cpProgram = clCreateProgramWithSource(*mCLRoot->getContext(), 1, (const char**) &programSource, &program_length, &error);
    
    cl_device_id *devices = mCLRoot->devices;
    // build the program
    //error = clBuildProgram(cpProgram, 0, NULL, "-cl-fast-relaxed-math", NULL, NULL);
    error = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);
    
    if (error != CL_SUCCESS) {
        
        // Shows the log
        char* build_log;
        size_t log_size;
        // First call to know the proper size
        clGetProgramBuildInfo(cpProgram, devices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
        build_log = new char[log_size+1];
        // Second call to get the log
        clGetProgramBuildInfo(cpProgram, devices[0], CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
        build_log[log_size] = '\0';
        std::cout << build_log << std::endl;
        delete[] build_log;
    }

I have got error 11 and my log is empty. Please, help. Thanks.