Alterna · learning material
10.3 Many similar actions simultaneously
The matrix result cells can be calculated in parallel. The GPU is well suited for a large number of similar operations.
What this material covers
- Independent tasks still have to be distributed
Content and key concepts
On the previous page, size and accuracy.
The matrix result cells can be calculated in parallel. The GPU is well suited for a large number of similar operations.
The numbers have final accuracy; they have to be stored and moved. The matrix blocks produce a lot of independent work, but memory and group organization also affect the results.
Для изменения рисунка включитеJavaScript; расчёт и теория доступны далее.
Independent tasks still have to be distributed
CPU is suitable for managing logic, branches and successive relationships; GPU organizes a large number of streams for througput. This is not an assertion "CPU counts one, GPU all at the same time": modern CPU also vectorizes the work, and GPU is limited to resources and relationships.
In the training model, the tasks are combined into lockstep width groups.w The group lasts as long as its longest task.
non-measured letancy device
.
Take the 16 goals:8–1tick and 8–4ticks. Priw=8 and the group group's grouped order is 1–4icks, total.5 In the alternation of short and long, both groups are 4—ticks, all.8 Useful work 40lane-ticks is the same, allocated budget 40–64.
Experiment.
Change lanes and order at the same time as the work. Check the tail when the tasks are not divided by Width. Unused slots should not disappear from the efficiency denominator.
Restriction.
The model illustrates a simple lockstep and an imbalance. It does not model modern independent planning of instructions, occupancy, caches, interconnect or frequency. The number of lanes cannot be interpreted as "the number of kernels of your GPU." For a real choice of CPU/GPU, the measurements of specific implementation are needed.
work=[1]*8+[4]*8
grouped=sum(max(work[i:i+8]) for i in range(0,16,8))
mixed=[1,4]*8
interleaved=sum(max(mixed[i:i+8]) for i in range(0,16,8))
assert grouped==5 and interleaved==8 and sum(work)==40
The code repeats the operations just taken care of.
Completely checked Python-example Chapter
Available with a separate file; the short piece shown does not replace its implementation.
The model does not profile the equipment and does not know its actual frequency.
How does one cell of a work be calculated? How does this question continue?
Python examples of Chapter 10
Academic base