Results 1 to 8 of 8

Thread: how do I invoke the OpenCL compiler

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    how do I invoke the OpenCL compiler

    rather simple question:

    In Linux/Ubuntu 10.04 LTS,
    Having installed NVIDIA's CUDA sdk, (CUDA is *operational*)
    Having installed the necessary libs so that the OpenCL examples are building ok using make,
    how do I invoke the OpenCL compiler on a specific source file?

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: how do I invoke the OpenCL compiler

    Quote Originally Posted by stenlee
    rather simple question:

    In Linux/Ubuntu 10.04 LTS,
    Having installed NVIDIA's CUDA sdk, (CUDA is *operational*)
    Having installed the necessary libs so that the OpenCL examples are building ok using make,
    how do I invoke the OpenCL compiler on a specific source file?
    You call clBuildProgram within your source-code.

    Code cannot be compiled off-line, as you will never know what devices the code might run on.

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    Re: how do I invoke the OpenCL compiler

    Quote Originally Posted by notzed
    You call clBuildProgram within your source-code.

    Code cannot be compiled off-line, as you will never know what devices the code might run on.
    I did not make myself clear:
    How do I compile the host code (not the device code, which is dynamically compiled with clBuildProgram).
    Initially I thought the host code is compiled by gcc, but since OpenCL has some language constructs that are not part of the C language, ... it should be something else.

  4. #4
    Junior Member
    Join Date
    Jun 2012
    Posts
    3

    Re: how do I invoke the OpenCL compiler

    gcc works fine to compile the host code. As for the language constructs of OpenCL, that are not part of C, you just have to include the OpenCL library ("#include <CL/cl.h>").

    Check the demo programs in your Nvidia SDK, they probably also use gcc.

  5. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    Re: how do I invoke the OpenCL compiler

    Thanks,

    This one compiles:

    g++ -L/usr/local/cuda/lib64 -lOpenCL -I/usr/local/cuda/include -I/home/onto/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc -I/home/onto/NVIDIA_GPU_Computing_SDK/shared/inc oclVectorAdd.cpp

    but does not link, due to these:
    oclVectorAdd.cpp.text+0x33): undefined reference to `shrCheckCmdLineFlag'
    oclVectorAdd.cpp.text+0x51): undefined reference to `shrSetLogFileName'
    oclVectorAdd.cpp.text+0x70): undefined reference to `shrLog'
    oclVectorAdd.cpp.text+0x91): undefined reference to `shrRoundUp'
    oclVectorAdd.cpp.text+0xef): undefined reference to `shrLog'
    oclVectorAdd.cpp.text+0xfe): undefined reference to `shrLog'
    oclVectorAdd.cpp.text+0x17e): undefined reference to `shrFillArray'
    oclVectorAdd.cpp.text+0x195): undefined reference to `shrFillArray'
    oclVectorAdd.cpp.text+0x1be): undefined reference to `shrLog'

    Any idea which is the missing library ?

  6. #6
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: how do I invoke the OpenCL compiler

    Quote Originally Posted by stenlee
    Quote Originally Posted by notzed
    You call clBuildProgram within your source-code.

    Code cannot be compiled off-line, as you will never know what devices the code might run on.
    I did not make myself clear:
    How do I compile the host code (not the device code, which is dynamically compiled with clBuildProgram).
    Initially I thought the host code is compiled by gcc, but since OpenCL has some language constructs that are not part of the C language, ... it should be something else.
    Oh right, well that isn't the opencl compiler. It's just a C++ compiler.

    The C (acutally it seems you mean C++, which is a totally different language) code doesn't include any opencl-specific constructs, just library calls like any other code.

    You just run 'make' for the examples. Some of them them use more than one file or some library functions common within the examples and you can't compile the source files one by one without too much hassles.

  7. #7
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    Re: how do I invoke the OpenCL compiler

    There's a certain library that is missing:

    Code :
    shrutil_x86_64


    I've been able to short-circuit the problem, by adding
    ~/NVIDIA_GPU_Computing_SDK/shared/obj/x86_64/release/shrUtils.cpp.o
    to the linker command line, but obviously that is not the right way to go.

    I couldn't figure out where do I get this lib from?

  8. #8

    Re: how do I invoke the OpenCL compiler

    That's just stuff that nvidia puts in its SDK examples, for code that is shared by all of them (things like parsing the command line and selecting a gpu). It has nothing to do with OpenCL.

Similar Threads

  1. OpenCL Compiler
    By morteza271 in forum OpenCL
    Replies: 1
    Last Post: 09-16-2012, 06:49 AM
  2. OpenCL compiler
    By george_vv in forum OpenCL
    Replies: 0
    Last Post: 12-10-2009, 07:47 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
  •