Skip to content

fix: advance indices in unrolled loops of portable dcopy and scopy - #16122

Open
mantrapatel05 wants to merge 1 commit into
stdlib-js:developfrom
mantrapatel05:fix/blas-copy-unit-stride-unrolled
Open

mantrapatel05 wants to merge 1 commit into
stdlib-js:developfrom
mantrapatel05:fix/blas-copy-unit-stride-unrolled

Conversation

@mantrapatel05

@mantrapatel05 mantrapatel05 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR fixes a unit-stride loop bug in the portable C implementations of blas/base/dcopy and blas/base/scopy. The unrolled loop copies seven elements per pass but did not advance ix and iy, so copies spanning multiple blocks repeated the first block and left later destination elements unchanged.

The loop now advances both indices by M after each pass. Regression tests cover lengths 14, 15, 16, 21, and 28 with non-zero offsets in both packages.

Related issue

Resolves #15823.

Checklist

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Testing

  • Compiled the portable C sources with GCC using -std=c99 -Wall -Wextra -Werror -O2; the direct harness passed for lengths 1 through 150 with non-zero offsets.
  • Ran the filtered DCOPY and SCOPY package suites; their JavaScript tests passed.
  • Native addon tests were skipped because the Windows C++ build tools required by node-gyp are not installed here.

On Linux and macOS, the native addon uses the Fortran implementation, so those builds do not exercise the portable C code changed here.

Resolves: stdlib-js#15823
Signed-off-by: Mantra Patel <patelmantra551@gmail.com>
@mantrapatel05
mantrapatel05 requested a review from a team October 13, 2026 16:59
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. labels Oct 13, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/dcopy $\\color{green}414/414$
$\\color{green}+100.00\\%$
$\\color{green}29/29$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}414/414$
$\\color{green}+100.00\\%$
blas/base/scopy $\\color{green}414/414$
$\\color{green}+100.00\\%$
$\\color{green}29/29$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}414/414$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

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

Labels

BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: portable DCOPY and SCOPY leave values uncopied for unit strides

2 participants