Expand description
Runtime dispatch over CPU feature levels.
One artifact per platform, several compilations of every hot loop. Each
loop covered here is compiled once for each level below, by the
multiversion crate, which attaches the level’s target_feature set to
a clone of the same generic Rust source; the compiler’s autovectoriser
is what turns each clone into vector code. Nothing in libjay writes SIMD
intrinsics, and nothing may start: vectorisation is the backend’s job.
Which clone runs is decided once per process. LIBJAY_CPU_LEVEL pins it
— baseline, v2, v3, v4, or native for what the machine offers
— and a level the CPU cannot run is clamped down to the one it can, so a
pinned level is always a level that actually executes.
A covered loop may still decline the vector clone: where the loop that
would widen is only a few elements long, entering a vector body costs
more than the width gives back, so the loop takes the baseline
compilation whatever the machine can run. verb::VECTOR_COLUMNS is that
rule and carries the measurement behind it.
An elementwise pass computes the same values whatever clone runs it:
vectorising dst[i] = a[i] + b[i] reorders nothing. A reduction is
another matter — the levels agree there only to the tolerance the float
contract already allows for regrouping an associative fold (§5.9).
Enums§
- Level
- A set of CPU features the hot loops are compiled for.
Functions§
- available
- Every level this machine can run, lowest first. A test that wants to compare the levels against each other iterates this; asking for one that is not in it would only get the highest one that is.
- detected
- The highest level this machine can run.
- level
- The level the hot loops dispatch to. Resolved once, then an atomic load.
- set_
level - Dispatch to
lfrom here on, clamped to what the machine can run. Returns the level that took effect.