CSE 30 -- Lecture 9 -- Oct 28

In this lecture, I went over the C handout's putnum and getnum routines and gave a proof sketch for their correctness.

The proof for putnum was inductive, with the base case being putnum(value,base) working correctly when 0 <= value < base, and the inductive step assuming that the function output the correct digit string for values of value where 0 <= value < basek, and showing that the output is still correct for values of value where basek <= value < basek+1.

To see the inductive step, consider the number

N = Sigmai=0k ai bi
and notice that
floor(N/base) = Sigmai=0k-1 ai+1 bi

The proof for getnum was based on the observation that

N = Sigmai=0k ai bi
where ai are the digits in base b may be rewritten as
N = ({[(akb + ak-1)b + ak-2]b + ... }b + a1)b + a0
and that value simply holds a running value that, after determining the next base b digit (in newdigit), gets replaced by value * base + newdigit.

New material covered in class: pipelining. See Chapter 2 of Kane & Heinrich to see the R2000/3000 pipeline.

The participatory demonstration that I used in class was the computation of

Sigmai=ab i
First, I had one person do this computation, one cycle per add, for a=10 and b=22. Next, I had a dozen people perform this in a pipeline, where each person added their own value to a ``current'' value on a sheet of paper. While we had to wait the same amount of time for the first value to show up, we were able to repeat this calculation by keeping the pipeline full (more sheets of paper) and the second output showed up one cycle after the first one.

Latency and throughput were defined in class: latency is the time until the output is done, and throughput is the aggregate rate at which output appears (this is sometimes an asymptotic value -- supercomputer manufacturers talk about ``Peak GFLOPS'' -- and more properly it is measured based on ``average-case input''.)

I started to talk about data and control hazards, and will go over this again next time.

[ CSE 80 | ACS home | CSE home | CSE calendar | bsy's home page ]
picture of bsy

bsy@cse.ucsd.edu, last updated Mon Oct 28 20:25:12 PST 1996.

email bsy