bench: refactor to use dynamic memory allocation - #14099
Merged
Merged
Conversation
Propagates fix from 91c2fae ("chore: clean-up") to sibling packages with the same variable-length-array usage in C benchmark files. Stack arrays sized by runtime benchmark lengths reach ~16 MB worst case (e.g. `double A[ N*N ]` with N=1000), exceeding default stack limits; converts them to malloc/free in `blas/base/*`, `lapack/base/dlacpy`, and `stats/strided/*` benchmarks. Ref: #8643 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSCf4wFDyy8QnpxnPxLFVr
cppcheck's uninitdata checker cannot see that the heap-allocated `stdlib_complex128_t` array is initialized via the struct-returning `stdlib_complex128` constructor before the post-loop NaN checks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DSCf4wFDyy8QnpxnPxLFVr
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
kgryte
marked this pull request as ready for review
August 9, 2026 20:55
kgryte
approved these changes
Aug 9, 2026
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.
Description
This pull request:
developbetween 2026-08-08 16:20 (-0700) and 2026-08-09 06:04 (-0700) to sibling packages.Applies the stack-allocation fix from 91c2fae (#14054, #8643) to the 13 remaining benchmark files still declaring runtime-sized C arrays on the stack. Worst offenders blow past the 8 MB default stack limit —
lapack/base/dlacpy'sdouble A[ N*N ]hits ~8 MB per array at N=1000, andblas/base/dznrm2/zscal'sdouble X[ len*2 ]hits ~16 MB at len=10^6 — and VLAs are optional in C11 regardless. All affected files switch tomalloc/free:blas/base/{scnrm2,dznrm2,scasum,zdrot,zscal,zdscal,dgemv,sgemv,dger,sger}lapack/base/dlacpystats/strided/{dcovmatmtk,dnanmskmax}dnanmskmaxwas left partially converted by earlier work —xwas already heap-allocated butmaskremained a VLA — and is now brought in line with its siblingsdnanmskmin/dnanmskrange.Related Issues
This pull request has the following related issues:
Questions
No.
Other
Validation performed before inclusion: repo-wide VLA sweep over
benchmark/**/*.c(multiple search patterns, false positives on#define-sized arrays and indexing expressions excluded); two independent validation passes reading each target file in full (confirming runtime-sized declarations, single-return control flow, nosizeof/address-of usage on candidate arrays,<stdlib.h>availability); a per-site adaptation pass; a style-consistency pass; andgcc -fsyntax-onlyover all modified files with resolved@stdlibinclude paths.Deliberately excluded:
blas/base/zaxpy(worst-case VLA is ~10 KB —main()passesN = floor(sqrt(10^i)), so the stack-overflow rationale does not apply);blas/ext/base/ndarray/{csum,zsum}addon.cconst-view normalization (constness already handled via explicit cast; no defect present); comment-wording updates inblas/base/{scabs1,dcabs1}type tests (validators split on whether the legacy wording is defective in a zero-argument-only test block). Pre-existing latent issues inzdrot/dlacpyinit loops were intentionally left untouched to keep the diff scoped to the propagated fix.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of an automated fix-propagation routine: candidate sites were enumerated by search, independently validated by two review passes, adapted per site, style-checked, and syntax-checked before committing.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DSCf4wFDyy8QnpxnPxLFVr
Generated by Claude Code