~/bend-docscommunity

performance/bang_after_fork.bend fails

raw source on the hub · import bend-lint-rules@0.1.0.0/performance/bang_after_fork.bend as Bang_after_fork

performance/bang_after_fork: a ! call that runs after a fork of the same evaluation, so Bend runs it on the CPU pool, not on the GPU: in its definition, a let before it forks (a parallel let, or a value that calls a definition under which a parallel let runs), or one of its arguments does. Heuristics: a bang that follows the host's forks in one evaluation runs on the CPU pool ("bend guide shaders"); a ! call is not one of those forks: Bend's radix sort benchmark, three ! calls in a row, took the same time with IO steps between them. Measured on a discrete GPU, a numeric bang that took 0.55 s on the GPU after an IO step took 3.9 s, its time on the CPU pool, after a parallel let, after a let whose value forked in a call, and with an argument that forked; after a let whose value looped without forking, it stayed on the GPU. A short call loses little on the CPU pool. An IO step (<- in a do block) starts a new evaluation, so a fork before one does not count; nor does a fork in a definition that calls this one, which the rule does not follow. A ! call of a definition under which no parallel let runs, or of one that returns Unit, is left to performance/gpu_fit and performance/drop_in_bang: they ask to remove the !.

6 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
import ./deep_call_in_fork.bend as Deep
import ./gpu_fit.bend as GpuFit