xcode 无法在 Mac OSX 上设置 OpenCL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23072367/
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
Can't setup OpenCL on Mac OSX
提问by jprice
So i started OpenCL but can't get it to work on my Air'13 with Mavericks and C++ host. Heres the code.
所以我启动了 OpenCL,但无法让它在带有 Mavericks 和 C++ 主机的 Air'13 上运行。这是代码。
#include <iostream>
#include <vector>
#include "OpenCL/opencl.h"
int main()
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
cl_int cl::Platform::get(&platforms);
}
When I try to to access the cl::Platform
library , the compiler(Xcode) throws the error Use of undeclared Identifier
I have tried a couple of things, mainly changing the header file to cl.h
and a few others in the OpenCL framework.How can I get it to work, The apple website states that the Air supports OpenCL 1.2.
当我尝试访问cl::Platform
库时,编译器(Xcode)抛出错误Use of undeclared Identifier
我尝试了几件事情,主要是将头文件更改cl.h
为 OpenCL 框架中的其他一些文件。网站声明 Air 支持 OpenCL 1.2。
Addendum - whats a good book to start learning OpenCL?
附录 - 什么是开始学习 OpenCL 的好书?
回答by jprice
Your code snippet is making use of the OpenCL C++ bindings, which are defined in a different header file to the main OpenCL API (which is C). The header you need (cl.hpp
) isn't included on OS X systems by default, so you'll have to download it directly from the the Khronos OpenCL Registry(make sure you get the version listed under 1.2). You then just need to include this header from your code.
您的代码片段正在使用 OpenCL C++ 绑定,这些绑定在与主 OpenCL API(即 C)不同的头文件中定义。cl.hpp
默认情况下,OS X 系统中不包含您需要的标头 ( ),因此您必须直接从Khronos OpenCL 注册表下载它(确保您获得了 1.2 下列出的版本)。然后,您只需要在代码中包含此标头即可。
The typical books that get recommended for learning OpenCL are "OpenCL Programming Guide (Munshi, Gaster, Mattson, Fung, Ginsberg)" and "Heterogeneous Computing with OpenCL (Gaster, Howes, Kaeli)". There's also plenty of free tutorial material on the web, such as the Hands-on OpenCL tutorial on Github.
推荐学习 OpenCL 的典型书籍是“OpenCL Programming Guide (Munshi, Gaster, Mattson, Fung, Ginsberg)”和“Heterogeneous Computing with OpenCL (Gaster, Howes, Kaeli)”。网络上还有大量免费的教程材料,例如Github 上的Hands-on OpenCL 教程。