Software and Hardware Circular Buffer Operations First presented in ENCM515 2005. There are 3 earlier lectures that are useful for midterm review. M. R.

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

CSCI 4717/5717 Computer Architecture
Intel Pentium 4 ENCM Jonathan Bienert Tyson Marchuk.
Anshul Kumar, CSE IITD CSL718 : VLIW - Software Driven ILP Hardware Support for Exposing ILP at Compile Time 3rd Apr, 2006.
Processor Architecture Needed to handle FFT algoarithm M. Smith.
Tuan Tran. What is CISC? CISC stands for Complex Instruction Set Computer. CISC are chips that are easy to program and which make efficient use of memory.
Chapter 8. Pipelining. Instruction Hazards Overview Whenever the stream of instructions supplied by the instruction fetch unit is interrupted, the pipeline.
Detailed look at the TigerSHARC pipeline Cycle counting for the IALU versionof the DC_Removal algorithm.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
What are the characteristics of DSP algorithms? M. Smith and S. Daeninck.
Daddy! -- Where do instructions come from? Program Sequencer controls program flow and provides the next instruction to be executed Straight line code,
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
TigerSHARC CLU Closer look at the XCORRS M. Smith, University of Calgary, Canada
ENCM 515 Review talk on 2001 Final A. Wong, Electrical and Computer Engineering, University of Calgary, Canada ucalgary.ca.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter.
Detailed look at the TigerSHARC pipeline Cycle counting for COMPUTE block versions of the DC_Removal algorithm.
Microprocessors Introduction to ia64 Architecture Jan 31st, 2002 General Principles.
RISC. Rational Behind RISC Few of the complex instructions were used –data movement – 45% –ALU ops – 25% –branching – 30% Cheaper memory VLSI technology.
TigerSHARC CLU Closer look at the XCORRS M. Smith, University of Calgary, Canada
11/11/05ELEC CISC (Complex Instruction Set Computer) Veeraraghavan Ramamurthy ELEC 6200 Computer Architecture and Design Fall 2005.
TigerSHARC processor General Overview. 6/28/2015 TigerSHARC processor, M. Smith, ECE, University of Calgary, Canada 2 Concepts tackled Introduction to.
Just enough information to program a Blackfin Familiarization assignment for the Analog Devices’ VisualDSP++ Integrated Development Environment.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Speeding it up Part 2: Pipeline problems & tricks dr.ir. A.C. Verschueren Eindhoven.
Real time DSP Professors: Eng. Julian Bruno Eng. Mariano Llamedo Soria.
Processor Architecture Needed to handle FFT algoarithm M. Smith.
Presented by: Sergio Ospina Qing Gao. Contents ♦ 12.1 Processor Organization ♦ 12.2 Register Organization ♦ 12.3 Instruction Cycle ♦ 12.4 Instruction.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 3 Understanding the memory pipeline issues.
DSP Processors We have seen that the Multiply and Accumulate (MAC) operation is very prevalent in DSP computation computation of energy MA filters AR filters.
Averaging Filter Comparing performance of C++ and ‘our’ ASM Example of program development on SHARC using C++ and assembly Planned for Tuesday 7 rd October.
Understanding the TigerSHARC ALU pipeline Determining the speed of one stage of IIR filter – Part 2 Understanding the pipeline.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
PART 6: (1/2) Enhancing CPU Performance CHAPTER 16: MICROPROGRAMMED CONTROL 1.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
RISC and CISC. What is CISC? CISC is an acronym for Complex Instruction Set Computer and are chips that are easy to program and which make efficient use.
MICROPROGRAMMED CONTROL
Systematic development of programs with parallel instructions SHARC ADSP21XXX processor M. Smith, Electrical and Computer Engineering, University of Calgary,
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
A first attempt at learning about optimizing the TigerSHARC code TigerSHARC assembly syntax.
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Generating a software loop with memory accesses TigerSHARC assembly syntax.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Software and Hardware Circular Buffer Operations
General Optimization Issues
TigerSHARC processor General Overview.
Generating “Rectify( )”
Overview of SHARC processor ADSP Program Flow and other stuff
Trying to avoid pipeline delays
Generating a software loop with memory accesses
Understanding the TigerSHARC ALU pipeline
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Understanding the TigerSHARC ALU pipeline
* 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items.
* M. R. Smith 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint.
Getting serious about “going fast” on the TigerSHARC
General Optimization Issues
Explaining issues with DCremoval( )
General Optimization Issues
Building a simple loop using Blackfin assembly code
Overview of SHARC processor ADSP-2106X Memory Operations
Understanding the TigerSHARC ALU pipeline
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
A first attempt at learning about optimizing the TigerSHARC code
Lecture 4: Instruction Set Design/Pipelining
Working with the Compute Block
A first attempt at learning about optimizing the TigerSHARC code
Presentation transcript:

Software and Hardware Circular Buffer Operations First presented in ENCM There are 3 earlier lectures that are useful for midterm review. M. R. Smith, ECE University of Calgary Canada

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 2 Tackled today Circular Buffer Issues  DCRemoval( )  FIR( ) Coding a software circular buffer in C++ and TigerSHARC assembly code Coding a hardware circular buffer Where to next?

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 3 DCRemoval( ) Not as complex as FIR, but many of the same requirements  Does an “implied” multiplication by a FIR coefficient of 1 and then does the sum. Easier to handle You use same ideas in optimizing FIR over Labs 2 and 3 Two issues – speed and accuracy. Develop suitable tests for CPP code and check that various assembly language versions satisfy the same tests Memory Intensive Addition intensive Loops for main code FIFO implemented as circular buffer “Memory Shuffle approach”

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 4 Set up time In principle 1 cycle / instruction instructions

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 5 First key element – Sum Loop -- Order (N) Second key element – Shift Loop – Order (log 2 N) 4 instructions N * 5 instructions * log 2 N No J parallel shifter Do it M68000 way

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 6 Third key element – FIFO circular buffer -- Order (N) * N 2

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 7 Next stage in improving code speed Software circular buffers Set up pointers to buffers Insert values into buffers SUM LOOP SHIFT LOOP Update outgoing parameters Update FIFO Function return N * 5 1 Was * log 2 N * N N Was N + 2 log 2 N N = 128 – instructions = delay cycles = 1730 cycles

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 8 DCRemoval( ) If there are N points in the circular buffer, then this approach of moving the data from memory to memory location requires  N Memory read / N Memory write (possible data bus conflicts)  2N memory address calculations FIFO implemented as circular buffer Uses memory shuffle approach from Lab. 1 NOTE: This approach can sometimes be the “fastest” (see later Labs.)

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 9 Alternative approach Move pointers rather than memory values In principle – 1 memory read, 1 memory write, pointer addition, conditional equate

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 10 Note: Software circular buffer is NOT necessarily more efficient than data moves Watch out Circular buffers can be implemented with the newest element placed “last” in the FIFO buffer, or with newest element placed “first” in the FIFO buffer SHARC (2002, 2003, 2004) – used “first approach” TigerSHARC – used “first approach” and failed max. optimization

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 11 Note: Software circular buffer is NOT necessarily more efficient than data moves Now spending more time on moving / checking the software circular buffer pointers than moving the data? SLOWER FASTER

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 12 On TigerSHARC Since we can have multiply instructions on one line, then “perhaps” if we can avoid pipeline delays then software circular buffer is faster than memory moves Pipeline delay XR4 = R4 + R5;; XR4 = R4 + R6;; Second instruction needs result of first No Pipeline delay XR4 = R4 + R5;; XR3 = R4 + R6;; Second instruction DOES NOT need result of first

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 13 Generate the tests for the software circular buffer routine

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 14 New static pointers needed in Software circular buffer code

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 15 New sets of register defines Now using many of TigerSHARC registers

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 16 Code for storing new value into FIFO requires knowledge of “next-empty” location First you must get the address of where the static variable – saved_next_pointer Second you must access that address to get the actual pointer Third you must use the pointer value Will be problem in labs and exams with static variables stored in memory

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 17 Adjustment of software circular buffer pointer must be done carefully Get and update pointer Check the pointer Save corrected pointer

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 18 Next stage in improving code speed Software circular buffers Set up pointers to buffers Insert values into buffers SUM LOOP SHIFT LOOP Update outgoing parameters Update FIFO Function return 2 8 Was N * 5 1 Was * log 2 N 6 14 Was * N N Was N N = 128 – instructions = 677 cycles delay cycles = 1011 cycles Was delay cycles = 1730 cycles

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 19 Next step – Hardware circular buffer Do exactly the same pointer calculations as with software circular buffers, but now the calculations are done behind the scenes – high speed – using specialized pointer features Only available with J0, J1, J2 and J3 registers (On older ADSP – all pointer registers) Jx -- The pointer register JBx – The BASE register – set to start of the FIFO array JLx – The length register – set to length of the FIFO array VERY BIG WARNING? – Reset to zero. On older ADSP it was very important that the length register be reset to zero, otherwise all the other functions using this register would suddenly start using circular buffer by mistake.  Still advisable – but need special syntax for causing circular buffer operations to occur

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 20 Setting up the circular buffer functions Remember all the tests to start with

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 21 Store values into hardware FIFO CB instruction ONLY works on POST-MODIFY operations CB [J1 += J2] not CB [J1 + J2]

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 22 Now perform Math operation using circular buffer operation MUST NOT DO XR2 = CB [J0 + i_J8]; Save N cycles as no longer need to increment index

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 23 Update the static variables Further special CB instructions A few cycles saved here

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 24 Next stage in improving code speed Hardware circular buffers Set up pointers to buffers Insert values into buffers SUM LOOP SHIFT LOOP Update outgoing parameters Update FIFO Function return 2 8 Was N * 4 Was 4 + N * 5 1 Was * log 2 N 6 14 Was * N N Was N N = 128 – instructions = 549 cycles delay cycle = 879 cycles Delays are now >50% of useful time Was delay cycles = 1011 cycle

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 25 Tackle the summation part of FIR Exercise in using CB (Lab 2)

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 26 Place assembly code here

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 27 The code is too slow because we are not taking advantage of the available resources Bring in up to 128 bits (4 instructions) per cycle Ability to bring in 4 32-bit values along J data bus (data1) and 4 along K bus (data2) Perform address calculations in J and K ALU – single cycle hardware circular buffers Perform math operations on both X and Y compute blocks Background DMA activity Off-load some of the processing to the second processor

6/2/2015 Software Circular Buffer Issues, M. Smith, ECE, University of Calgary, Canada 28 Tackled today Have moved the DCremoval( ) over to the X Compute block Circular Buffer Issues  DCRemoval( )  FIR( ) Coding a software circular buffer in C++ and TigerSHARC assembly code Coding a hardware circular buffer Where to next?