Getting IL code from OpenCL

Discussion created by hazeman on Oct 21, 2009
Latest reply on Oct 23, 2009 by oscarbarenys1

It's possible to generate IL code using OpenCL compiler from SDK. Here is how .

Go to SDK/bin directory and copy your opencl source file as source.cl. Then issue from command line the following instructions

./clc --emit=llvmbc source.cl -o kernel.bc

./llc -regalloc=amdil -filetype=asm -march=amdil kernel.bc -o kernel.il

( for windows users omit ./ )

Done . kernel.il is our result.

You can try to enable optimizations ( -O3 -enable-fp-mad -enable-unsafe-fp-math as options to the llc ) but it looks like the compiler doesn't use it.

On the pessimistc note, the quality of generated code doesn't look too good. I think that at the moment we have only rudimentary OpenCL compiler. Judging by the time it took ATI to get it done ( 5 months longer than others ) we can't expect good compiler any time soon.

PS. llc --versions gives Registered Targets: amdil  - ATI RADEON HD4XXX series graphics cards. And yet at the same time we get information that OpenCL compiler is created for 58xx ( this argument was given as justification to low opencl performance on 48xx ).