performance/gpu_fit.bend fails
raw source on the hub · import bend-lint-rules@0.1.0.0/performance/gpu_fit.bend as Gpu_fit
performance/gpu_fit: a call that may run faster on the CPU than on the GPU, or the reverse: a ! call
(it runs on the GPU, if there is one) of a definition under which no parallel let runs, so one GPU
thread runs it alone; a ! call of a definition that forks but receives data, not only numbers; or a
call of a definition that forks over numbers only, made without !, from a definition that does not
fork.
Heuristics: measured on a discrete GPU (CUDA) against its machine's CPU (--gpu off): a ! on
BendSR's compute_mae, a list walk that never forks, took 6.5 s against 0.08 s without the ! (0.11 s
against 0.07 s on the CPU); Bend's slash boss draw, which forks over data, took 10.5 ms against 7.4 ms;
the GPU also costs a fixed 0.3 to 0.8 s to start there, after which numeric work is nearly free: a
numeric fork tree of 16,384 leaves took 0.95 s against 3.6 s on the CPU, but one that took 0.06 s on
the CPU took 0.49 s. The same draw takes 8 ms on an Apple M-series GPU (unified memory), and a high-end
desktop GPU drew it at 17 to 19 FPS ("bend guide shaders"): a discrete GPU pays for each page it reads
across PCIe, whatever its speed. The JS lane has no GPU. The hint to add a ! does not see a ! in a
caller: in Bend's benchmarks, which run under a ! at their top, its 7 hints were all wrong, and a !
in a ! was up to 4.6x slower. Nor does it see a fork before the call in the caller's evaluation,
which keeps the ! on the CPU (performance/bang_after_fork). It follows calls through the program's
files; a definition outside them is Base's, where only Image.free (and Image.drop, through it) forks.
Numbers are U32, I32, F32, Nat, Bool, Char (and their 64-bit forms), and a record of numbers only,
defined in the program's files; anything else is data. Erased and template parameters do not count. A
! call of a definition that returns Unit is left to performance/drop_in_bang.
4 imports
import Base import bend-lint-api@0.1.0.0/linter/lint.bend as Lint import bend-lint-api@0.1.0.0/shared/lists.bend as Lists import bend-lint-api@0.1.0.0/shared/names.bend as Names
The reader could not load this file (at 0x2b0a0dcada30f71a8eb4ec2e148b9279/linter/lint.bend:522). What bend.ts says:
Error:
- expected : a fresh constructor name (duplicate declaration: Text)
- observed : 'Text'
Location:
521 | Flag{on: Bool}
522>| Text{text: String}
| ^^^^
523 |