Day 3
I. Last Time
A. Hw #1 Due now
B. Hw #2 Assigned
C. History
1. Mechanical Machines: Adders, Looms, etc.
Loom: Stored, Hardware Program
Babbage's Engine: Mathamatical Computer & Ada was Programmer
2. Tube Computers & WWII:
Eckert, Mauchley, von Neumann: Dept. of Defense
Turing: Dept. of Communications
Zuse: Halted due to War
3. Transistor Computers: Ugly Balls of wire, but faster
4. IC: Used for NASA/Space Program
Faster, Cheaper, "Object Oriented", More Reliable, Less Power Consumption
1. SSI: A chip does a single simple function (Basic Logic/math)
2. LSI: A chip does a more complex function: Memory
3. VLSI: A chip integrates several functions: Processor, Memory, etc.
D. Computer Components: Input, Output, IO, Storage, Processor (Datapath, Control)
II. Software Hierarchy & Components
A. OS (System Software): Manage Computers Resources
1. Hardware interface/communications (Think device drivers)
As time has progressed, these interfaces have gotten quite general
2. Starting Applications
3. Task Switching
4. Resource Sharing
B. One Hierarchy:
1. Hardware (Bare Metal)
2. OS (System Software)
3. User Applications
C. Hierarchy of APPLICATIONS used by Programmers:
1. Compiler
Take a High Level Language (HLL) and convert it into the assemble language
instructions that the machine actually understands. (Starts with "source code"
Assembly Language: A symbolic (mnemonic) based representation of the actual
instructions the computer understands.
The "BASE" Language of the computer.
Like any other language there are rules of syntax.
EX: a=b+c <-> ADD $1,$2,$3
2. Assembler
Converts the symbolic representation (Assembly Language) into the 1s and 0s
that the CPU actually reads (Machine Language).
Fills in/creates some details (Calculates some addresses, determines constants, etc.)
The Assembler ususally produces an OBJECT file as output.
3. Linker:
The sticky tape that binds the whole mess toghether.
The Linker "links" together seperate object files and fills in all the final details.
It produces a file in a format which the operating system is capable of "loading"
and which should be capable of executing. (Consolidates "globals", allows seperate
compilation of components)
D. All you want to know about assembly
Why know/understand ASM:
1. Can be smaller / Faster
2. Sometimes nesc. to work with hardware
3. Can sometimes better utilize Processors by using an instruction which the compiler would not.
4. On Some Processors, a compiler isn't available yet. (New design)
5. Sometimes need to be able to read to debug a program
6. "" "" to estimate run time of a program
The Downside:
1. Not very portable (and often "advantages" are lost if a little portable)
2. Expansion: 1 inst in C is often 10+ insts in asm
3. Tedious/Complex.: Often only 8-20 variables to use.
4. VERY difficult to read/understand
E. Other Tools:
Profiler: "Profiles" execution of code. Gives actual "timing" data of how long
parts of the code take to execute
Loader: A component of the OS which actually "loads" a file to be run.
(The file must be in the proper format for the loader to interpret)
A loader is often responsible for verifying that the "dynamic" parts of
a program are present and "linking" to them.
Statically linked: Except for the OS the program is self contained.
I.e. All subroutines/etc. are in one file (except system calls)
Dynamically linked: Some functions/subroutines/components are in another file which
needs to be present to run the program. Ex. Window's DLLs
This saves overall space because there is just a single copy of
the commonly used subroutines on disk. (Instead of a copy in every
program that uses it)
III. Intro. to Performance
A. What is Performance: Ex Fig 2.1 Pg 55: Which is best?
1. Performance is a way to answer the question: "Which is best"
2. But it also must take into account "Best for what"
B. Best in terms of what:
There are many things which computers may be measured against. Really, the most
important task is to first think about what the machine(s) in question will be used
for prior to attempting to determine which is best. I.e. Best at WHAT?
C. Common Measures of Computer Performance:
1. Graphics/Drawing Time: How many X can be drawn per second?
(High Quality Games for example - Often this is largely
a function of the video card and memory rather than the CPU)
2. Disk ACCESS: How long does it take to accessretrieve X?
For example a large database will be almost solely contained
on a disk. The disk speed is probably a lot more critical than
the CPU speed
3. Throughput: How many questions can be answered per second?
Again, in a large, multi-user data base a company might want to
answer as many questions per second as possible. EX. Amazon.com
4. Execution/Response Time: How long does it take to run this program?
This is the one that we'll worry about. And it's the most common used
by ASM programmers.
5. Power Consumption - Transmeta/Ugh.
D. For most of our purposes: Performance = 1/execution time
EX:
Machine A computes a task in 14s.
Machine B computes the same task in 7s.
We would say that Machine B is twice as fast as A.
Perf_A = 1/14s, Perf_B = 1/7s. Perf_B/Perf_A = 2
1. There are different "components" to execution time:
User Time: The whole thing. How longs it "feels" like it takes to a user
Often Called "Wall Clock" time
CPU Time = User CPU Time + System CPU Time
user CPU Time: Actual time spent by CPU on YOUR task in YOUR code
system CPU Time: Time spent by the CPU in OS tasks (Waiting for IO, etc.)
We usually worry mainly about USER time. Although most of our examples are
simple enough to consider yser cpu time the same as user time.
(The unix Time command corresponds to the above)
2. System Clock Based: Performance - It's all about megahertz (or is it)
Mega - Millions: 1,000,000; Hertz - Cycles Per second (A frequency).
Clock Wave Looks like: (Square Wave, Time on Axis)
Period = 1/frequency. 2ns period (2ns clock cycle) = 500MHz
a. What's the clock used for?
The clock is used to keep track and time the processing of asm instructions.
Instructions depend on the clock in vastly different ways.
Some Processors: All Instructions take the same number of clocks
Some Processors: Different Instructions take different numbers of clocks
Most Processors: Different Instructions take different numbers of clocks and
may depend on memory speed/etc.
Common Fallacy: Higher Clock Speed means faster.
Reality: Although this is sometimes true, it is rarely garunteed
if the clock speeds are even close ton one another.
I.e. when comparing a 1MHz machine to a 500MHz machine, I'd
feel pretty comfortable saying that the 500MHz machine is faster
(Although there really could be a few exceptions). When comparing
a 550MHz machine to a 500MHz machine, I'd be a LOT more cautious -
There are just too many factors affecting speed to be sure without
more knowledge
b. CPU Time = CPU Cycles * Cycle Time
See Example on Page 60:
1. Compute total number of clock cycles required by A
2. Multiply by 1.2
3. This tells us how many clock cycles must be completed in 6s,
so divide by 6 to determine clock rate
IV. Next Time:
1. Continue/Finish Performance
2. Reading: Handout & Book
3. Hw#2 Assigned