Results 1 to 10 of 10

Thread: I can't get a basic opencl program to run

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    10

    I can't get a basic opencl program to run

    Hi,

    I'm super new to opencl and an early intermediate at C++.

    I'm trying to get just a simple opencl program to work so I can build from there.

    I installed XCode 4 and cmake to my Mac (Os X), but my opencl code is still getting errors when I try to build it.

    I tried the Hello World code from the book OpenCL Programming Guide By: Aaftab Munshi; Benedict R. Gaster; Timothy G. Mattson; James Fung; Dan Ginsburg

    I get errors on all the opencl program terms like:
    hello.cpp:16: error: ‘cl_context’ was not declared in this scope
    hello.cpp:17: error: ‘cl_command_queue’ was not declared in this scope
    hello.cpp:18: error: ‘cl_program’ was not declared in this scope
    hello.cpp:19: error: ‘cl_device_id’ was not declared in this scope

    Do I need to put an #include<opencl> or something like that?

    Anyone know what I may have missed?

    Can you give me a really simple code to start with?

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    17

    Re: I can't get a basic opencl program to run

    Hi biokhar,

    The basic includes for opencl are different for the mac versus the rest of the world. You will want to put something like the following at the beginning of your code:

    #ifdef MAC
    #include <OpenCL/cl.h>
    #else
    #include <CL/cl.h>
    #endif


    Thank will include the right files for the mac and if you take your code to a PC.

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    17

    Re: I can't get a basic opencl program to run

    Also The book you are using is very good(I use it all the time) but they only have sample code for four of the chapters. The other two opencl books have code from the very beginning which may be very helpful to you. It is not to say they are better all three of the books provide great information and I have all three open all the time. While I recommend buying all the books you can get the source for free from the authors websites at:

    OpenCL in Action: The author really good simple programs that should get you started asap
    Also he has his intro section available for free download which may help you get started. Also note he has code for the MAC, Linux and windows as separate downloads http://www.manning.com/scarpino2/

    OpenCL Programming Guide:A bit more reference but absolutely wonderful as well. The source code is in a google repository at: http://code.google.com/p/opencl-book-samples/
    Using the downloaded make file it should setup everything you need to get started including referencing OpenCL.

    Again I want to stress that all three books are great and I use them all but I think the never book, OpenCL in Action takes a softer approach to OpenCL. The book you are looking at is great for getting up and running quickly and the case studies are really great but if you are having trouble another references is great. For now look at the source code and decide for yourself.

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    10

    Re: I can't get a basic opencl program to run

    Thanks for the help.

    I added the Mac specific stuff and a file named Opencl.h, then built it again and it said

    error: Cl/cl.h: No such file or directory
    error: 'cl_context' was not declared in this context and other opencl specific errors

    so I removed

    #else
    #include <CL/cl.h>

    and still got

    error: 'cl_context' was not declared in this context and other opencl specific errors

    Any suggestions?

  5. #5
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: I can't get a basic opencl program to run

    biokhar, it is generally recommended to be proficient in C before attempting to use OpenCL.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  6. #6

    Re: I can't get a basic opencl program to run

    I can only add here that I also program OpenCL on Apple (MacBook Pro / nVidia and Mac Pro / AMD), and I don't think I've ever had to #include anything at all . . . I look now in my project, and I see that i do have OpenCL.framework under the "Frameworks->Linked Frameworks" tab. That's all. I don't know if this observation can help, but if it does, then cool!

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    29

    Re: I can't get a basic opencl program to run

    On Mac the include directive should be:
    #include <OpenCL/opencl.h>

    This follows the general form Framework/framework.h.

    To link the executable, the OpenCL.framework must be added to the target in an xcodeproject (or otherwise added to the linker command line).

    Note that the filesystem might be case sensitive.

  8. #8
    Junior Member
    Join Date
    Dec 2011
    Posts
    4

    Re: I can't get a basic opencl program to run

    OpenCL in Action: The author really good simple programs that should get you started asap
    Hello, i've installed OpenCL SDK 1.5 and AMD APP SDK under Windows7 and
    try to compile VC2010 projects from the book samples, on my VC2010 Express Edition.
    I didn't tuch to the project properties and linkage seems ok
    But after compilling troubles come from access violation :

    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
    'Ch1_matvec.exe': Loaded 'C:\Program Files (x86)\Intel\OpenCL SDK\1.1\bin\x86\clang_compiler.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Program Files (x86)\Intel\OpenCL SDK\1.1\bin\x86\task_executor.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Program Files (x86)\Intel\OpenCL SDK\1.1\bin\x86\tbb.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\dbghelp.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Program Files (x86)\Intel\OpenCL SDK\1.1\bin\x86\tbbmalloc.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Program Files (x86)\Intel\OpenCL SDK\1.1\bin\x86\cpu_device.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\amdocl.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\aticaldd.dll', Cannot find or open the PDB file
    'Ch1_matvec.exe': Loaded 'C:\Windows\SysWOW64\atigktxx.dll', Cannot find or open the PDB file
    First-chance exception at 0x685d13be in Ch1_matvec.exe: 0xC0000005: Access violation reading location 0xcccccccc.
    Unhandled exception at 0x685d13be in Ch1_matvec.exe: 0xC0000005: Access violation reading location 0xcccccccc.


    The missing the PDB file isn't a problem but for the access violation i don't know what to do or to search

    Could u help please ?

  9. #9
    Junior Member
    Join Date
    Dec 2011
    Posts
    4

    Re: I can't get a basic opencl program to run

    Ok, forget my request for another forum rather...

  10. #10
    Member
    Join Date
    Mar 2010
    Location
    Raleigh, NC
    Posts
    55

    Re: I can't get a basic opencl program to run

    I've had some strange issues with the AMD APP SDK on my Windows 7 64-bit machine. OpenCL would throw an unhandled exception when it was installed. There were a few DLLs that I had to rename (cant remember them right now) that didn't get cleaned up from pre-2.5 version AMD APP SDK.

Similar Threads

  1. I can't seem to get your program to run in Chrome.
    By Agamemnon in forum User Hardware, Software Help
    Replies: 1
    Last Post: 01-19-2012, 12:22 PM
  2. How can i run this OPENGL ES program
    By sohrab in forum OpenGL ES general technical discussions
    Replies: 5
    Last Post: 05-22-2004, 10:26 PM

Posting Permissions

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