Conversation
Add the ndarray adapter and optional native bridge while preserving the adopted compensated prefix semantics and JavaScript fallback. Cover exact cancellation prefixes, aliases, scalar read order and configured integer widths. Assisted-by: OpenAI Codex
blas/ext/base/ndarray/dcusumkbn
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Progresses #14819.
Description
Add the missing native implementation for
blas/ext/base/ndarray/dcusumkbn: an ndarray-object C API, optional Node-API bridge, build metadata, header, C examples/benchmarks, native benchmark, fallback guards and meaningful cumulative-prefix regression coverage. The adopted one-argument JavaScript API and original JavaScript main are preserved; the existing compensated strided C kernel is reused unchanged.The bridge extracts the input, output and initial scalar in the original order, then snapshots the original view-helper values once. Native execution supports byte-offset typed views, independent signed/nonunit/zero strides, output mutation and sequential input/output aliases. Initial scalar extraction precedes writes and still occurs for empty input. Generic/accessor-backed buffers, incompatible metadata and wider valid JavaScript indexing use the existing strided path. The result remains the exact original output ndarray object.
The C adapter checks the actual configured
CBLAS_INTwidth before narrowing, including the reused kernel's final post-iteration increment. Exact integer division and unsigned-magnitude checks avoid dependence on extended floating-point precision. The addon uses conservative signed32 eligibility and intrinsic typed-array bounds; valid wider JavaScript cases fall back. Browser resolution selects the unchanged JavaScript implementation. Shared helpers and the numerical algorithm are unchanged.Related Issues
blas/ext/base/ndarraypackages #14819 (accepted non-GFI native-ndarray RFC; this contributes one natural package capability and does not close the tracking issue).Validation
CBLAS_INT, and 64-bit with suffix each compile with warnings as errors and pass 2,117 ASan/UBSan checks. A harmless mock-kernel probe compiled with 53-bitlong doublerejects the 64-bit post-increment overflow boundary before dispatch.CBLAS_API64controls suffixes separately from integer width.Questions
No.
Other
This adds the requested native capability using the existing improved Kahan–Babuška/Neumaier implementation, without claiming a new numerical algorithm. The C caller supplies valid physical buffers and descriptors; unsupported metadata or configured-width arithmetic returns without output writes. JavaScript fallback preserves its existing accepted behavior.
Checklist
AI Assistance
Yes
No
Code generation
Test/benchmark generation
Documentation (including examples)
Research and understanding
Disclosure
This contribution was authored primarily with OpenAI Codex under benatsf's explicit authorization to contribute. Codex generated the C ndarray adapter, normalized Node-API bridge, package-local dispatch guards, build metadata, exact-prefix fixtures, regression tests and native benchmark, and executed the recorded checks. A delegated Codex agent wrote the C documentation/example/benchmark; a separate agent independently reviewed the source, generated exact numerical fixtures and exercised the actual addon and configured-width C APIs. Codex reviewed and applied the contributing guidelines; the checked statement refers to that agent work and does not claim personal applicant review.
@stdlib-js/reviewers