1 / 6

Pipeline Programming

Pipeline Programming. Programming Techniques & Datapath Requirements. Hazard Avoidance Example Sample code: for (int i = 0; i < 100; i++) { A[i] = B[i] + c; } Assume: A is in reg 1 B is in reg 2 c is in reg 3 Write the LC2K code to minimize stalls – assume:

hana
Télécharger la présentation

Pipeline Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pipeline Programming Programming Techniques& Datapath Requirements

  2. Hazard Avoidance Example • Sample code: for (int i = 0; i < 100; i++) { A[i] = B[i] + c;} • Assume: • A is in reg 1 • B is in reg 2 • c is in reg 3 • Write the LC2K code to minimize stalls – assume: • a single cycle delayed branch (branch delay slot of size 1) • any necessary/possible data forwarding

  3. Hazard Avoidance: Example • The unoptimized codebased on a simplehand-compile:

  4. Hazard Avoidance: Unoptimized Load stall!

  5. Hazard Avoidance: Optimized Branch delay slot Branch delay slot

  6. Performance Analysis • N iterations (N = 100 in the example) • Unoptimized: • Overhead: 2 cycles are required to get to the loop • Each iteration takes 15 – 3 + 1 = 13 cycles • 1 more cycle to finish last instruction in the pipeline • Total cycles for unoptimized version 2 + 13 * N + 1 = 1303 • Total instructions = 2 + 9 * N = 902 • CPI  1.445 • Optimized: • Each iteration takes 11 – 3 + 1 = 9 cycles • 4 more cycles to finish last instruction in the pipeline • Total cycles for optimized version 2 + 9 * N + 4 = 906 • CPI 1.004

More Related