Docsity

Instruction Control Unit - Introduction to Low-Level Programming | CMSC 212, Exams of Computer Science

Toggle sidebar
bg1
1
1
1
CMSC 212 โ€“ F05 (lect 22)
Announcements
โ—Program #6
โ€“ is due dec 13
โ—Final Exam
โ€“Thursday, Dec 15
โ€“4:00-6:00 pm
โ€“ in H.J. Patterson 0226.
2
CMSC 212 โ€“ F05 (lect 22)
โ—Optimizations you should do regardless of
processor/compiler
โ€“ Code Motion (moving out of the loop)
โ€“ Reducing procedure calls
โ€“ Unneeded memory usage
โ€“ Share Common sub-expressions
โ—Machine-Dependent Optimization
โ€“ Pointer Code
โ€“ Unrolling
โ€“ Enabling instruction level parallelism
pf3
pf4
pf5

Partial preview of the text

Download Instruction Control Unit - Introduction to Low-Level Programming | CMSC 212 and more Exams Computer Science in PDF only on Docsity!

CMSC 212 โ€“ F05 (lect 22)^1

Announcements

l Program

  • is due dec 13

l Final Exam

  • Thursday, Dec 15
  • 4:00-6:00 pm
  • in H.J. Patterson 0226.

CMSC 212 โ€“ F05 (lect 22)^2

l Optimizations you should do regardless of

processor/compiler

  • Code Motion (moving out of the loop)
  • Reducing procedure calls
  • Unneeded memory usage
  • Share Common sub-expressions

l Machine-Dependent Optimization

  • Pointer Code
  • Unrolling
  • Enabling instruction level parallelism

CMSC 212 โ€“ F05 (lect 22)^3

Instruction Control Unit

Instruction

Cache

Address

Instruction

Fetch

Control

Instruction

Decode

Retirement

Unit

Register

File

Operations

Execution

Unit

Branching Results & Register Updates

CMSC 212 โ€“ F05 (lect 22)^4

Execution Unit

Instruction

Control Unit

Data Cache

Operations

Integer/ Branch

General Integer

FP

add

FP Load (^) Store mult/div

Operations Results

& Data Address

CMSC 212 โ€“ F05 (lect 22)^7

Enhancing Parallelism

l Dependences hurt pipeline performance

Time 1 2 3 4 5 6 7 add R2 R3 R2 IF ID X M WB add R2 R4 R2 IF stall stall stall ID X

int sum = 0, arr[], i;

for (i = 0; i < 100; i++) { sum += arr[i]; }

CMSC 212 โ€“ F05 (lect 22)^8

Enhancing Parallelism

l Dependences hurt pipeline performance,

  • so use iteration splitting or loop splitting

Time 1 2 3 4 5 6 7 add R2 R6 R2 IF ID X M WB add R3 R7 R3 IF ID X M WB add R4 R8 R4 IF ID X M WB bra IF ID X M add R2 R9 R2 IF ID X add R3 R10 R3 IF ID

int sum = 0, arr[], i;

for (i = 0; i < 100; i+=3) { suma += arr[i]; sumb += arr[i+1]; sumc += arr[i+2]; } sum = suma + sumb + sumc

no stall!

assume everything in registers

CMSC 212 โ€“ F05 (lect 22)^9

Register Spilling

l register spilling is when not enough registers

  • assume 2 general-purpose registers what happens with:

for (i = 0; i < โ€ฆ; i++) { arr[i] += a + b + c

l Some values are temporarily stored on the stack

  • Causes a significant performance drop

CMSC 212 โ€“ F05 (lect 22)^10

Cache considers two kinds of Locality

l Principle of Locality:

  • Programs tend to reuse data and instructions near those they have used recently, or that were recently referenced themselves.
  • Temporal locality: Recently referenced items are likely to be referenced in the near future.
  • Spatial locality: Items with nearby addresses tend to be referenced close together in time.

CMSC 212 โ€“ F05 (lect 22)^13

More Detailed Memory Hierarchy

Registers On-chip L cache (SRAM)

Main memory (DRAM)

Local secondary storage (local disks)

Larger, slower, and cheaper (per byte) storage devices Remote secondary storage (distributed file systems, Web servers)

Local disks hold files retrieved from disks on remote network servers.

Main memory holds disk blocks retrieved from local disks.

Off-chip L cache (SRAM)

L1 cache holds cache lines retrieved from the L2 cache.

CPU registers hold words retrieved from cache memory.

L2 cache holds cache lines retrieved from memory.

L0:

L1:

L2:

L3:

L4:

L5:

Smaller, faster, and costlier (per byte) storage devices