From c73cdf4e3b2495a9a61a1429bf433460a02bea04 Mon Sep 17 00:00:00 2001 From: ishwarthecodddr Date: Mon, 8 Dec 2025 18:23:39 +0530 Subject: [PATCH 1/2] bench: refactor to use dynamic memory allocation in 'blas/base/cscal' --- .../base/ccopy/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../base/cscal/benchmark/c/benchmark.length.c | 8 ++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c index bb78a5ab0ff0..83533ae2aef3 100644 --- a/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len*2 ]; - float y[ len*2 ]; + float *x; + float *y; double t; int i; + x = (float *) malloc( len * 2 * sizeof( float ) ); + y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*10000.0f ) - 5000.0f; x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -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; - float x[ len*2 ]; - float y[ len*2 ]; + float *x; + float *y; double t; int i; + x = (float *) malloc( len * 2 * sizeof( float ) ); + y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*10000.0f ) - 5000.0f; x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -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/cscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/cscal/benchmark/c/benchmark.length.c index d8304dd48453..ee2163e5b25e 100644 --- a/lib/node_modules/@stdlib/blas/base/cscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/cscal/benchmark/c/benchmark.length.c @@ -97,12 +97,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { stdlib_complex64_t alpha; - float x[ len*2 ]; + float *x; double elapsed; double t; int i; alpha = stdlib_complex64( 1.0f, 0.0f ); + x = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; x[ i+1 ] = ( rand_float()*2.0f ) - 1.0f; @@ -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_complex64_t alpha; - float x[ len*2 ]; + float *x; double elapsed; double t; int i; alpha = stdlib_complex64( 1.0f, 0.0f ); + x = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; x[ i+1 ] = ( rand_float()*2.0f ) - 1.0f; @@ -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; } From 4f86109da3738e0869f57e78ae614bdfd73346b8 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 8 Dec 2025 17:47:29 -0800 Subject: [PATCH 2/2] Discard changes to lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c --- .../base/ccopy/benchmark/c/benchmark.length.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c index 83533ae2aef3..bb78a5ab0ff0 100644 --- a/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c @@ -96,13 +96,11 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float *x; - float *y; + float x[ len*2 ]; + float y[ len*2 ]; double t; int i; - x = (float *) malloc( len * 2 * sizeof( float ) ); - y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*10000.0f ) - 5000.0f; x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -121,8 +119,6 @@ static double benchmark1( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } - free( x ); - free( y ); return elapsed; } @@ -135,13 +131,11 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float *x; - float *y; + float x[ len*2 ]; + float y[ len*2 ]; double t; int i; - x = (float *) malloc( len * 2 * sizeof( float ) ); - y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*10000.0f ) - 5000.0f; x[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f; @@ -160,8 +154,6 @@ static double benchmark2( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } - free( x ); - free( y ); return elapsed; }