Skip to content

Fix SIMD article: correct loop logic, grammar, and style#52331

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-simd-example-error
Open

Fix SIMD article: correct loop logic, grammar, and style#52331
Copilot wants to merge 2 commits intomainfrom
copilot/fix-simd-example-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

The SIMD example had a loop condition bug (i < left.Length) that caused the "remaining items" loop to never execute — the first loop would consume all elements, leaving nothing for the scalar remainder pass.

The English docs already carry the correct fix using a remaining pre-calculation:

int remaining = length % Vector<double>.Count;

for (int i = 0; i < length - remaining; i += Vector<double>.Count)
{
    // process complete vector-sized chunks
}

for (int i = length - remaining; i < length; i++)
{
    // scalar tail: processes leftover elements
}

Additional fixes

  • Grammar: "SIMD-enable types""SIMD-enabled types" in the description frontmatter
  • Heading capitalization: "Simple Vectors""Simple vectors" (sentence case)
  • Frontmatter: updated ms.date and added ai-usage: ai-assisted
Original prompt

This section details on the original issue you should resolve

<issue_title>Error in SIMD example</issue_title>
<issue_description>---
Issue moved from dotnet/docs.fr-fr#118


From @polijp on Friday, November 6, 2020 8:37:34 PM

Dear all, I guess the example on this page is not correct, or I'm missing something:
for (i = 0; i < left.Length; i += offset)
{
var v1 = new Vector(left, i);
var v2 = new Vector(right, i);
(v1 * v2).CopyTo(result, i);
}

//remaining items
for (; i < left.Length; ++i)
{
    result[i] = left[i] * right[i];
}

if you exit the first loop, it means that i>=left. length, so the second loop will have no iteration.
Or obviously, some data must be processed there.


Détails du document

Ne pas modifier cette section. C’est obligatoire pour docs.microsoft.com ➟ Liaison des problèmes GitHub.

Comments on the Issue (you are @copilot in this section)

@gewarren --- **Issue moved from dotnet/docs.fr-fr#118** - Please respond to @polijp.

From @polijp on Friday, November 6, 2020 8:44:19 PM

To me the first loop should look like:
for (i = 0; i <= left.Length - offset; i += offset)
{
var v1 = new Vector(left, i);
var v2 = new Vector(right, i);
(v1 * v2).CopyTo(result, i);
}</comment_new>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.


Internal previews

📄 File 🔗 Preview link
docs/standard/simd.md docs/standard/simd

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Mar 17, 2026
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in SIMD example code Fix SIMD article: correct loop logic, grammar, and style Mar 17, 2026
Copilot AI requested a review from BillWagner March 17, 2026 18:36
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM, and the original bus was already fixed in the English version.

@BillWagner BillWagner marked this pull request as ready for review March 17, 2026 20:54
@BillWagner BillWagner requested review from a team and gewarren as code owners March 17, 2026 20:54
Copilot AI review requested due to automatic review settings March 17, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the SIMD documentation page metadata and heading capitalization to align with current docs conventions and disclose AI assistance.

Changes:

  • Fixed a typo in the frontmatter description (“SIMD-enable” → “SIMD-enabled”).
  • Updated ms.date to 03/17/2026 and added ai-usage: ai-assisted to the frontmatter.
  • Changed the “Simple Vectors” heading to sentence case (“Simple vectors”).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotnet-fundamentals/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in SIMD example

3 participants