Skip to main content

for_each_token_permutation

Function for_each_token_permutation 

Source
pub fn for_each_token_permutation(
    policy: CompileTimePolicy,
    f: impl FnMut(&TokenPermutation),
) -> PermutationReport
Available on crate feature std only.
Expand description

Run f once for every unique combination of available SIMD tokens disabled.

Acquires a process-wide mutex to prevent concurrent token manipulation. Re-enables all tokens after each invocation, even if f panics.

§Permutation logic

  1. Resets any stale disabled state from previous tests
  2. Discovers which tokens are available on this CPU (summon()Some)
  3. Excludes tokens that can’t be disabled (compile-time guaranteed), applying policy
  4. Skips tokens the CPU doesn’t have — they’d produce duplicate states
  5. Generates all valid combinations respecting cascade hierarchy (disabling a parent implies its descendants are disabled too)
  6. Runs f for each unique effective state

§Panics

  • If policy is CompileTimePolicy::Fail and any available token is compile-time guaranteed.
  • If f panics (after re-enabling tokens and releasing the mutex).