Results 1 to 5 of 5

Thread: Offline Kernel Compiling in Ubuntu?

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1

    Offline Kernel Compiling in Ubuntu?

    Hi,

    I am quite a noob to OpenCL, and am trying to grasp some ideas of it with guide book examples.
    And I am currently using Ubuntu 12.04 with Intel / NVIDIA C2075,
    of which both OpenCL SDKs are installed.

    I know that there are two ways of compiling kernels (on/offline)
    But I couldn't figure out how I can compile my kernel and get binary file before compiling the whole thing.

    The book says there's a software named [Intel OpenCL offline Compiler] but what about Ubuntu??

    My kernel code is very simple :

    Code :
    __kernel void vecAdd(__global float * a)
    {
    	int gid = get_global_id(0);
     
    	a[gid] += a[gid];
     
    }

    Writing
    Code :
    gcc -I/usr/local/cuda-5.0/include -o kernel.clbin kernel.cl -lOpenCL
    didn't work that much. I got
    Code :
    /usr/bin/ld:kernel.cl: file format not recognized; treating as linker script
    /usr/bin/ld:kernel.cl:1: syntax error
    collect2: ld returned 1 exit status



    I appreciate your reply!

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    168

    Re: Offline Kernel Compiling in Ubuntu?

    The typical technique is to compile your program from source using clBuildProgram, then use clGetProgramInfo with the CL_PROGRAM_BINARY_SIZES and then CL_PROGRAM_BINARIES to fetch the binaries, and save them to disk. In future runs, use clCreateProgramWithBinary with the binary file.

    Note: This will only work if the driver and GPU hasn't changed. You won't be able to ship this binary and have it run on any hardware. That capability is the promise of the SPIR feature announced with OpenCL 1.2 but not widely shipping yet.

  3. #3
    Senior Member
    Join Date
    Oct 2012
    Posts
    165

    Re: Offline Kernel Compiling in Ubuntu?

    You should have a look at clusterchimps.org

    they have written a framework that should suite you. But remember that you will not be able to deliver binaries to other pc's because the binaries are (mostly) fo your system only (depending on driver + hardware)

  4. #4

    Re: Offline Kernel Compiling in Ubuntu?

    Quote Originally Posted by clint3112
    But remember that you will not be able to deliver binaries to other pc's because the binaries are (mostly) fo your system only (depending on driver + hardware)
    Is there any envitonment that can read binaries on another PC?

  5. #5
    Senior Member
    Join Date
    Oct 2012
    Posts
    165

    Re: Offline Kernel Compiling in Ubuntu?

    sadly not really,

    the binaries are profided by the vendors. so its very hard to get them running on different platforms. Have a look at cuda cubin to see some of the problems.

    there has been some ideas in the .ir format of khronos. but i couldnt get that one running on nvidia or amd. even intel wouldnt accept it. And i dreated it with the intel offline compiler -.-

Similar Threads

  1. Compiling Kernel With Struct Pointer in Argument
    By ConstantinS in forum OpenCL
    Replies: 1
    Last Post: 03-29-2013, 02:58 PM
  2. OpenCL slow compiling of multiple kernel code
    By chammakchallo in forum OpenCL
    Replies: 3
    Last Post: 02-13-2012, 08:45 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
  •