From 06890ef985bfb6198d76461d0656212775148124 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 9 Aug 2026 13:32:52 +0000 Subject: [PATCH 1/7] chore: replace VLAs with heap allocation in C benchmarks Propagates fix from 91c2fae9c ("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: https://github.com/stdlib-js/stdlib/issues/8643 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01DSCf4wFDyy8QnpxnPxLFVr --- .../base/dgemv/benchmark/c/benchmark.length.c | 24 ++++++++++++++----- .../base/dger/benchmark/c/benchmark.length.c | 24 ++++++++++++++----- .../dznrm2/benchmark/c/benchmark.length.c | 8 +++++-- .../scasum/benchmark/c/benchmark.length.c | 8 +++++-- .../scnrm2/benchmark/c/benchmark.length.c | 8 +++++-- .../base/sgemv/benchmark/c/benchmark.length.c | 24 ++++++++++++++----- .../base/sger/benchmark/c/benchmark.length.c | 24 ++++++++++++++----- .../base/zdrot/benchmark/c/benchmark.length.c | 16 +++++++++---- .../zdscal/benchmark/c/benchmark.length.c | 8 +++++-- .../base/zscal/benchmark/c/benchmark.length.c | 8 +++++-- .../base/dlacpy/benchmark/c/benchmark.size.c | 16 +++++++++---- .../dcovmatmtk/benchmark/c/benchmark.size.c | 24 ++++++++++++++----- .../dnanmskmax/benchmark/c/benchmark.length.c | 8 +++++-- 13 files changed, 150 insertions(+), 50 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c index 912eaae082b8..1a3d8f32222b 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c @@ -96,13 +96,16 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + x = (double *) malloc( N * sizeof( double ) ); + y = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_double()*20.0 ) - 10.0; y[ i ] = ( rand_double()*20.0 ) - 10.0; @@ -123,6 +126,9 @@ static double benchmark1( int iterations, int N ) { if ( y[ i%N ] != y[ i%N ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } @@ -135,13 +141,16 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + x = (double *) malloc( N * sizeof( double ) ); + y = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_double()*20.0 ) - 10.0; y[ i ] = ( rand_double()*20.0 ) - 10.0; @@ -162,6 +171,9 @@ static double benchmark2( int iterations, int N ) { if ( y[ i%N ] != y[ i%N ] ){ printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c index 754dc8568cab..26c91c8c7444 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dger/benchmark/c/benchmark.length.c @@ -97,13 +97,16 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + x = (double *) malloc( N * sizeof( double ) ); + y = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_double()*20.0 ) - 10.0; y[ i ] = ( rand_double()*20.0 ) - 10.0; @@ -124,6 +127,9 @@ static double benchmark1( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } @@ -136,13 +142,16 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + x = (double *) malloc( N * sizeof( double ) ); + y = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_double()*20.0 ) - 10.0; y[ i ] = ( rand_double()*20.0 ) - 10.0; @@ -163,6 +172,9 @@ static double benchmark2( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c index a9a222d8332e..2227c6d2d850 100644 --- a/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c @@ -95,12 +95,13 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - double X[ len*2 ]; + double *X; double elapsed; double norm; double t; int i; + X = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_double()*10000.0 ) - 5000.0; X[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; @@ -118,6 +119,7 @@ static double benchmark1( int iterations, int len ) { if ( norm != norm ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } @@ -129,12 +131,13 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - double X[ len*2 ]; + double *X; double elapsed; double norm; double t; int i; + X = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_double()*10000.0 ) - 5000.0; X[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; @@ -152,6 +155,7 @@ static double benchmark2( int iterations, int len ) { if ( norm != norm ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c index 007a5b94b37f..38a95b392665 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c @@ -95,12 +95,13 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - float X[ len*2 ]; + float *X; double elapsed; float out; double t; int i; + X = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_float()*10000.0f ) - 5000.0f; X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -118,6 +119,7 @@ static double benchmark1( int iterations, int len ) { if ( out != out ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } @@ -129,12 +131,13 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - float X[ len*2 ]; + float *X; double elapsed; float out; double t; int i; + X = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_float()*10000.0f ) - 5000.0f; X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -152,6 +155,7 @@ static double benchmark2( int iterations, int len ) { if ( out != out ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c index 342f0bff372a..b549b7c43112 100644 --- a/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c @@ -95,12 +95,13 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - float X[ len*2 ]; + float *X; double elapsed; float norm; double t; int i; + X = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_float()*10000.0f ) - 5000.0f; X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -118,6 +119,7 @@ static double benchmark1( int iterations, int len ) { if ( norm != norm ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } @@ -129,12 +131,13 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - float X[ len*2 ]; + float *X; double elapsed; float norm; double t; int i; + X = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { X[ i ] = ( rand_float()*10000.0f ) - 5000.0f; X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -152,6 +155,7 @@ static double benchmark2( int iterations, int len ) { if ( norm != norm ) { printf( "should not return NaN\n" ); } + free( X ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index 4f90a56409e5..e66c5ade65f4 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -96,13 +96,16 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; - float y[ N ]; + float *A; + float *x; + float *y; double t; int i; int j; + A = (float *) malloc( N * N * sizeof( float ) ); + x = (float *) malloc( N * sizeof( float ) ); + y = (float *) malloc( N * sizeof( float ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_float()*20.0f ) - 10.0f; y[ i ] = ( rand_float()*20.0f ) - 10.0f; @@ -123,6 +126,9 @@ static double benchmark1( int iterations, int N ) { if ( y[ i%N ] != y[ i%N ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } @@ -135,13 +141,16 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; - float y[ N ]; + float *A; + float *x; + float *y; double t; int i; int j; + A = (float *) malloc( N * N * sizeof( float ) ); + x = (float *) malloc( N * sizeof( float ) ); + y = (float *) malloc( N * sizeof( float ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_float()*20.0f ) - 10.0f; y[ i ] = ( rand_float()*20.0f ) - 10.0f; @@ -162,6 +171,9 @@ static double benchmark2( int iterations, int N ) { if ( y[ i%N ] != y[ i%N ] ){ printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c index c0539ad9f739..8ea7f81885ba 100644 --- a/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sger/benchmark/c/benchmark.length.c @@ -97,13 +97,16 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; - float y[ N ]; + float *A; + float *x; + float *y; double t; int i; int j; + A = (float *) malloc( N * N * sizeof( float ) ); + x = (float *) malloc( N * sizeof( float ) ); + y = (float *) malloc( N * sizeof( float ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_float()*20.0f ) - 10.0f; y[ i ] = ( rand_float()*20.0f ) - 10.0f; @@ -124,6 +127,9 @@ static double benchmark1( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } @@ -136,13 +142,16 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; - float y[ N ]; + float *A; + float *x; + float *y; double t; int i; int j; + A = (float *) malloc( N * N * sizeof( float ) ); + x = (float *) malloc( N * sizeof( float ) ); + y = (float *) malloc( N * sizeof( float ) ); for ( i = 0; i < N; i++ ) { x[ i ] = ( rand_float()*20.0f ) - 10.0f; y[ i ] = ( rand_float()*20.0f ) - 10.0f; @@ -163,6 +172,9 @@ static double benchmark2( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c index c3e30660da2d..a8ddc58ac98f 100644 --- a/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zdrot/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - double x[ len*2 ]; - double y[ len*2 ]; + double *x; + double *y; double t; int i; + x = (double *) malloc( len * 2 * sizeof( double ) ); + y = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_double()*10000.0 ) - 5000.0; x[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; @@ -119,6 +121,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -131,11 +135,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - double x[ len*2 ]; - double y[ len*2 ]; + double *x; + double *y; double t; int i; + x = (double *) malloc( len * 2 * sizeof( double ) ); + y = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_double()*10000.0 ) - 5000.0; x[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0; @@ -154,6 +160,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c index e4124b662fb7..04f83f3d0135 100644 --- a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c @@ -99,11 +99,12 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - stdlib_complex128_t x[ len ]; + stdlib_complex128_t *x; double elapsed; double t; int i; + x = (stdlib_complex128_t *) malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -119,6 +120,7 @@ static double benchmark1( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_imag( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -130,11 +132,12 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - stdlib_complex128_t x[ len ]; + stdlib_complex128_t *x; double elapsed; double t; int i; + x = (stdlib_complex128_t *) malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -150,6 +153,7 @@ static double benchmark2( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_real( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c index f325705dd28a..31a000ecc5ed 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c @@ -97,12 +97,13 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int len ) { stdlib_complex128_t alpha; - double x[ len*2 ]; + double *x; double elapsed; double t; int i; alpha = stdlib_complex128( 1.0, 0.0 ); + x = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len*2; i+=2 ) { x[ i ] = ( rand_double()*2.0 ) - 1.0; x[ i+1 ] = ( rand_double()*2.0 ) - 1.0; @@ -119,6 +120,7 @@ static double benchmark1( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -131,12 +133,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { stdlib_complex128_t alpha; - double x[ len*2 ]; + double *x; double elapsed; double t; int i; alpha = stdlib_complex128( 1.0, 0.0 ); + x = (double *) malloc( len * 2 * sizeof( double ) ); for ( i = 0; i < len*2; i+=2 ) { x[ i ] = ( rand_double()*2.0 ) - 1.0; x[ i+1 ] = ( rand_double()*2.0 ) - 1.0; @@ -153,6 +156,7 @@ static double benchmark2( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.size.c b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.size.c index 20b12950e661..27ba8d08686f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.size.c +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.size.c @@ -96,12 +96,14 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double B[ N*N ]; + double *A; + double *B; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + B = (double *) malloc( N * N * sizeof( double ) ); for ( i = 0, j = 0; i < N; i++, j += 2 ) { A[ j ] = ( rand_double()*20.0 ) - 10.0; A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; @@ -121,6 +123,8 @@ static double benchmark1( int iterations, int N ) { if ( B[ i%(N*2) ] != B[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( B ); return elapsed; } @@ -133,12 +137,14 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double B[ N*N ]; + double *A; + double *B; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + B = (double *) malloc( N * N * sizeof( double ) ); for ( i = 0, j = 0; i < N; i++, j += 2 ) { A[ j ] = ( rand_double()*20.0 ) - 10.0; A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; @@ -158,6 +164,8 @@ static double benchmark2( int iterations, int N ) { if ( B[ i%(N*2) ] != B[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( B ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c b/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c index c410945feb02..2736b34249cb 100644 --- a/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c +++ b/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c @@ -96,13 +96,16 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double B[ N*N ]; - double mu[ N ]; + double *A; + double *B; + double *mu; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + B = (double *) malloc( N * N * sizeof( double ) ); + mu = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { for ( j = 0; j < N; j++ ) { A[ (i*N)+j ] = ( rand_double()*20.0 ) - 10.0; @@ -123,6 +126,9 @@ static double benchmark1( int iterations, int N ) { if ( B[ i%(N*2) ] != B[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( B ); + free( mu ); return elapsed; } @@ -135,13 +141,16 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double B[ N*N ]; - double mu[ N ]; + double *A; + double *B; + double *mu; double t; int i; int j; + A = (double *) malloc( N * N * sizeof( double ) ); + B = (double *) malloc( N * N * sizeof( double ) ); + mu = (double *) malloc( N * sizeof( double ) ); for ( i = 0; i < N; i++ ) { for ( j = 0; j < N; j++ ) { A[ (i*N)+j ] = ( rand_double()*20.0 ) - 10.0; @@ -162,6 +171,9 @@ static double benchmark2( int iterations, int N ) { if ( B[ i%(N*2) ] != B[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( A ); + free( B ); + free( mu ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmskmax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dnanmskmax/benchmark/c/benchmark.length.c index 691f48f3ffbc..004ff31c7516 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmskmax/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmskmax/benchmark/c/benchmark.length.c @@ -95,7 +95,7 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; double *x; double v; @@ -103,6 +103,7 @@ static double benchmark1( int iterations, int len ) { int i; x = (double *) malloc( len * sizeof( double ) ); + mask = (unsigned char *) malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -126,6 +127,7 @@ static double benchmark1( int iterations, int len ) { printf( "should not return NaN\n" ); } free( x ); + free( mask ); return elapsed; } @@ -137,7 +139,7 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; double *x; double v; @@ -145,6 +147,7 @@ static double benchmark2( int iterations, int len ) { int i; x = (double *) malloc( len * sizeof( double ) ); + mask = (unsigned char *) malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -168,6 +171,7 @@ static double benchmark2( int iterations, int len ) { printf( "should not return NaN\n" ); } free( x ); + free( mask ); return elapsed; } From 7ac06a653e9135676ef0f579bc0b78d7b2d7cc7c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 9 Aug 2026 13:39:59 +0000 Subject: [PATCH 2/7] chore: suppress cppcheck false positive in `blas/base/zdscal` benchmark 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 Claude-Session: https://claude.ai/code/session_01DSCf4wFDyy8QnpxnPxLFVr --- .../@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c index 04f83f3d0135..780ffd4c1ea7 100644 --- a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c @@ -117,6 +117,7 @@ static double benchmark1( int iterations, int len ) { } } elapsed = tic() - t; + // cppcheck-suppress uninitdata if ( stdlib_base_is_nan( stdlib_complex128_imag( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } @@ -150,6 +151,7 @@ static double benchmark2( int iterations, int len ) { } } elapsed = tic() - t; + // cppcheck-suppress uninitdata if ( stdlib_base_is_nan( stdlib_complex128_real( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } From 8c37f09a5e0b55fb0cc8197ff266550f3551cbe7 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 13:53:15 -0700 Subject: [PATCH 3/7] bench: reorder variables Signed-off-by: Athan --- .../stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c b/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c index 2736b34249cb..98bbb4d07e04 100644 --- a/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c +++ b/lib/node_modules/@stdlib/stats/strided/dcovmatmtk/benchmark/c/benchmark.size.c @@ -96,9 +96,9 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; + double *mu; double *A; double *B; - double *mu; double t; int i; int j; @@ -141,9 +141,9 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; + double *mu; double *A; double *B; - double *mu; double t; int i; int j; From 1fbbdfe97fb916212082997752df70c1bf0605c0 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 13:53:42 -0700 Subject: [PATCH 4/7] bench: reorder vars Signed-off-by: Athan --- .../@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c index 2227c6d2d850..d31bd6ae4e2e 100644 --- a/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dznrm2/benchmark/c/benchmark.length.c @@ -95,9 +95,9 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - double *X; double elapsed; double norm; + double *X; double t; int i; @@ -131,9 +131,9 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - double *X; double elapsed; double norm; + double *X; double t; int i; From 4d87d23d915519140975269ee9e7e878c03ca567 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 13:54:09 -0700 Subject: [PATCH 5/7] bench: reorder vars Signed-off-by: Athan --- .../@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c index 38a95b392665..53da76d61bf8 100644 --- a/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/scasum/benchmark/c/benchmark.length.c @@ -95,10 +95,10 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - float *X; double elapsed; float out; double t; + float *X; int i; X = (float *) malloc( len * 2 * sizeof( float ) ); @@ -131,10 +131,10 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - float *X; double elapsed; float out; double t; + float *X; int i; X = (float *) malloc( len * 2 * sizeof( float ) ); From 7b8944aa24e6609e3a17e2a2c9ece24d58288e03 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 13:54:37 -0700 Subject: [PATCH 6/7] bench: reorder vars Signed-off-by: Athan --- .../@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c index b549b7c43112..9b498be25007 100644 --- a/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/scnrm2/benchmark/c/benchmark.length.c @@ -95,10 +95,10 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - float *X; double elapsed; float norm; double t; + float *X; int i; X = (float *) malloc( len * 2 * sizeof( float ) ); @@ -131,10 +131,10 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - float *X; double elapsed; float norm; double t; + float *X; int i; X = (float *) malloc( len * 2 * sizeof( float ) ); From f71cd9e990f6c42d46776d098c9f316765dabcd6 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 9 Aug 2026 13:55:24 -0700 Subject: [PATCH 7/7] bench: reorder vars Signed-off-by: Athan --- .../@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c index 31a000ecc5ed..9ebe44baa882 100644 --- a/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zscal/benchmark/c/benchmark.length.c @@ -97,8 +97,8 @@ static double rand_double( void ) { */ static double benchmark1( int iterations, int len ) { stdlib_complex128_t alpha; - double *x; double elapsed; + double *x; double t; int i; @@ -133,8 +133,8 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { stdlib_complex128_t alpha; - double *x; double elapsed; + double *x; double t; int i;