Basis Lab

How a program runs

Work out from the bytes a job touches whether it fits on a device, how fast it could possibly run there, and what to change when memory and not arithmetic is the ceiling

Memory Is the Limit on a GPU

Most work on a GPU waits for bytes, not for arithmetic. This course covers what has to fit, how fast bytes arrive, how access order changes that rate, and what the options are when the job is too big.

8 lessons, written and corrected before you arrived. Reading them here needs no account. The first reads the whole way through; the others open and then stop, because a page nobody owns cannot tell who is reading it. Starting the course gives you your own copy, where every idea has problems standing under it and you can ask about any sentence.

Start reading

  1. 01Add Up the Largest Moment, Not the AverageWhether a job runs on a GPU at all is decided by the bytes it holds at its fullest moment, and that total can be worked out from the shapes before anything is launched.
  2. 02The Fastest a Job Can Run Is Its Bytes Divided by the Bandwidthopening onlyA GPU's memory delivers bytes at a published rate. Divide the bytes a job must read and write by that rate and you have a time no version of the job can beat.
  3. 03One Division Says Whether Faster Arithmetic Would Helpopening onlyDivide a job's operations by its bytes, divide the device's arithmetic rate by its memory rate, and compare the two. The smaller side names the limit you are against.
  4. 04Where a Byte Is Kept Decides What It Costs to Readopening onlyA worker on a GPU can hold a value in four places, each larger and slower than the one before, and the cost of a job depends on how often each value is read from which.
  5. 05A Group That Reads Next-Door Addresses Wastes Nothingopening onlyThe workers of a group read in the same step and the device fetches in fixed units of 32 bytes, so how far apart their addresses lie decides how much of each fetch is used.
  6. 06Store Each Field in Its Own Array and the Group Reads Next-Door Bytesopening onlyRecords kept whole put a worker's field 32 bytes from its neighbour's. Keeping each field in its own array puts them 4 bytes apart, and the fetches saved can be counted in advance.
  7. 07Use a Value Many Times While It Is Near and the Memory Stops Being the Limitopening onlyA job's operations per byte rise when each value fetched is used more than once before it is let go: by one worker, by a whole block of workers, or by many items at once.
  8. 08Four Ways to Fit, and What Each One Costsopening onlyA job too large for the device can use smaller numbers, smaller batches, memory off the device or a second device. Each has a price that can be worked out first.