redbluegreen wiki

Bandwidth

What the memory system gives a streaming kernel, measured with the vector add.

coarse data fine data (COHERENT) theoretical peak 0 64 128 192 256 GB/s 1 100 10 thousand 1 million 100 million elements, log scale theoretical 256 GB/s 83 225 coarse 218 fine 222 one element: no bandwidth 133 us launch floor, about 30 MB at 225 GB/s
The vector add reaches 88 percent of the theoretical peak on the large sizes, and a one-element dispatch measures the launch floor instead of a bandwidth.

We measure bandwidth with vadd, which computes c[i] = a[i] + b[i].

The kernel:

  1. Each work-item handles one element. It does two loads and one store.
  2. A workgroup is 256 work-items. The grid is n rounded up to a multiple of 256.
  3. A bounds check on n stops the work-items past the end.
  4. The kernarg holds the a, b and c pointers and n.
  5. The code is 16 instructions.

No loaded value is used twice, so memory sets the speed.

The host times one dispatch. The clock starts just before the doorbell write. It stops when the completion signal reaches zero. So the time includes the launch.

Each size runs five reps with a fresh signal and reused buffers. We keep the best rep.

Bandwidth is 12 bytes per element over the best time: two reads and one write. We measured with the model server stopped and coarse data unless a row says fine.

elementsbest timeGB/s
1133 uslaunch floor
1,048,576151 us83
16,777,216924 us218
16,777,216, fine906 us222
67,108,8643,578 us225
67,108,864, finehangsopen item

The theoretical peak is 256 GB/s. The largest size reaches 225 GB/s, which is 88 percent of the peak.

At 1,048,576 elements the launch is still a large share of the time, so the rate is only 83 GB/s.

The launch floor is 133 us.

A dispatch of one element costs 133 us. Every dispatch pays this cost before it moves any memory.

At 225 GB/s, 133 us moves about 30 MB. A training step must move enough bytes that 133 us is small against it. So the floor sets a lower bound on the batch size.

Fine-grained data streams at the same speed as coarse data: 222 GB/s against 218 GB/s at 16,777,216 elements. So the COHERENT flag costs nothing on streaming loads.

At 67,108,864 fine elements (768 MiB), the kernel hangs before its first store and logs no fault. This is an open item. Our data stays coarse.

Two processes share the bandwidth.

With two rbg processes at once, their bandwidths add up to about the bandwidth of one process alone. With a model server generating alongside, our reps run at about half speed, and every result is correct.

The hardware runs the queues side by side. It does not starve one queue for another.

Sources