Question

So i started OpenCL but can't get it to work on my Air'13 with Mavericks and C++ host. Heres the code.

#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.

Addendum - whats a good book to start learning OpenCL?

Was it helpful?

Solution

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top