Analog Devices, Inc. · NASDAQ:ADI
Analog Devices — Technical Presentation (December 2008)
85 slides from Analog Devices's technical presentation, December 2008

Slide 1: About this Module
About this Module This module introduces concepts, tools and approaches to optimising Blackfin C applications. It highlights the problems and opportunities that can lead to potentially significant performance improvements. The course will look at the available tools, such as the Statistical profiler

Slide 2: Module Outline
Module Outline Concepts and Tools z Concerns of C : Advantages & problems z Useful tools z Pipelines and stalls Tuning DSP Kernels z Tuning techniques z Advanced loop optimisation Tuning Control code z Introduction to optimising control code z Advanced control code optimisation Blackfin Memo

Slide 3: Concepts and Tools
Concepts and Tools ANALOG DEVICES

Slide 4: Why use C?
Why use C? Advantages: C is much cheaper to develop. ( encourages experimentation ) C is much cheaper to maintain. C is comparatively portable. Disadvantages: ANSI C is not designed for DSP. DSP processor designs usually expect assembly in key areas. DSP applications continue to evolve. ( faster

Slide 5: How to go about increasing C performance
How to go about increasing C performance (1) Work at high level first most effective -- maintains portability z improve algorithm z make sure it’s suited to hardware architecture z check on generality and aliasing problems (2) Look at machine capabilities z may have specialised instructions (library

Slide 6: Uniform C computational model, BUT....
Uniform C computational model, BUT…. Missing operations provided by software emulation (floating point!) Assumes Large flat memory model C is more machine-dependent than you might think z for example: is a “short” 16 or 32 bits? Can be a poor match for DSP – accumulators? SIMD? Fractions?

Slide 7: Two kinds of Optimisation
Two kinds of “Optimisation”. Use the Optimiser and Optimise the C! (1) Automatic compiler optimisation. z Up to 20 times faster that non-optimised code in DSP kernels z Sliding scale from control code to DSP inner loop z Non-optimized code is only for debugging the algorithm But Note: Optimising Com

Slide 8: Un-Optimized Code for Blackfin
Un-Optimized Code for Blackfin Unoptimised assembly: [FP+ -8] = R7; ._P1L1: [FP+ -8] R3=[FP+ = R7; ._P1L1: -8]; R3=[FP+ -8]; R2 = 150 (X); R2 = 150 (X); Loop control The source code: CC = R3 < R2; CC = R3 < R2; IF !CC JUMP ._P1L3 ; increment, test & exit for (i = 0; i < 150; i++) { IF !CC JUMP ._P1L

Slide 9: Direct your effort: Use the Statistical Profiler
Direct your effort: Use the Statistical Profiler. Statistical profiling samples the program counter of the running application and builds up a picture of where it spends its time Completely non-intrusive – no tracing code is added Completely accurate – shows all effects, including stalls, from

Slide 10: VDSP++ Statistical Profiler
VDSP++ Statistical Profiler Benchmark by function, then drill down Left pane shows line by line activity Linear Profiler is also available in the simulator 10

Slide 11: A tip: Use Mixed Mode
A tip: Use Mixed Mode. Statistical results at the instruction level. Costly instructions are easy to spot. <- Pipeline stalls <- Transfer of control Could mean pipeline or multi-cycle instruction or memory cost. Due to pipeline, costs may be offset from adjacent instruction. 11

Slide 12: Bear in mind the Length of the Pipeline
Bear in mind the Length of the Pipeline. Take care on conditionally branching code. ( 0, 4 or 8 stall cycles ) sometimes branches can be avoided by using other techniques Take care with Table lookup and structure depth. p->q->z is inefficient to access. ( 3 stalls per indirection ) ( And a

Slide 13: VDSP++ Pipeline Viewer (Simulation Only)
VDSP++ Pipeline Viewer (SIMULATION ONLY) Accessed through View->Debug Windows->Pipeline Viewer. Press <Ctrl> and hover over stall. Step through interesting code sequences and look out for the slash of yellow that means stalls. 13

Slide 14: Tuning Digital Signal Processing Kernels
Tuning Digital Signal Processing Kernels 14

Slide 15: An efficient floating Point Emulation
An efficient floating Point Emulation Measurement in cycles VDSP++ 4.0 BF533 BF533 ratio fast-fp ieee-fp Multiply 93 241 0.4 Add 127 264 0.5 Subtract 161 329 0.5 Divide 256 945 0.3 Sine 2271 4665 0.5 Cos 2170 4419 0.5 Square Root 318 322 1.0 atan 1895 5712 0.3 atan2 2666 8058 0.3 pow 8158 17037 0.5

Slide 16: Wide support for Fractional processing
Wide support for Fractional processing The Blackfin instruction set includes a number of operations which support fractional (or fract) data. The instructions include: z saturating MAC/ALU/SHIFT instructions z MAC shift correction for fractional inputs The compiler and libraries provide support

Slide 17: Portable C expressing fractions
Portable C expressing fractions void vec_mpy1(short y[], const short x[], short scaler) { int i; for (i = 0; i < 150; i++) y[i] += ((scaler * x[i]) >> 15); } It is portable and the compiler is going to understand this, and generate optimal code for 16 bit fractions. ( it will assume saturation ) But

Slide 18: Explicit fixed point programming
Explicit fixed point programming There is a comprehensive array of 16 bit intrinsic functions. ( detailed in Visual DSP 4.0\Blackfin\include\ ) You must program using these explicitly. Intrinsics are 'inlined' and are not function calls Optimiser fully understands built-ins and their effects

Slide 19: ETSI Builtins
ETSI Builtins – fully optimised Fractional arithmetic to a standard specification European Telecommunications Standards Institute's fract functions carefully mapped onto the compiler built-ins. add() sub() abs_s() shl() shr() mult() mult_r() negate() round() L_add() L_sub() L_abs() L_negat

Slide 20: Pointers or Arrays?
Pointers or Arrays? Arrays are easier to analyse. void va_ind(int a[], int b[], int out[], int n) { int i; for (i = 0; i < n; ++i) out[i] = a[i] + b[i]; } Pointers are closer to the hardware. void va_ptr(int a[], int b[], int out[], int n) { int i, for (i = 0; i < n; ++i) *out++ = *a++ + *b++ }

Slide 21: Loops
Loops It is considered a good trade off to slow down loop prologue and epilogue to speed up loop. Make sure your program spends most of its time in the inner loop. The optimizer basically “works by unrolling loops”. z Vectorisation z Software pipelining What is software pipelining? z Reorgan

Slide 22: Effects of Vectorisation and Software Pipelining on Blackfin
Effects of Vectorisation and Software Pipelining on Blackfin Simple code generation: 1 iteration in 3 instructions R0.L = W[I1++] R1.L = W[I0++]; A1+= R0.L*R1.L; Vectorised and unrolled once: 2 iterations in 3 instructions R0 = [I1++] R1 = [I0++] A1+= R0.H*R1.H, A0+= R0.L*R1.L (IS) Software pi

Slide 23: Do not unroll inner loops yourself
Do not unroll inner loops yourself Good - compiler unrolls to use both compute blocks. for (i = 0; i < n; ++i) c[i] = b[i] + a[i]; Bad - compiler less likely to optimise. for (i = 0; i < n; i+=2) { xb = b[i]; yb = b[i+1]; xa = a[i]; ya = a[i+1]; xc = xa + xb; yc = ya + yb; c[i] = xc; c[i+1] = yc

Slide 24: Do not software pipeline loops yourself
Do not software pipeline loops yourself. The original loop (good) A pipelined loop (bad) float ss(float *a, float *b, int n){ float ss(float *a, float *b, int n ) { float sum = 0.0f; int i; float ta, tb , sum = 0.0f; for (i = 0; i < n; i++) int i = 0; ta = a[i]; tb = b[i]; { for (i = 1; i < n; i++)

Slide 25: Avoid loop carried dependencies
Avoid loop carried dependencies Bad: Scalar dependency. for (i = 0; i < n; ++i) x = a[i] - x; Value used from previous iteration. So iterations cannot be overlapped. Bad: Array dependency. for (i = 0; i < n; ++i) a[i] = b[i] * a[c[i]]; Value may be from previous iteration. So iterations cannot b

Slide 26: You can experiment with Loop structure
You can experiment with Loop structure Unify inner and outer Loops. z May make loop too complex, but optimiser is better focused. Loop Inversion. - reverse nested loop order. Unify sequential loops z reduce memory accesses – can be crucial when dealing with external memory. − And remember you c

Slide 27: Failure to engage Hardware Loop
Failure to engage Hardware Loop. The LSETUP zero overhead hardware loop is very effective. And signals a well understood loop. Reasons for not getting the desired HW loop from the compiler include: (1) There are only two, so only the two deepest nested cycles. (2) Calls to complex or unknown f

Slide 28: Vectorisation
Vectorisation Simultaneous operations on a number of adjacent data elements. But, programs written in serial, one-at-a-time form z compiler finds opportunities for many-at-a-time Valuable on architectures with wide data paths or parallel operations These Factors Make Vectorisation Difficult No

Slide 29: Word align your data
Word align your data 32-bit loads help keep compute units busy. 32-bit references must be at 4 byte boundaries. Top-level arrays are allocated on 4 byte boundaries. Only pass the address of first element of arrays. Write loops that process input arrays an element at a time. Nested loops

Slide 30: Think about the data layout
Think about the data layout. Arrange for 32 bit loads Example: Complex Data. short Real_Part[ N ]; short Imaginary_Part [N ]; Wrong! Two loads required. short Complex [ N*2 ]; One 32 bit load sufficient to load both parts. Construct Arrays with high visibility. A common performance fla

Slide 31: Watch Memory Access Patterns
Watch Memory Access Patterns Facilitate 32 bit and sequential access. Need to be careful how program sweeps thru memory for for(i=0; (i=0;i<NC; i<NC;i++) i++){{ // //bad bad for (j=0; j<NC; j++) for (j=0; j<NC; j++) {{ int intsum sum==0.0; 0.0; for for (k=0; k<NUM_SAMPS;k++) (k=0; k<NUM_SAMPS; k++

Slide 32: Aliasing: A prime cause of poor performance
Aliasing: A prime cause of poor performance Watch Pointers which come from outside :- Arguments, globals. Watch Pointers which serve several purposes. ( alias analysis is “flow free” ) Watch Implicit pointers – Reference parameters – esp. arrays. Some of this is experience. Look at any pointer

Slide 33: Inter-procedural Analysis: -ipa
Inter-procedural Analysis : -ipa To produce the best possible code for a function the optimiser needs information about: z Data alignment z Possible argument interference z Number of iterations First compilation uncovers information. Compiler called again from link phase if procedures will benefit

Slide 34: #pragma no_alias #pragma vector_for
#pragma no_alias #pragma no_alias for (i=0; i < n; i++) out[i] = a[i] + b[i]; No load or store in any iteration of the loop has the same address as any other load or store in any other iteration of the loop. If this is untrue, the program will give incorrect answers. Or use Qualifier restrict.

Slide 35: Array alignment on Blackfin
Array alignment on Blackfin __builtin_aligned(pointer,4); // aligned on word(32-bit) boundary. Executable statement, not #pragma, so when used on parameter arrays, must come after declarations in receiving function. #pragma all_aligned On Blackfin this asserts that the pointers are word aligned.

Slide 36: #pragma loop_count
#pragma loop_count example minimum trip count – used int i; to decide to omit loop #pragma loop_count(24,48,8) guards for (i=0; i<n; i++) maximum trip count – used sum += a[i] * b[i]; to decide it it is worth slowing down prologue and epilogue for a faster loop? trip modulo – used during sof

Slide 37: Volatile is an important tool
Volatile is an important tool Volatile is essential for hardware or interrupt-related data Some variables may be accessed by agents not visible to compiler. z accessed by interrupt routines z set or read by hardware devices ‘volatile’ attribute forces all operations with that variable to be do

Slide 38: Circular addressing
Circular addressing A[i%n] The compiler now attempts to treat array references of the form array[i%n] as circular buffer operations. -force-circbuf can help the compiler to accept the safety of a circular buffer access. Explicit circular addressing of an array index: long circindex(long index, l

Slide 39: Know your vocabulary: count_ones intrinsic
Know your vocabulary. Example: The count_ones intrinsic Original Problem: U16 parityCheck(U32 dataWord[], const S32 nWords) { S32 i,j; U32 accParity=0; for(j=0; j < nWords; j++){ for (i=0; i < 32; i++){ if (((dataWord[j] >> i) & 0x0001) == 1) accParity++; }} return((accParity & 0x00000001) ? 1 : 0)

Slide 40: The inline asm()
The inline asm() ASMS() used to be a hard barrier to all Example of inline asm. optimisation. A widening multiply. ( fract 32*32 using 16 bit Now when the asm uses specific operations). registers or touches memory directly. It can tell the compiler what it “clobbers”. inline int32_t MULT32(int32

Slide 41: Tuning Control Code
41 Tuning Control Code ANALOG DEVICES

Slide 42: Optimise Conditionals with PGO
Optimise Conditionals with PGO “Profile Guided Optimisation” : -Pguide Simulation produces execution trace. Use the compiled simulator (hundreds of times faster) than conventional simulator. z Problem: If what matters to you is worst case, not majority case, then choose training data appropriately.

Slide 43: Or Manual guidance
Or Manual guidance You can guide the compiler manually with: expected_true() expected_false(). For instance, If ( expected_false( failure status ) ) { < Call error routine > } Will lift very seldom executed error handling code out of main code stream. Execution will drop through to next item a

Slide 44: Replace Conditionals with Min, Max, Abs
Replace Conditionals with Min,Max,Abs. Simple bounded Programming decrement “trick” kk = = k-1; k-1; ifif (k (k < < -1) -1) kk = = max max (k-1, (k-1, -1); -1); kk = = -1; -1; Avoid jump instruction R0 += -1; latencies and simplifying R1 = -1; control flow helps R0 = MAX (R1,R0); optimisation. The c

Slide 45: Removing conditionals 2
Removing conditionals 2 Duplicate small loops rather than have a conditional in a small loop. Example for { if { ….. } else {…..} } => if { for {…..} } else { for {…..} } 45

Slide 46: Removing Conditionals: Predicated Instruction Support
Removing Conditionals 3 Predicated Instruction Support The blackfin predicated instruction support takes the form of: IF (CC) reg = reg. Much faster than a conditional branch. ( 1 cycle ) but limited. Recode to show the compiler the opportunity. For instance – consider speculative execution.

Slide 47: Removing Conditionals 4
Removing Conditionals 4 Is approach suitable for a pipelined machine sum = 0; for (I=0; I<NN; I++) { if ( KeyArray[val1][10-k+I] == '1' ) sum = sum + buffer[I+10]*64; else sum = sum - buffer[I+10]*64; } Faster Solution removes conditional branch. Multiplication is fast: let KeyArray hold +64 or

Slide 48: Avoid Division
Avoid Division. There are no divide instructions – just supporting instructions. Floating or integer division is very costly Modulus( % ) also implies division. Get Division out of loops wherever possible. Classic trick: - power of 2 Î shift. Division by power of 2 rendered as right shift

Slide 49: There are two implementations of Division
There are two implementations of Division. On a Blackfin, the cost depends on the range of the inputs. (1) Can use Division primitives Cost ~ 40 cycles (Loosely speaking, the result and divisor fit in 16 bits. ) (2) Bitwise 32 bit division Cost ~ 400 cycles Consider numeric range when dividing. Di

Slide 50: Use the laws of Algebra
Use the laws of Algebra A customer benchmark compared ratios coded as: if ( X/Y > A/B ) Recode as: if ( X * B > A * Y ) Another way to lose divisions! Problem: possible overflow in fixed point. The compiler does not know anything about the real data precision. The programmer must decide. For i

Slide 51: Dreg or Preg?
Dreg or Preg? The Blackfin design saves time and power by associating registers with functional units. That splits the register set into Dregs and Pregs. But it costs three stalls to transfer from Dreg to Preg. So you want to avoid chopping back and forth. Avoid address arithmetic that is not su

Slide 52: Convergent: DSP and micro-controller - Integer size?
Convergent: DSP and micro-controller - Integer size? 16 bit for arrays of data in DSP style calculations. 32 bits for “control” variables in micro-controller code. The ISA is not symmetric for 8, 16 and 32 bits. z Example: Comparison can only be done in 32 bits. z So 8 bit or 16 bit conditions

Slide 53: Varying multiplication cost
Varying multiplication cost. 32 bit multiplication takes three cycles. z R0 *= R1; You can do two 16 bit multiplications in one cycle. z And you can load and store in the same cycle. z That’s up to six times the throughput. z Eg. A1+= R0.H*R0.H, A0+= R0.L*R0.H (IS) || R0.L = W[I1++] || R0.H= W[I

Slide 54: Function Inlining and the inline qualifier
Function Inlining ( -Oa ) and The “inline” qualifier Inlining functions ( inserting body code at point of call) : z Saves call instruction ( multi-cycle ) z Saves return ( multi-cycle ) z Saves construction of parameters and return values. z Gives the optimiser greater visibility. z Gives the opti

Slide 55: Zero trip loops
Zero trip loops C definition of a FOR loop is Zero or more iterations. Blackfin HW loop is defined as One or more iterations. Result is guard code before loops jumping around if zero trip. R7=[FP+ -8] || NOP; CC = R7 <= 0 IF CC JUMP ._P3L15 ; LSETUP and loop body. …. ._P3L15: This can be avo

Slide 56: Blackfin Memory Performance
Blackfin Memory Performance 56

Slide 57: Evaluation tip: Watch the Bus speed
Evaluation tip: Watch the Bus speed. Some good CPU/BUS speed settings for Blackfins 30 mhz clock 27 mhz clock DF=1 ( giving 15 mhz granularity ) DF=1 ( giving 13.5 mhz granularity ) CPU Speed Bus speed Bus speed Bus speed CPU Speed Bus speed Bus speed Multiple Div = 4 Div = 5 Div = 6 Multiple 13.5 D

Slide 58: Memory Hierarchy - Caching
Memory Hierarchy - Caching The cache occupies some of the L1 memory. (it’s optional) Recommend use caching from the start . Either use the Project Wizard or: (1) Use Linker option USE_CACHE (2) Insert in the C program: #pragma “retain_name” A static integer “cplb_ctrl = 15” (3) Write Back mode h

Slide 59: Spread across the SDRAM banks
Spread across the SDRAM banks. The ADSP-BF533 EBIU allows for 4 internal banks in an external SDRAM bank to be accessed simultaneously, reducing the stalls on access compared to keeping program and data in one bank. An SDRAM row change can take 20-50 cycles depending on the SDRAM type. Macro “PA

Slide 60: SDRAM access – significant costs
SDRAM access – significant costs. ( using Bf533 EZkit ) Average time over 10,000 16 bit transfers Sequential Alternate Rows Alt Rows/diff Banks L1 Read 1 1 1 L3 ( cached ) Read 7.7 9.4 7.7 L3 Read 40.4 141.5 L1 Write 1 1 1 L3 ( cached ) Write/WT 5.2 45.7 5.2 ( Times in cycles at 600 mhz core speed )

Slide 61: Code Speed versus Space
Code Speed versus Space Compile for minimum code size or for maximum speed? Many optimisations increase the code size. This is at it’s most extreme in DSP Kernels, where loop unrolling, vector prologs and epilogs increase space several times. But minimising space in DSP kernels would cost us

Slide 62: Which Options? (code density suite)
Which Options? ( code density suite ) Control code size has significant variability on a Blackfin. As much as a 50% variation in code size can be available. No mode change calling between speed and space optimised code. Space optimised code has no restrictions on functionality. Breakdown of si

Slide 63: Advanced Automatic speed/space blending
Advanced Automatic speed/space blending. -Ov ( 1 to 100 ) Based on Profile Guided Optimisation analysis. The compiler knows exactly how often each block of code is executed, which is a good guide to its importance. The compiler knows pretty well how size expansive each of its speed increasin

Slide 64: Trial results from -OvNum
Trial results from –OvNum (stepping “Num” from 0 to 100 by 10) Cjpeg Speed/Space tradeoff 38000 37500 37000 36500 Space 36000 35500 35000 34500 34000 30000000000 30500000000 31000000000 31500000000 32000000000 32500000000 Speed EEMBC Consumer. All five apps show these curves. Shows we have a lar

Slide 65: The Manual method of blending space and speed
The Manual method of blending space and speed. – Try file level granularity. Yellow files matter for speed. Blue files matter for space. 22 out of 28 files are almost irrelevant for speed tradeoffs and could be compiled for min space. It’s not always the same files that matter for speed and

Slide 66: Correlate speed and space, filter and order the file list
Correlate speed and space, filter and order the file list. ( These figures are percentages of the available variation in space and speed, not total application space and speed. ) filedata.c -O ( 25% faster for no space increase ) jccolor.c -O ( 9.7% faster for 1.1% space increase) jcdctmgr.c -

Slide 67: Examples
Examples Some real examples based on programs submitted by customers and using the principles outlined in this presentation. 67

Slide 68: A real case of complex data structure – Before
A real case of “complex” data structure – Before ….. for (INT16 j = 0; j < syncLength ; j ++) // THIS LOOP VITAL TO APP PERFORMANCE. { k = i + j; realSyncCorrelation += ((INT32)sample[k].iSample * syncCofs[j]) << 1 ; imagSyncCorrelation += ((INT32)sample[k].qSample * syncCofs[j]) << 1 ; } Produc

Slide 69: ... and After
… and After Copying data to a temp struct is cheap compared to gains. INT16 sample_iq[287*2]; // local copy of data - real and imaginary shorts consecutive. for (INT16 j = 0; j < syncLength ; j ++) { k = i + j; realSyncCorrelation += ((INT32)sample_iq[(k*2)] * syncCofs[j]) << 1 ; imagSyncCorrelati

Slide 70: Customer's Goal: get ported C to run as required
Customer’s Goal : get ported C to run as required This is abstracted from a real evaluation of the Blackfin. Strategy for application acceleration: (1) Insert timing points and checking code. ( 50 million cycles) (2) Optimisation on. ( 9.5 million cycles) (3) Cache on. ( 1.4 million cycles) (3)

Slide 71: Problem #1: Profile and Focus - ETSI
Problem #1 : Profile and Focus - ETSI Statistical Profiler reveals ETSI fractional arithmetic costly. Code inspection reveals implemented by function calls. Engage compiler builtins for ETSI. This only requires a pre- processor setting #define ETSI_SOURCE #include <libetsi.h> ETSI call mostl

Slide 72: Problem #2: Conditional jumps found in critical loop
Problem #2: Conditional jumps found in critical loop short corr_max(DATA *corr_up,DATA *corr_down,DATA *store,DATA gate_level, ushort nx) { int j; for (j=0;j<len;j++) { DATA maxval; // DATA is 16 bits. maxval = *corr_up++; if(*corr_down>maxval) maxval = *corr_down; corr_down++; if(maxval>gate_leve

Slide 73: Remove first Conditional jump!
Remove first Conditional jump! Transform: maxval = *corr_up++; if(*corr_down>maxval) maxval = *corr_down; corr_down++; to: maxval = max(*corr_down++,*corr_up++); Time cut from 67,000 to 40,000 cycles. Why did the compiler not perform this transformation? Wrong DATA type. Compiler does 32 bit

Slide 74: Remove second Conditional jump
Remove second Conditional jump Look at the innermost conditional if(maxval>*store) *store = maxval; Use MAX again and force condition to always execute. *store = max(*store,maxval); A compiler will not do this for you. We are forcing an extra write, which the compiler will reckon is outside of

Slide 75: Remove third and final Conditional jump
Remove third and final Conditional jump Facilitate a translation to “ IF CC Rx = Ry. A one cycle predicated instruction. Get rid of the jump, NOT the condition. for (j=0;j<len;j++) { unsigned int maxval; oldvalue = *store; maxval = max(*corr_down++,*corr_up++); maxstore = max(oldvalue,maxval); if(ma

Slide 76: Remove coercion
Remove coercion Sharp eyes will have noted that variable Maxval changed from a DATA ( 2 bytes ) to a 4 byte variable. This is to remove an unnecessary coercion. ( 16 -> 32 bits ) The problem is that the Blackfin control code style, including comparison operations is set up for 32 bits. Solut

Slide 77: Performance impact by removing All three CONDITIONAL LOOPS
Performance impact by removing All three CONDITIONAL LOOPS The final machine code looks like this: LSETUP (._P1L1 , ._P1L2-2) LC0=P5; ._P1L1: R0 = W[P0++] (X); R2 = W[P1++] (X); R0 = MAX (R0,R2) || R2=W[P2+ 0] (X) || NOP; //<<<<< IF (1) => MAX instr CC = R1 < R0 (IU); R0 = MAX (R0,R2); //<<<<<<<<<

Slide 78: Problem #3: Opportunities with Memcpy
Problem #3: Opportunities with Memcpy Statistical profile shows that we spend time in memcpy(). Experimentally engage Write Back mode in the cache. This means that data will not be copied back to external memory until the cache line is retired. Setup in cplbtab.h. #define CPLB_DWBCACHE CPL

Slide 79: Additional Information about Memcpy
Additional Information about Memcpy Memcpy() is written to reward 4 byte alignment of data. It checks word alignment and uses a word at a time loop if it can. Otherwise a byte by byte copy is performed. Because: A Blackfin can do a 4 byte load and a 4 byte store in a single cycle, but you can on

Slide 80: Problem #4: Loop Splitting?
Problem #4: Loop Splitting? for (k=0; k<numcols; k++) { kr1+=(LDATA)L_mult((fract16)*matdc_val_loc, (fract16)*f_coef1++); ki1+=(LDATA)L_mult((fract16)*matdc_val_loc, (fract16)*f_coef1++); kr2+=(LDATA)L_mult((fract16)*matdc_val_loc, (fract16)*f_coef2++); ki2+=(LDATA)L_mult((fract16)*matdc_val_loc,

Slide 81: Impact of Loop Splitting
Impact of Loop Splitting const int numcols=*matdc_numcols_loc++; for (k=0; k<numcols; k++) { kr1+=(LDATA)L_mult((fract16)*matdc_val_loc, (fract16)*f_coef1++); ki1+=(LDATA)L_mult((fract16)*matdc_val_loc, (fract16)*f_coef1++); matdc_val_loc++; } for (k=0; k<numcols; k++) { kr2+=(LDATA)L_mult((fract1

Slide 82: Next Step: Tune to final Platform
Next Step: Tune to final Platform The same techniques, applied in other areas reduced the time by another 40,000 cycles. We have come from 1.45 million to 0.73 million cycles in all. There remained lots of scope for #pragma no_alias but that required customer knowledge to do safely. The app

Slide 83: Consider Bus Speed: Set Sclk and Cclk
Consider Bus Speed : Set Sclk and Cclk The processor speed and bus speed of the Blackfin are variable. Experimentation reveals that: CCLK= 391.5MHz SCLK= 130.5MHz Are optimal. Explanation: The clock on the BF532 Ezkit is 27 mhz. This is multiplied by 29 and divided by 2 to give a mhz of 391.

Slide 84: Consider L1 SRAM allocation
Consider L1 SRAM allocation The default LDF file uses any free L1 memory and cascades the rest of the application to external memory. Study cache behaviour with Cache Viewer. A number of cache events are seen that represent collisions. Track these back to user data constructs. Hint: Noticed

Slide 85: Additional Information
Additional Information Reference material z EE197 Blackfin Multi-cycle instructions and latencies. z Blackfin Compiler manual, chapter 2: Achieving Optimal Performance from C/C++ Source Code. z ETSI – European Telecommunications Standards Institute. For Questions, click the “Ask A Question” butt
Source: Internet Archive copy of analog.com
More decks from Analog Devices, Inc.
Proxy Contest (February 2026)6 slides · Feb 9, 2026
Investor Presentation (September 2025)11 slides · Sep 19, 2025
Investor Presentation (September 2024)14 slides · Sep 27, 2024
Technical Presentation (May 2024)97 slides · May 30, 2024
Shareholder Meeting (February 2024)18 slides · Feb 29, 2024
Investor Presentation (October 2023)12 slides · October 2023