Results 1 to 4 of 4

Thread: Getting Started with OpenCL

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    5

    Getting Started with OpenCL

    Hi,

    I'm just starting to explore OpenCL. I've found this tutorial - http://www.codeproject.com/KB/GPU-Pr...oToOpenCL.aspx - and I'm having some troubles.

    Here is my code from just the start of the tutorial:
    Code :
    #include <utility>
    #define __NO_STD_VECTOR // Use cl::vector instead of STL version
    #include <CL/cl.h>
     
    #include <cstdio>
    #include <cstdlib>
    #include <fstream>
    #include <iostream>
    #include <string>
    #include <iterator>
     
    int main(void) {
        cl_int err;
        cl::vector< cl::Platform > platformList;
        cl::Platform::get(&platformList);
     
        return 0;
    }

    I had to change CL/cl.hpp (in the tutorial) to CL/cl.h (in my code) because I only have cl.h on my machine. When I try to compile this code, I get:

    Code :
    In function 'int main()':
    error: 'cl' has not been declared
    error: 'cl' has not been declared
    error: 'platformList' was not declared in this scope
    error: 'cl' has not been declared
    warning: unused variable 'err'
    ||=== Build finished: 4 errors, 1 warnings ===|

    I have added the OpenCL include path, library path and OpenCL library to my build settings.

    I have been able to successfully compile and run the vector addition application found here: http://www.thebigblob.com/getting-st...gpu-computing/. It appears that the code between the two applications are of different styles:

    Code :
    // From tutorial
    cl::Platform::get(&platformList);

    Code :
    // From vector addition application
    cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);

    Are there two different versions of OpenCL? Any help on why I can't compile the tutorial code would be greatly appreciated! Also, any other good resources or tutorials for starters would be appreciated as well!

  2. #2

    Re: Getting Started with OpenCL

    One tutorial is using the C-language and the other is using the C++ language.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    5

    Re: Getting Started with OpenCL

    So it turns out I was missing the C++ bindings. I downloaded it here: http://www.khronos.org/registry/cl/api/1.1/cl.hpp and placed it in the include directory, then changed my code back to CL/cl.hpp.

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    5

    Re: Getting Started with OpenCL

    Quote Originally Posted by bwatt
    One tutorial is using the C-language and the other is using the C++ language.
    Awesome, thanks for the reply!

Similar Threads

  1. Getting started
    By Alvaro in forum OpenCL
    Replies: 2
    Last Post: 02-27-2011, 01:39 AM
  2. getting started
    By Deep in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 04-09-2009, 10:20 AM
  3. Can somebody help me get started!
    By newtoopengl in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 02-24-2006, 06:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •