Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Compiler: clpru 2.2.1: code timing, optimizer, __delay_cycles()

$
0
0

Tool/software: TI C/C++ Compiler

I have code like this:
[A] __R30 = ctrl ;
[B] myvar = (myexpr) ;  // 4 cycles
[C] __delay_cycles(4) ; // 4 cycles
[D] result = __R31 ; // 8 cycles delay

Point [D] must be 40ns = 8 cycles later then [A].
To not waste time, I moved some calculation to [B].
[B] is 4 cycles, so this worked until the optimizer "clpru -O3" moved [B] before [A].
Executing [B], [A], [C], [D] is only 4 cycles, so error.

Questions:
- what can I do to temporarily prohibit code reorder between [A] and [D] ?
- is guaranteed, that the optimizer always lets  __delay_cycles() stay in place between [A] and [D] ?

Maybe here's a potential target collision: the PRUs shall execute code in deterministic timing, but the optimizer may scramble everything.

Proposal: make a pair of two intriniscs __delay_start() and  __delay_end(), which tells the compiler between which points I need the delay:
Then the optimizer could arranged code accordingly.

__delay_start() ;
 __R30 = ctrl ;
 myvar = (myexpr) ; 
 __delay_end(8) ; // need 8 cycles from __delay_start() to here
result = __R31 ;


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>