Skip to content

Vectorize _on_minor_arc_xyz for improved large-data processing performance #1623

Description

@hongyuchen1030

The current implementation still involves some branching. Given this is one of our computation hot paths — every edge in a hundred-GB mesh passes through it — vectorizing this function should meaningfully improve large-data processing, and it's also a prerequisite for our planned GPU and multithreading support.

Modern compilers will optimize branches, but that doesn't mean the result is optimized for vectorization — these are two different problems. The compiler-optimizes-branches argument (from that old shader blog and the Jason Booth rebuttal) is about a single function processing one item at a time.

Vectorization is a different thing entirely: instead of computing one edge's answer at a time, we want to hand the CPU (or GPU, or a batch of threads) a whole array of edges — say 8, or 10,000 — and have it compute all their answers in one shot, using the exact same formula applied uniformly across all of them. That only works if the formula has no per-item decision-making in it.

See [Avoiding Shader Conditionals](https://theorangeduck.com/page/avoiding-shader-conditionals) for how boolean masking replaces if-else branching with plain arithmetic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovements on existing features or infrastructure

    Projects

    Status
    📝 To-Do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions