Skip to content

feat: add opt-in Highway SIMD support to DSUMPW - #15106

Draft
teddygood wants to merge 5 commits into
stdlib-js:developfrom
teddygood:feature/dsumpw-highway-review
Draft

feat: add opt-in Highway SIMD support to DSUMPW#15106
teddygood wants to merge 5 commits into
stdlib-js:developfrom
teddygood:feature/dsumpw-highway-review

Conversation

@teddygood

@teddygood teddygood commented Sep 8, 2026

Copy link
Copy Markdown

Description

What is the purpose of this pull request?

This pull request:

  • adds optional Highway 1.4.0 installation and a reusable static runtime.
  • adds opt-in Highway SIMD to DSUMPW for its native add-on and the Wasm DMEANPW package.

With SIMD_BACKEND=highway, inputs with N > 128 and unit stride use Highway, preserving the existing addition order and C interface. Default builds still use C without requiring Highway or CMake. Highway builds require C++17, and Wasm requires a SIMD-capable runtime. See the [installation guide](https://github.com/teddygood/stdlib/blob/feature/dsumpw-highway-review/tools/make/lib/install/README.md#highway) for native build requirements and options.

I chose Highway mainly for how it handles multiple CPU targets. The DSUMPW comparisons with direct intrinsics, SIMDe, and xsimd gave similar throughput. xsimd also supports runtime dispatch, but my prototype needed separate SSE2 and AVX2 build targets and compiler flags. Highway handles target generation and native dispatch, which I expect to make adding more kernels easier.

Both xsimd and Highway worked in Wasm. This implementation shares the Highway kernel between native and Wasm builds, though it requires C++17 and additional build setup.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

Does the shared Highway runtime and opt-in build setup fit stdlib's build system?

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Performance

Measured with benchmark.ndarray.native.js and benchmark.module.ndarray.js in the following environment:

  • Linux x86-64 VM
  • Node.js 22.22.3
  • GCC/G++ 15.2 (Release build)
  • Emscripten 6.0.9

Each path and backend was measured in six independent runs. Throughput is the median of per-run medians of three repetitions.

Highway/default C throughput for each path:

N Native DSUMPW Wasm DMEANPW (calls DSUMPW)
10 0.98x 0.99x
100 0.99x 0.99x
1,000 1.52x 1.71x
10,000 2.05x 1.74x
100,000 1.86x 1.71x
1,000,000 1.68x 1.73x

Measurements used repeated calls after warmup. Wasm uses Module.ndarray with inputs already in Wasm memory, excluding module initialization and copying JavaScript typed arrays into Wasm memory.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

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

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

I used GPT-6 Astra to generate and refine tests and benchmarks.


@stdlib-js/reviewers

Add optional Highway download, checksum verification, extraction, and
header installation tests using the existing dependency Make rules.
Keep Highway out of the default development dependency installation.

Verified a fresh parallel installation and rejection of an invalid
checksum before extraction. Existing DSUMPW package tests pass.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Build the upstream hwy target as a reusable static library and export
its headers, compile definitions, and link dependencies as metadata.
Add runtime linkage and metadata checks alongside installation docs.

Verified fresh GCC builds with and without libatomic, CTest, seven
metadata assertions, and filename lint tests.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Select the Highway kernel through the native manifest and link the
prepared runtime from GYP. Keep the existing C implementation when the
backend is unset, and preserve the pairwise reduction grouping.

Add native parity and manifest checks with build documentation.
Verified 175 assertions for GCC and Clang Release and Debug, GCC with
libatomic, and the restored default build. Missing-runtime configuration
and 14 integration assertions also pass.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Add a static Wasm entry for the shared DSUMPW kernel and propagate
backend sources and definitions through the DMEANPW manifest chain.
Build C and C++ inputs separately while retaining scalar defaults.

Check pointers, special values, and definition resolution failures.
Fresh scalar and Highway builds each pass 106 assertions. Verified
22 integration assertions, backend switching, definition invalidation,
and 79 assertions for legacy scalar DASUM.

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: passed
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@teddygood
teddygood requested a review from a team September 8, 2026 13:04
@stdlib-bot

Copy link
Copy Markdown
Contributor

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

Getting Started

Next Steps

  1. A project maintainer will approve GitHub Actions workflows for your PR.
  2. All CI checks must pass before your submission can be fully reviewed.
  3. You'll need to address any failures in linting or unit tests.

Running Tests Locally

You can use make to run any of the CI commands locally from the root directory of the stdlib repository:

# Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"

# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"

If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR.

If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members.

We appreciate your contribution!

Documentation Links

@stdlib-bot stdlib-bot added First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Sep 8, 2026
@teddygood teddygood changed the title Feature/dsumpw highway review feat: add opt-in Highway SIMD support to DSUMPW Sep 8, 2026
@teddygood
teddygood marked this pull request as draft September 8, 2026 17:39
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor A pull request from a contributor who has never previously committed to the project repository.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants