Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

macos - How can I test for OpenCL compatibility?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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
", 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...