PDA

View Full Version : Offline Kernel Compiling in Ubuntu?



hyunn0204
01-04-2013, 01:01 AM
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 :


__kernel void vecAdd(__global float * a)
{
int gid = get_global_id(0);

a[gid] += a[gid];

}

Writing
gcc -I/usr/local/cuda-5.0/include -o kernel.clbin kernel.cl -lOpenCL didn't work that much. I got
/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!

Dithermaster
01-05-2013, 05:28 PM
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.

clint3112
01-09-2013, 01:10 AM
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)

rob_newman
01-22-2013, 12:53 AM
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?

clint3112
01-22-2013, 04:54 AM
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 -.-