cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

hazeman
Adept II

Getting IL code from OpenCL

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 ).

 

 

 

 

 

 

0 Likes
8 Replies
genaganna
Journeyman III

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 ).

Hazeman,

               could you please post testcase which shows poor performance on 4XXX?

0 Likes

There has been a lot of talk about opencl performance in other thread ( with code samples and results ) - http://forums.amd.com/devforum/messageview.cfm?catid=390&threadid=120413&enterthread=y.

 

0 Likes

Hazeman,
What you are see being generated is unoptimized code only.
0 Likes

Correct me if I'm wrong. The libOpenCL is calling clc and llc to generate IL and then uses CAL backend to compile to ISA - and I assume that you are talking about CAL backend optimizations.

 

So if it's true I'm going to leave my conclusions without any change, as CAL optimizer has it's own problems ( and btw test results confirm it ). And CAL can't make some optimizations ( like using mads when llc generates mul_ieee ).

 

0 Likes

Hazemen,
The bitcode that you are passing into llc is not the same bitcode that the runtime passes to llc.
0 Likes

Originally posted by: MicahVillmow Hazemen, The bitcode that you are passing into llc is not the same bitcode that the runtime passes to llc.


When I have some spare time I'll verify this as intercepting llc call from libopencl isn't that hard ( and I'll try to update this "guide" ). But I can say that bit code generated by the clc didn't look bad ( clc generates also text version ). So for now i have reasonable doubts if changing clc step ( to match the one in libopencl ) will give better code.

Of course you could simply tell us what to do ( I assume some additional flags to clc ).

 

0 Likes

I have actually done exactly that a wrapper to ATI CAL..

It's working on Windows and Linux as a note I tested your kernel and as Micah said it's much better code than what you get with your implementation..

Also note that it has also device assembly code (so it gets info as would a SKA for OpenCL..)

One limitation of my approach vs. yours is that you can theoretically run that in Mac (using Wine) for getting AMD IL.. My implementation can't as ATI doesn't ship CAL libraries in MacOS an also the AMD support in MacOs seems to do not depend on CAL libraries (I can't search it)..

 

0 Likes

Sorry the link is http://oscarbg.blogspot.com/2009/10/cal-wrapper-for-getting-amd-il-from.html

Originally posted by: oscarbarenys1 I have actually done exactly that a wrapper to ATI CAL..

 

It's working on Windows and Linux as a note I tested your kernel and as Micah said it's much better code than what you get with your implementation..

 

Also note that it has also device assembly code (so it gets info as would a SKA for OpenCL..)

 

One limitation of my approach vs. yours is that you can theoretically run that in Mac (using Wine) for getting AMD IL.. My implementation can't as ATI doesn't ship CAL libraries in MacOS an also the AMD support in MacOs seems to do not depend on CAL libraries (I can't search it)..

 

 

 

0 Likes