Skip to content

Rewrite SIMD article as "SIMD and Hardware Intrinsics"#54834

Merged
tannergooding merged 6 commits into
dotnet:mainfrom
tannergooding:tannergooding-update-simd-docs
Jul 20, 2026
Merged

Rewrite SIMD article as "SIMD and Hardware Intrinsics"#54834
tannergooding merged 6 commits into
dotnet:mainfrom
tannergooding:tannergooding-update-simd-docs

Conversation

@tannergooding

@tannergooding tannergooding commented Jul 19, 2026

Copy link
Copy Markdown
Member

Modernizes docs/standard/simd.md, which was out of date and missing many of the SIMD/vectorization concepts that modern .NET exposes. Retitled to SIMD and Hardware Intrinsics (the official term) and updated its toc entry.

The article now works through the layered SIMD support from highest to lowest level, aligned with the current dotnet/runtime vectorization guidance:

  • System.Numerics fixed-shape vector/matrix types
  • Vector<T> (variable-width)
  • Cross-platform, fixed-width Vector64/128/256/512<T>
  • Platform-specific hardware intrinsics (X86, Arm, Wasm)
  • TensorPrimitives for ready-made vectorized span math

Highlights:

  • A near-complete common-operations reference table for the fixed-width vector APIs, grouped by category.
  • Code-structure and remainder-handling guidance -- width fan-out, small-input jump tables, and masked vs. idempotent tail handling (with the overlap/ConditionalSelect reasoning).
  • An instruction-set configuration-knob reference for .NET 11 (EnableHWIntrinsic, MaxVectorTBitWidth, PreferredVectorBitWidth, and the per-grouping Enable* x86/x64 and Arm64 switches), with an explicit callout that these are diagnostic tools, that they don''t affect ReadyToRun/Native AOT or necessarily internal runtime routines, that enabling an unsupported knob is ignored, and that the set may differ across releases.
  • Test all code paths and benchmark to confirm the win sections, plus refreshed best practices leading with "reuse the higher-level APIs first" and "start with Vector128<T>".

All code snippets live in a new docs/standard/snippets/simd/csharp/ project (net11.0) and were built and run to verify output before inclusion. bin//obj/ are gitignored and not part of the change.

Note

This article and its snippets were drafted with AI assistance (ai-usage: ai-assisted) and reviewed/verified against the runtime source and a compiled snippet project.


Internal previews

📄 File 🔗 Preview link
docs/fundamentals/toc.yml docs/fundamentals/toc
docs/standard/simd.md Use SIMD and hardware intrinsics in .NET

Modernize docs/standard/simd.md into a source-of-truth guide covering the layered SIMD support in .NET 11: System.Numerics fixed-shape types, Vector<T>, cross-platform Vector64/128/256/512, platform-specific hardware intrinsics, and TensorPrimitives. Adds a full common-operations reference, code-structure/remainder-handling guidance, an instruction-set configuration-knob reference, and testing/benchmarking sections, backed by a verified C# snippet project.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 19, 2026 19:39
@tannergooding
tannergooding requested review from a team and gewarren as code owners July 19, 2026 19:39
@dotnetrepoman dotnetrepoman Bot added this to the July 2026 milestone Jul 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the SIMD documentation by rewriting docs/standard/simd.md as “SIMD and Hardware Intrinsics”, expanding it to cover the full layered SIMD stack in modern .NET and backing the article with runnable snippet sources.

Changes:

  • Rewrites and retitles the SIMD article to cover System.Numerics, Vector<T>, fixed-width Vector64/128/256/512<T>, hardware intrinsics, and TensorPrimitives, including guidance on structure, remainder handling, testing, and benchmarking.
  • Adds a new docs/standard/snippets/simd/csharp/ snippet project with sample implementations used by the article.
  • Updates the fundamentals TOC entry to match the new article title.
Show a summary per file
File Description
docs/standard/simd.md Major rewrite and retitle of the SIMD article; adds new guidance, reference tables, and snippet references.
docs/fundamentals/toc.yml Updates the TOC display name to “SIMD and Hardware Intrinsics”.
docs/standard/snippets/simd/csharp/SimdSnippets.csproj Adds the snippet project (net11.0) and references System.Numerics.Tensors.
docs/standard/snippets/simd/csharp/Program.cs Adds a local verification runner for the snippet project.
docs/standard/snippets/simd/csharp/NumericsExamples.cs Adds System.Numerics vector/matrix and Vector<T> examples referenced by the article.
docs/standard/snippets/simd/csharp/AdvancedVectorization.cs Adds more advanced vectorization examples (width fan-out, masked remainder handling, jump-table remainder).
docs/standard/snippets/simd/csharp/SimpleVectorization.cs Adds simpler vectorization examples (idempotent remainder handling, ASCII validation).
docs/standard/snippets/simd/csharp/HardwareIntrinsicsExample.cs Adds a per-platform light-up example for hardware intrinsics with a portable fallback.
docs/standard/snippets/simd/csharp/TensorPrimitivesExample.cs Adds TensorPrimitives span-math examples referenced by the article.

Copilot's findings

  • Files reviewed: 9/9 changed files
  • Comments generated: 4

Comment thread docs/standard/snippets/simd/csharp/SimpleVectorization.cs Outdated
Comment thread docs/standard/simd.md
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
tannergooding and others added 3 commits July 19, 2026 12:44
Escape the angle brackets in the Vector<T> heading (MD033 / OPS disallowed-html-tag) and drop a trailing space in the config-knob callout (MD009).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Match the EnableArm64Rdm/Rcpc knob names: RDM (Rounding Doubling Multiply Accumulate), not RDMA; and RCpc casing without the duplicated word.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The overlapping-tail load underflows for a non-empty buffer shorter than one vector; fall back to a scalar scan in that case so the sample is correct for any length. Verify small and empty buffers in the runner.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread docs/standard/simd.md
Comment thread docs/fundamentals/toc.yml Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Comment thread docs/standard/simd.md Outdated
Sentence-case the title/heading/toc, drop redundant displayProperty=fullName from namespace xrefs, and take the copyedits from review (may->might, wording, and acronym spacing).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding

Copy link
Copy Markdown
Member Author

Thanks @gewarren -- applied all of these in 03d8f40: sentence-cased the title/H1/toc, dropped the redundant displayProperty=fullName from the namespace xrefs (including one in the intro paragraph you didn't flag), and took the copyedits (may->might, following table, acronym spacing, and the callout punctuation).

Note

Reply posted by Copilot on my behalf.

@BillWagner BillWagner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one clarification that we need here.

Comment thread docs/standard/simd.md Outdated
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
@tannergooding
tannergooding merged commit 2e690cf into dotnet:main Jul 20, 2026
9 checks passed
@tannergooding
tannergooding deleted the tannergooding-update-simd-docs branch July 20, 2026 20:52
tannergooding added a commit to dotnet/runtime that referenced this pull request Jul 21, 2026
)

The general SIMD and hardware-intrinsics guidance now lives in the
official docs, which were recently rewritten in dotnet/docs#54834. Our
in-repo `docs/coding-guidelines/vectorization-guidelines.md` had become
largely duplicative and out of sync, so this trims it down to defer to
the official article and keep only the dotnet/runtime-specific nuance:

- The `BoundedMemory` test helper for access-violation testing (with a
repo-relative link and a short usage example).
- The real `LastIndexOf` GC-hole case study (#73768 / fix #75857) behind
the "prefer the element-offset overloads" rule.
- The #64451 catalogue of real vectorized implementations to learn from.

The lane-crossing worked example that the official rewrite dropped is
being restored upstream in dotnet/docs#54840 rather than kept here,
since it''s general teaching content and belongs where it stays in sync.

----------

Also adds a `vectorization` skill covering both authoring and reviewing
SIMD code. Vectorization is a cross-cutting domain rather than a folder,
so a task-triggered skill fits better than a file-scoped
`.instructions.md`. The skill defers to the official docs and carries
the same repo-specific nuance (prefer the span/`LoadUnsafe`
element-offset overloads, `BoundedMemory` AV testing, the
acceleration-toggle env vars, `char`/`bool` reinterpretation, and
benchmarking before committing complexity), plus
authoring/testing/review checklists. `copilot-instructions.md` gets a
one-line nudge toward it, matching the existing
`code-review`/`performance-benchmark` pattern.

> [!NOTE]
> This PR description was drafted by GitHub Copilot.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants