15

I have a MacBook Pro 13' with an integrated Intel HD 3000 and a i7 core.
I have to use Parallel Programming.

My teaching advisors couldn't tell me if it would work with my MacBook.

Is there a test I could run on my Laptop for testing? + I found this, but there is only a Linux and Windows SDK ... maybe the Linux version works also for Mac.

What should I do?

Cœur
  • 37,241
  • 25
  • 195
  • 267
fragant1996
  • 361
  • 1
  • 2
  • 9

3 Answers3

41

vocaro's answer is absolutely correct; you can always use the CPU compute device on Snow Leopard and Lion, even if your particular graphics chip doesn't support OpenCL.

The following program will show you the OpenCL-capable devices on a given Macintosh:

// clang -framework OpenCL dumpcl.c -o dumpcl && ./dumpcl

#include <stdio.h>
#include <stdlib.h>
#include <OpenCL/opencl.h>

int main(int argc, char* const argv[]) {
    cl_uint num_devices, i;
    clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);

    cl_device_id* devices = calloc(sizeof(cl_device_id), num_devices);
    clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);

    char buf[128];
    for (i = 0; i < num_devices; i++) {
        clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 128, buf, NULL);
        fprintf(stdout, "Device %s supports ", buf);

        clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, 128, buf, NULL);
        fprintf(stdout, "%s\n", buf);
    }

    free(devices);
}

On my Macbook, this gives:

Device Intel(R) Core(TM) i7-2635QM CPU @ 2.00GHz supports OpenCL 1.1 
Device ATI Radeon HD 6490M supports OpenCL 1.1 

You can ask for other device information using this program as a starting point. The Khronos API reference for clGetDeviceInfo should be useful.

James
  • 2,373
  • 18
  • 16
  • Did this break with OSX 10.9? When i run this i get: dumpcl.c:1:10: fatal error: 'stdio.h' file not found – deweydb Oct 23 '13 at 08:25
  • Nevermind, it seems that xcode developer tools go away after upgrading, you can trigger a re-install by running: xcode-select --install – deweydb Oct 23 '13 at 08:56
  • @user1876508 On Linux you have to replace `` with `` and replace `-framework OpenCL` with `-lOpenCL`. And of course, you have to install both the libraries and the ICD. – o11c Nov 08 '16 at 03:54
3

You can use the built-in OpenCL platform that Apple ships with OS X Snow Leopard and Lion. Follow this guide:

http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/

Note that it will not work on the Intel HD 3000 GPU, only the CPU.

vocaro
  • 2,779
  • 2
  • 23
  • 16
  • I love how Apple created OpenCL, made it a open standard then basically let their support for it dwindle. The latest OpenCL they support overall is 1.2 which is as of today (2017) over circa 3 years old. :( – Entalpi Apr 01 '17 at 10:52
0

I´ve tested OpenCL on macbook air 2011, which has a Core i5-2467M. And i can tell you that OpenCL implementation made by apple, DOES not work properly on CPU, just on GPU. The big problem is when you set a workgroup size greater than 1.