Basis Lab

Why a GPU Is Built This Way

Five Seconds That Will Not Divide Cap a Thousand Workers at Twenty Times

Last timeTime for One, Rate for All

Some work divides among workers and some cannot. The part that cannot sets a ceiling on any number of workers, and slow workers reach that ceiling from a worse start.

Does it split

The first two lessons used jobs at the two extremes: items with nothing to do with each other, and a chain where every step needs the one before. A real job is a mixture, and the first skill is sorting it into the two kinds.

The test is one question asked of each piece. Does it need a result that some other piece is still producing? If no piece does, the pieces are independent and any number of workers can hold one each. Reading the same inputs does not count. Two workers can read one array all day. What forces an order is one worker waiting for another's answer.

FIG 1The test applied to five computations
stepcomputationwhat one piece needsdoes it splitwhat happened
1brighten every pixel of an imageits own pixel and nothing elseyes, one piece per pixelNo pixel's new value depends on another's. This is the shape a GPU was first built for.
2add up an arrayits own slice of the arrayyes, apart from a short joining stepEach worker totals a slice. The partial totals then have to be added together, and that join is work that does not divide evenly.
3a running total, element by elementthe running total just before itno, as writtenEach output is the previous output plus one element. Written this way it is a chain.
4a simulation over many time stepsthe whole state after the step beforeinside a step yes, across steps noA mixture. The cells of one step can be updated side by side, and the steps themselves stay in order.
5read the input file and set upthe file, in ordernoNearly every job begins and ends with something like this.
5 steps
Only the first row splits completely. The others each keep a part that has to be done in order, and that part is what the rest of this lesson is about.

The part that will not divide

Take a job that is 100 seconds of work for one plain worker. Reading it with the test above shows that 5 seconds of it will not divide and 95 seconds will.

FIG 2Finish time on w workers
seconds until the job is finished
seconds of work that will not divide
seconds of work that divides
number of workers, each of speed 1
The worker count sits under one term only. Doubling w halves the second term and leaves the first exactly where it was, so the first term is what remains when the workers have done all they can.

On sixteen workers that is 5+95/16=10.945 + 95/16 = 10.94 seconds, about 9.1 times faster than one worker. On 1,024 workers it is 5+95/1024=5.095 + 95/1024 = 5.09 seconds, 19.6 times faster. Sixty-four times the workers bought barely twice the speed, and the second term is now under a tenth of a second.

The lesson stops here

4 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Same Chip Buys One Worker at Speed Four or Sixteen at Speed One
  2. 02Why a Machine Can Be Four Times Slower and Four Times Faster at Onceopening only
  3. 03Five Seconds That Will Not Divide Cap a Thousand Workers at Twenty Timesyou are here
  4. 04Thirty-Two Workers Share One Stream of Instructions, and One Dissenter Stalls Them Allopening only
  5. 05How a GPU Stays Busy While Every One of Its Workers Is Waiting for Memoryopening only
  6. 06How Big a Job Must Be Before Sending It to the GPU Pays for the Journeyopening only
  7. 07Three Numbers on a GPU Data Sheet and How to Tell Which One Limits Your Jobopening only
  8. 08Four Kinds of Job a GPU Does Worse Than the Processor Beside Itopening only

Read alongside