Path of Attunement
A short route from an ordinary function to a portable SIMD kernel
Write a function, let Archmage select its CPU context, and keep the work inside that context.
- Attune a kernel: an ordinary public function that selects a CPU tier for its whole loop.
- Stay in context: helpers that follow the caller's selected tier without another CPU probe.
- Add vectors: Magetypes operations, complete chunks, and the remaining elements.
Keep the complete reference nearby for explicit tiers, proofs, generics, methods, inlining, visibility, and legacy mappings. Use See the Expansion to compare source and generated code side by side, with target selection and mobile tabs.
You need two spellings for this route:
| Spelling | Purpose |
|---|---|
#[attune(...)] | Choose which implementations and callable functions to generate |
attuned!(helper(...)) | Call the helper appropriate to the enclosing context |
Start with #[attune(dispatch)] for a kernel called from ordinary code and
#[attune(_*)] for its internal helpers. Add other forms when the application
needs them. reattune! is an explicit request to reconsider the CPU tier inside
an existing context; it is not needed for the basic path.
Where to go next
The Archmage guide covers capability tokens, the
#[target_feature] safety model, raw intrinsics, testing, and architecture
details alongside #[attune]. The full attunement reference and migration
table covers explicit proofs, visibility, inline
policies, named tiers, method and generic restrictions, and legacy attribute
mappings.