You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scalar-operand maps: scale, shift, and the ops #5 listed but did not ship #38
#5's own issue text lists these as wanted, and the map mechanism landed without
them:
scale / shift on RegTile and RegVec (multiply/add by a scalar)
a free rsqrt(f32) beside exp2_approx / log2_approx
RegTile::add_assign
Surfaced again by #6, which found these are the only arithmetic left on any
example kernel's blocked-on list.
There is a structural reason they were missed, and it decides the fix
trait UnaryOp { fn apply(x: f32) -> f32; } is stateless — a unit struct
with an associated function. So scale(k) cannot be written as a UnaryOp at
all: there is nowhere to put k. That is why the mechanism covered ~30
functions and silently left this family behind; it is a hole in the trait shape,
not an oversight in the op list.
The clean fix reuses the existing BinaryOp set rather than adding a stateful
op trait — treat the scalar as the second operand:
Then scale is scalar_map::<Mul>, shift is scalar_map::<Add>, and
division-by-constant, clamping against a bound, and every other
tile-against-scalar op come free from ops that already exist. Same for RegVec
and ColVec.
A free rsqrt(f32) is separately trivial — the Rsqrt op struct already
exists, so it is a convenience wrapper. Worth adding for symmetry with exp2_approx / log2_approx, which kernels call directly.
Note on add_assign
RegTile::add_assign is in-place and therefore #31's territory — by-value row_map::<Mul> measured 168 -> 255 registers/thread at 128 columns against the
in-place scale_rows. Land the in-place map variants there and add_assign
falls out; do not add a one-off here that #31 would have to unify.
The same question applies to scalar_map: measure the by-value form at 128
columns (modal run modal_app.py::regcount, CPU-only). The 32-wide probes are
insensitive — see #31 — though note #6 found the reverse at its shapes, so
measure both rather than trusting either as the sensitive one.
Activity
device-tests: price the scalar map at both probe widths
examples: what the scalar-map probe says about #31's framing
Scalar-operand maps: scale, shift, and a free rsqrt over the existing…
Masking, against the coordinate origin a tiled kernel has (#7)
Masking, against the coordinate origin a tiled kernel has (#7)
Open the RegTile shape set, and mask against a coordinate origin (#23 +
In-place map variants, and what they are actually worth (#31) (#58)