Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Notes

1. Computer Abstractions and Technology

Diego Montero

Slide Sources: Patterson & Hennessy MK 3rd and 5th edition, adapted and supplemented

Facultad de Ingenierı́a

Semestre Septiembre2021 - Marzo2022

Introduction

Outline Notes

1 Introduction
Classes of Computing Applications and Their Characteristics
Welcome to the PostPC Era
Objectives of this course
Understanding Program Performance

2 Eight Great Ideas in Computer Architecture

3 Below Your Program


From a High-Level Language to the Language of Hardware

4 Under the Covers


Opening the Box

5 Performance
Defining Performance
Measuring Execution Time
Instruction Count and CPI

Montero, Diego (OAC-18586) Abstractions and Technology 1 / 49


Introduction

Relevance Notes

Computers have led to a third revolution for civilization

Applications that were economically infeasible suddenly become


practical
Computers in automobiles
Cell phones
Human genome project
World Wide Web
Search engines

Montero, Diego (OAC-18586) Abstractions and Technology 2 / 49

Introduction

Relevance Notes

Advances in this technology affects almost every aspect of our society

Hardware advances → programmers create wonderfully useful software

Today’s science fiction suggests tomorrow’s killer applications


self-driving cars
cashless society: bitcoins
augmented reality
artificial intelligence

Montero, Diego (OAC-18586) Abstractions and Technology 3 / 49


Introduction Classes of Computing Applications

Classes of Computing Applications Notes

Personal Computer (PCs)


single user: incorporates a display, keyboard and a mouse
good performance, low cost
merely 40 years old

Servers
multiple users, carry sizable workloads
accessed via a network
resources expandable, dependability

Supercomputers: high-end servers


highest performance and cost: tens of thousands of processors and
many terabytes of memory
high-end scientific and engineering calculations: weather forecasting, oil
exploration, protein structure

Montero, Diego (OAC-18586) Abstractions and Technology 4 / 49

Introduction Classes of Computing Applications

Classes of Computing Applications Notes

Embedded computers
designed to run one or a set of related applications

integrated with the hardware

largest class of computers and span the widest range of applications


and performance

found in your car, the computers in a television set, and the networks
of processors that control a modern airplane or cargo ship

Montero, Diego (OAC-18586) Abstractions and Technology 5 / 49


Introduction PostPC

Welcome to the PostPC Era Notes

Figure: The number manufactured per year of tablets and smart phones, which
reflect the post-PC era, versus PC and traditional cell phones.

Montero, Diego (OAC-18586) Abstractions and Technology 6 / 49

Introduction PostPC

Classes of Computing Applications Notes

Personal mobile device (PMD)


battery operated
wireless connectivity
smart phones, tablets

Cloud Computing
Warehouse Scale Computers (WSC)
Software as a Service (SaaS)
Portion of software run on a PMD and a portion run in the Cloud
Amazon, Google

Montero, Diego (OAC-18586) Abstractions and Technology 7 / 49


Introduction Objectives

Objectives Notes

How are programs written in a high-level language, such as C or Java,


translated into the language of the hardware, and how does the
hardware execute the resulting program?

What is the interface between the software and the hardware, and
how does software instruct the hardware to perform needed functions?

What determines the performance of a program, and how can a


programmer improve the performance?

What techniques can be used by hardware designers to improve


performance?

Montero, Diego (OAC-18586) Abstractions and Technology 8 / 49

Introduction Objectives

Objectives Notes

The answers to these questions will enable us to:


Improve the performance of a program
Select a specific hardware to execute a specific application

The rest of the course content:


basic ideas and definitions
Hardware and Software components
Performance evaluation

Montero, Diego (OAC-18586) Abstractions and Technology 9 / 49


Introduction Performance

Performance of a program Notes

Effectiveness of the algorithms used


Software systems used to create and translate the program into
machine instructions
Effectiveness of the computer in executing those instructions (I/O
operations may be included)

Montero, Diego (OAC-18586) Abstractions and Technology 10 / 49

Introduction Performance

Performance of a program Notes

Hardware or software How this component affects


component performance
Determines both the number of
source-level statements and the
Algorithm
number of I/O operations
executed
Determines the number of computer
Programming language,
instructions for each source-level
compiler, and architecture
statement
Processor and memory Determines how fast instructions
system can be executed
I/O system (hardware and Determines how fast I/O operations
operating system) may be executed

Montero, Diego (OAC-18586) Abstractions and Technology 11 / 49


Introduction Performance

Exercise Notes

Can you think of examples where each of the following is the right place to
look for a performance bottleneck?
The algorithm chosen
The programming language or compiler
The operating system
The processor
The I/O system and devices

Montero, Diego (OAC-18586) Abstractions and Technology 12 / 49

Ideas

Outline Notes

1 Introduction
Classes of Computing Applications and Their Characteristics
Welcome to the PostPC Era
Objectives of this course
Understanding Program Performance

2 Eight Great Ideas in Computer Architecture

3 Below Your Program


From a High-Level Language to the Language of Hardware

4 Under the Covers


Opening the Box

5 Performance
Defining Performance
Measuring Execution Time
Instruction Count and CPI

Montero, Diego (OAC-18586) Abstractions and Technology 13 / 49


Ideas

Eight Great Ideas in Computer Architecture Notes

1 Design for Moore’s Law: integrated circuit resources double every


18–24 months
2 Use Abstraction to Simplify Design: design at different levels of
representation; lower-level details are hidden→simpler model at higher
levels higher levels
3 Make the Common Case Fast
4 Performance via Parallelism
5 Performance via Pipelining
6 Performance via Prediction
7 Hierarchy of Memories
8 Dependability via Redundancy

Montero, Diego (OAC-18586) Abstractions and Technology 14 / 49

Below Your Program

Outline Notes

1 Introduction
Classes of Computing Applications and Their Characteristics
Welcome to the PostPC Era
Objectives of this course
Understanding Program Performance

2 Eight Great Ideas in Computer Architecture

3 Below Your Program


From a High-Level Language to the Language of Hardware

4 Under the Covers


Opening the Box

5 Performance
Defining Performance
Measuring Execution Time
Instruction Count and CPI

Montero, Diego (OAC-18586) Abstractions and Technology 15 / 49


Below Your Program

Below Your Program Notes

Typical application → millions of lines of code and rely on


sophisticated libraries
The hardware in a computer can only execute extremely simple
low-level instructions
From complex application to simple instructions
several layers of software interpret/translate high-level operations into
simple computer-specific instructions
abstractions

Montero, Diego (OAC-18586) Abstractions and Technology 16 / 49

Below Your Program

Below Your Program Notes

Figure: A simplified view of hardware and software as hierarchical layers.

Montero, Diego (OAC-18586) Abstractions and Technology 17 / 49


Below Your Program

Systems software Notes

Operating system
Interfaces between a user’s program and the hardware
Handles basic input and output operations
Allocates storage and memory
Provides protected sharing of the computer among multiple
applications using it simultaneously.
Linux, iOS, Android and Windows

Compilers
translation of a program written in a high-level language, such as C,
C++, Java, or Visual Basic into instructions that the hardware can
execute

Montero, Diego (OAC-18586) Abstractions and Technology 18 / 49

Below Your Program High-Level to Hardware

From a High-Level Language to the Language of Hardware Notes

Computers understand “instructions”


collections of bits that the computer understands and obeys
1000110010100000 → ADD two numbers

First programmers communicated to computers in binary numbers

Assembler: translates a symbolic version of an instruction into the


binary version
add A, B → 1000110010100000

Machine language = binary language

Assembly language = symbolic language


write one line for every instruction

Montero, Diego (OAC-18586) Abstractions and Technology 19 / 49


Below Your Program High-Level to Hardware

From a High-Level Language to the Language of Hardware Notes

Figure:
Montero,CDiego
program compiled intoAbstractions
(OAC-18586) assembly language and then assembled into
and Technology 20 / 49

binary machine language

Below Your Program High-Level to Hardware

High-Level programming languages Notes

Allow the programmer to think in a more natural language

Improve programmer productivity.

Allow programs to be independent of the computer on which they


were developed

Compilers and assemblers translate high-level language programs to


the binary instructions

Montero, Diego (OAC-18586) Abstractions and Technology 21 / 49


Under the Covers

Outline Notes

1 Introduction
Classes of Computing Applications and Their Characteristics
Welcome to the PostPC Era
Objectives of this course
Understanding Program Performance

2 Eight Great Ideas in Computer Architecture

3 Below Your Program


From a High-Level Language to the Language of Hardware

4 Under the Covers


Opening the Box

5 Performance
Defining Performance
Measuring Execution Time
Instruction Count and CPI

Montero, Diego (OAC-18586) Abstractions and Technology 22 / 49

Under the Covers

Under the Covers Notes

The hardware in any


computer performs the same
basic functions
inputting data
outputting data
processing data
storing data

The five classic components


of a computer
Input
Output Figure: The organization of a
Memory computer, showing the five classic
Data and control path, or components.
processor

Montero, Diego (OAC-18586) Abstractions and Technology 23 / 49


Under the Covers Opening the Box

Opening the Box Notes

Figure: Components of the Apple iPad 2 A1395.

Montero, Diego (OAC-18586) Abstractions and Technology 24 / 49

Under the Covers Opening the Box

Opening the Box Notes

Figure: Mainboard of the Apple iPad 2 A1395.

ARM processor 1 GHz


512 MB memory
32 GB flash drive

Montero, Diego (OAC-18586) Abstractions and Technology 25 / 49


Under the Covers Opening the Box

Opening the Box Notes

Mainboard
connects to I/O devices
Memory
The processor

CPU central processor unit


datapath: performs aritmetic operations
control path: tells the datapath, memory and I/O devices what to do
according to the instructions

Memory
built with DRAM chips

Montero, Diego (OAC-18586) Abstractions and Technology 26 / 49

Under the Covers Opening the Box

Opening the Box Notes

Figure: The processor integrated circuit inside the A5 package.

Montero, Diego (OAC-18586) Abstractions and Technology 27 / 49


Under the Covers Opening the Box

Opening the Box Notes

Cache Memory
small and fast memory
act as a buffer for the DRAM
SRAM technology: faster but less dence → more expensive

Storage
Main memory, volatile, DRAM
non-volatile storage: Flash drives, hard drives

Montero, Diego (OAC-18586) Abstractions and Technology 28 / 49

Under the Covers Opening the Box

Instruction Set Architecture Notes

ISA (Instruction Set Architecture) or Architecture

Interface hardware ↔ lowest-level software

Includes anything programmers need to know to make a binary


machine language program work correctly

OS encapsulate I/O, memory allocation, and other low-level system


functions

ISA + OS = Application binary interface (ABI)

ISA allows us to talk about functions independently from the hardware

Montero, Diego (OAC-18586) Abstractions and Technology 29 / 49


Under the Covers Opening the Box

Abstractions Notes

Both hardware and software consist of hierarchical layers using abstraction,


with each lower layer hiding details from the level above.

One key interface between the levels of abstraction is the instruction set
architecture—the interface between the hardware and low-level software.
This abstract interface enables many implementations of varying cost and
performance to run identical software.

Montero, Diego (OAC-18586) Abstractions and Technology 30 / 49

Recap

Recap Notes

Code generation, translation and execution

Hardware components

Abstractions

ISA
Raspberry PI ISA: ARM Cortex-A72, ARMv8-A 64-bit instruction set.

Arduino UNO ISA: ATmega328P, AVR enhanced RISC architecture.


Advanced RISC Machine (ARM) is a processor architecture based on a
32-bit reduced instruction set (RISC) computer.

Montero, Diego (OAC-18586) Abstractions and Technology 31 / 49


Performance

Outline Notes

1 Introduction
Classes of Computing Applications and Their Characteristics
Welcome to the PostPC Era
Objectives of this course
Understanding Program Performance

2 Eight Great Ideas in Computer Architecture

3 Below Your Program


From a High-Level Language to the Language of Hardware

4 Under the Covers


Opening the Box

5 Performance
Defining Performance
Measuring Execution Time
Instruction Count and CPI

Montero, Diego (OAC-18586) Abstractions and Technology 32 / 49

Performance Defining Performance

Performance Notes

One computer has better performance than another?


Which airplane has the best performance?
Passenger Cruising range Cruising speed Passenger throughput
Airplane
capacity (miles) (m.p.h) (passengers x m.p.h.)
Boeing 737 240 3000 564 135,360
BAC/Sud Concorde 132 4000 1350 178,200
Boeing 777-200LR 301 9395 554 166,761
Airbus A380-800 853 8477 587 500,711

Montero, Diego (OAC-18586) Abstractions and Technology 33 / 49


Performance Defining Performance

Performance Notes

Comparing two different desktop PC


Response time or execution time: time for task completion (metric)

Datacenter
Throughput or bandwidth: total amount of work done in a given
time (metric), e.g., tasks/transactions/... per hour

Montero, Diego (OAC-18586) Abstractions and Technology 34 / 49

Performance Defining Performance

Response Time and Throughput: Example Notes

How are response time and throughput affected by:

1 Replacing the processor in a computer with a faster version?

2 Adding more processors?

We will focus on response time . . .

Montero, Diego (OAC-18586) Abstractions and Technology 35 / 49


Performance Defining Performance

Relative Performance Notes

For a computer X:
1
PerformanceX =
Execution timeX
For two computers X and Y, if the performance of X is greater than Y:

PerformanceX > PerformanceY

Execution timeY > Execution timeX

PerformanceX Execution timeY


= =n
PerformanceY Execution timeX
If X is n times as fast as Y, then the execution time on Y is n times as
long as it is on X.

Montero, Diego (OAC-18586) Abstractions and Technology 36 / 49

Performance Defining Performance

Relative Performance: Example Notes

If computer A runs a program in 10 seconds and computer B runs the


same program in 15 seconds, how much faster is A than B?
PerformanceA Execution timeB
= =n
PerformanceB Execution timeA
15
= 1.5
10
A is therefore 1.5 times as fast as B.

Montero, Diego (OAC-18586) Abstractions and Technology 37 / 49


Performance Measuring Execution Time

Measuring Execution Time Notes

Elapsed time
Total response time, including: processing, I/O, OS overhead, idle time
Determines system performance

CPU time
Time spent processing a given job — discounts I/O time, other jobs’
shares

Comprises user CPU time and system CPU time

Different programs are affected differently by CPU and system


performance

Focus on this one

Montero, Diego (OAC-18586) Abstractions and Technology 38 / 49

Performance Measuring Execution Time

CPU Clocking Notes

Operation of digital hardware governed by a a constant-rate clock

Clock period: duration of a clock cycle


e.g., 250ps = 0.25ns = 250Ö10–12s

Clock frequency (rate): cycles per second


e.g., 4.0GHz = 4000MHz = 4.0 times109 Hz

Montero, Diego (OAC-18586) Abstractions and Technology 39 / 49


Performance Measuring Execution Time

CPU Time Notes

CPU execution time CPU clock cycles


= × Clock cycle time
for a program for a program

CPU execution time CPU clock cycles for a program


=
for a program Clock rate

Performance improved by:


reducing the number of clock cycles required for a program

Increasing clock rate

Hardware designer must often trade off clock rate against cycle count

Montero, Diego (OAC-18586) Abstractions and Technology 40 / 49

Performance Measuring Execution Time

CPU Time: Example Notes

Computer A: 2GHz clock, 10s CPU time

Designing Computer B
Objective: 6s CPU time
Can do faster clock, but causes 1.2 × clock cycles of A

Montero, Diego (OAC-18586) Abstractions and Technology 41 / 49


Performance Measuring Execution Time

CPU Time: Example Notes

CPU clock cyclesA


CPU timeA =
Clock rateA
CPU clock cyclesA
10 seconds = cycles
2 × 109 second

cycles
CPU clock cyclesA = 10 seconds × 2 × 109 = 20 × 109 cycles
second
Clock rate for B?
1.2 × CPU clock cyclesA 1.2 × 20 × 109 cycles
CPU timeB = =
Clock rateB Clock rateB

1.2 × 20 × 109 cycles


Clock rateB = = 4 GHz
6 seconds
Montero, Diego (OAC-18586) Abstractions and Technology 42 / 49

Performance Instruction Count and CPI

Instruction Count and CPI Notes

Average clock cycles


CPU clock cycles = Instructions Count ×
per instruction (CPI)

CPU time = Instruction count × CPI × Clock cycle time

Instruction count × CPI


CPU time =
Clock rate

Instruction Count for a program


Determined by program, ISA and compiler
Average Cycles per instruction (CPI)
Determined by CPU hardware
If different instructions have different CPI: average CPI affected by
instruction mix
Montero, Diego (OAC-18586) Abstractions and Technology 43 / 49
Performance Instruction Count and CPI

CPI Example Notes

Computer A: Cycle Time = 250ps, CPI=2.0


Computer B: Cycle Time = 500ps, CPI=1.2
Same ISA → same instruction count I
Which is faster, and by how much?

CPUTimeA = I × CPIA × CycleTimeA


= I × 2.0 × 250ps = I × 500ps
CPUTimeB = I × CPIA × CycleTimeB
= I × 1.2 × 500ps = I × 600ps
CPUTimeA I × 600ps
= = 1.2
CPUTimeA I × 500ps
A is 1.2 times as faster as B.

Montero, Diego (OAC-18586) Abstractions and Technology 44 / 49

Performance Instruction Count and CPI

CPI in more detail: comparing code segments Notes

Compiler designer is trying to decide between two code sequences for a


particular computer.
CPI for each instruction class
A B C
CPI 1 2 3
For a particular high-level language statement, the compiler writer is
considering two code sequences:
Instruction counts for
each instruction class
Code sequence A B C
1 2 1 2
2 4 1 1
Which code sequence executes the most instructions? Which will be faster?
What is the CPI for each sequence?
Montero, Diego (OAC-18586) Abstractions and Technology 45 / 49
Performance Instruction Count and CPI

CPI in more detail: comparing code segments Notes

Recap: Clock Cycles = CPI × Instruction Count


if different instruction classes take different number of cycles
Pn
Clock Cycles = CPIi × Instruction Counti
i=1
Sequence 1:

InstructionCount = 2 + 1 + 2 = 5 10
CPI1 = 5 =2
ClockCycles = 2 × 1 + 1 × 2 + 2 × 3 = 10

Sequence 2:

InstructionCount = 4 + 1 + 1 = 6 9
CPI2 = 6 = 1.5
ClockCycles = 4 × 1 + 1 × 2 + 1 × 3 = 9

Montero, Diego (OAC-18586) Abstractions and Technology 46 / 49

Performance Instruction Count and CPI

Performance Summary Notes

The BIG Picture


Seconds Instructions Clock cycles Seconds
Time = = × ×
Program program Instructions ClockCycle

Components of performance Units of measure


CPU execution time for a program Seconds for the program
Instructions executed for the
Instruction count
program
Average number of clock c
Clock cycles per instruction (CPI)
ycles per instruction
Clock cycle time Seconds per clock cycle

Montero, Diego (OAC-18586) Abstractions and Technology 47 / 49


Performance Instruction Count and CPI

Performance Summary: understanding program Notes


performance

Hardware
or software Affects what?
component
Instruction count,
Algorithm
possibly CPI
Programming Instruction count,
language CPI
Instruction count,
Compiler
CPI
Instruction set Instruction count,
architecture clock rate, CPI

Montero, Diego (OAC-18586) Abstractions and Technology 48 / 49

Performance Instruction Count and CPI

Concluding Remarks Notes

Cost/performance is improving
Due to underlying technology development

Hierarchical layers of abstraction


In both hardware and software

Instruction set architecture


The hardware/software interface

Execution time: the best performance measure

Montero, Diego (OAC-18586) Abstractions and Technology 49 / 49

You might also like