macos 如何测试 OpenCL 兼容性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7892955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I test for OpenCL compatibility?
提问by fragant1996
I have a MacBook Pro 13' with an integrated Intel HD 3000 and a i7 core.
I have to use Parallel Programming.
我有一台集成了 Intel HD 3000 和 i7 内核的 MacBook Pro 13'。
我必须使用并行编程。
My teaching advisors couldn't tell me if it would work with my MacBook.
我的教学顾问无法告诉我它是否适用于我的 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.
是否有我可以在笔记本电脑上运行的测试?+ 我找到了这个,但只有 Linux 和 Windows SDK ......也许 Linux 版本也适用于 Mac。
What should I do?
我该怎么办?
回答by James
vocaro's answer is absolutely correct; you can alwaysuse the CPU compute device on Snow Leopard and Lion, even if your particular graphics chip doesn't support OpenCL.
vocaro 的回答是绝对正确的;您始终可以在 Snow Leopard 和 Lion 上使用 CPU 计算设备,即使您的特定图形芯片不支持 OpenCL。
The following program will show you the OpenCL-capable devices on a given Macintosh:
以下程序将向您展示给定 Macintosh 上支持 OpenCL 的设备:
// 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:
在我的 Macbook 上,这给出了:
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 clGetDeviceInfoshould be useful.
您可以使用此程序作为起点来询问其他设备信息。clGetDeviceInfo的 Khronos API 参考应该很有用。
回答by vocaro
You can use the built-in OpenCL platform that Apple ships with OS X Snow Leopard and Lion. Follow this guide:
您可以使用 Apple 随 OS X Snow Leopard 和 Lion 提供的内置 OpenCL 平台。请遵循本指南:
http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/
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.
请注意,它不适用于 Intel HD 3000 GPU,仅适用于 CPU。
回答by Lucas Ribeiro
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.
我已经在配备 Core i5-2467M 的 macbook air 2011 上测试了 OpenCL。我可以告诉你,苹果公司的 OpenCL 实现在 CPU 上不能正常工作,只能在 GPU 上工作。最大的问题是当您将工作组大小设置为大于 1 时。