cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Are there any real functions @ AMD IL?

AMD IL functions support

I'm trying to figure out how AMD IL works. I've code that looks like:

mov r<0-15>, params#1

call 1

mov r<0-15>, params#2

call 1

mov r<0-15>, params#3

call 1

... etc

func 1

// kinda lot of code here

...

ret

 

When i'm trying to compile it it stucks at calclCompile() phase. As I can understand the reason is that CAL trying to inline everything. The questions are: is this normal behaviour? Am I missed some <noinline> thing? Are there any real functions with <call/ret> accessible via AMD IL?

// And as a side note -- kinda strange that pdf documentation have "no clipboard copy allowed" attribute .

 

 

0 Likes
7 Replies
rick_weber
Adept II

In IL, you can make actual function calls (even recursive ones). The instruction for returning from a function is ret_dyn, not ret.

0 Likes

Originally posted by: rick.weber In IL, you can make actual function calls (even recursive ones). The instruction for returning from a function is ret_dyn, not ret.

In fact it was ret_dyn, I've just incorrectly called it "ret" (not so familiar with IL atm while having long x86 history). More correctly, my kernel looks like:

il_ps_2_0
dcl_input_position_interp(linear_noperspective) vWinCoord0.xy__
dcl_output_generic o0
...

; setting up params #1

call 1
; setting up params #2

call 1

; more and more similar code, 19x times

...

mov o0,r10
mov o1,r11
mov o2,r12
mov o3,r13
mov o4,r14
endmain

func 1
; (big) function body here

ret_dyn
endfunc

end

It still hangs on compiling phase. And I can't find something that looks like "call/ret" when disassembling the kernel (and when using lesser numbers of functions' calls to avoid compiler lock up).

 

0 Likes

Try putting a ret_dyn before endmain. If that doesn't work, then comment out blocks of lines until you can isolate the ones that are causing compilation to fail. It would be helpful if getting the error string told you what line was wrong, but when I tried it, it said "no error."

0 Likes

Tried ret_dyn before endmain -- nothing changed.

And in fact there no error strings at all -- it just hangs up while compiling. C++ wrapper looks like:

 printf("Compiling kernel...\n");
 if (calclCompile(&obj, lang, pDecompressed, info.target) != CAL_RESULT_OK) {
   fprintf(stdout, "Kernel compilation failed. Exiting.\n");
   return 1;
 }
 printf("Compiling done, linking...\n");
 if (calclLink(&image, &obj, 1) != CAL_RESULT_OK) {
   fprintf(stdout, "Kernel linking failed. Exiting.\n");
   return 1;
 }
// calclDisassembleImage(image, (CALLogFunction)__logger); return 0;
 
 printf("Linking done, preparing to run\n");

After outputting "Compiling kernel..." nothing happens, it just hangs up. I've waited for 10 mins just to be sure . Long kernels takes some time to compile (i've got 30 sec on some really big one) but 10+ mins can't be good anyway.

 

If I'm reducing number of functions calls at some point kernel became compilable but it takes time (several seconds), result disassembly really big (1M+) and there no CALL/RET keywords inside. That why I assume that calCL just inlining my function instead of calling it.

0 Likes

empty,

  Have you tried breaking your kernel down more, into several smaller kernels?

0 Likes

Originally posted by: ryta1203 empty,

  Have you tried breaking your kernel down more, into several smaller kernels?

No, not yet. Currently I'm trying to create some kernel that will have functions inside after disassembly -- no success at all, calCL just inlining everything :S. WTB some <noinline this please> keyword .

Btw,  nVidia's CUDA have in fact "noinline" keyword for functions. But it doesn't works anyway if we're passing params to function by pointers (no surprise it doesn't works).

0 Likes

Unless your kernel is obscenely massive, it's really strange that it never returns. I assume you've called cal_init(), though, I'm not sure that's relevant. Can you try something else with the cal runtime like allocating a vector on the GPU?

0 Likes