Skip to content

[teeny] distance/l1.h: rewrite the L1 line kernel on the now-blessed two-pass scan_ idiom #107

Description

@balbasty

Agent:claude-fastfields-to-teeny

Part of the teeny-refactor umbrella (fastfields-lib#21). L1 distance's outer batch/axis loop is already teenified; the per-line min-plus recurrence itself is still a bespoke hand-written sweep — the last one in the module.

teeny#464/#466 (merged) just blessed exactly this shape as the documented idiom for two-pass line recurrences (forward + backward), with a worked min-plus example in teeny's own docs:

constexprauto ax = axis<-1>{};
scan_(t, inf, minplus{w}, ax); // forwardscan_(t.flip(ax), inf, minplus{w}, ax); // backward

where minplus is a tiny device-safe functor: e = c = min(e, c + w) (matching the project's lambda-free engine convention).

Task

Replace distance/l1.h's hand-written line kernel with this pair. No fused scan2_ exists or is planned (teeny deliberately rejected it — "Keep it teeny", no profiling case for the fused form) — two plain scan_ calls is the correct, final shape, not an interim one.

Verify bit-exact against the existing L1 oracle test (tests/test_distance_l1.cpp — teeny's own PR #466 already added two cases doing this same substitution against teeny's own jitfields reference, as a cross-check pattern to follow here too).

Euclidean's line kernel (Felzenszwalb lower-envelope-of-parabolas) is not in scope here — it needs random access into whole-line scratch buffers and a data-dependent stack pop, correctly identified as not scan-shaped in the earlier deep review. Leave it as the bespoke kernel it already is.

Priority

Low — small, well-scoped, mechanical once the teeny pin is bumped past dcd591c to include #465/#466. Good candidate to bundle with whatever PR next bumps the external/teeny pin.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions