From 4782640c765f8b33145e6af4f7752e369767623c Mon Sep 17 00:00:00 2001 From: ishwarthecodddr Date: Tue, 9 Dec 2025 19:00:39 +0530 Subject: [PATCH 1/4] bench: refactor to use dynamic memory allocation in 'blas/base/ccopy' --- .../base/ccopy/benchmark/c/benchmark.length.c | 18 ++++++++++++------ 1 file changed, 12 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..69e91189d3f3 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,12 @@ 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 +120,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 +134,12 @@ 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 +158,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; } From 7d021b926c988fdb6fd6e4ea9aba83622c07127d Mon Sep 17 00:00:00 2001 From: ishwarthecodddr Date: Wed, 10 Dec 2025 10:09:27 +0530 Subject: [PATCH 2/4] fixed whitespace convention --- .../blas/base/ccopy/benchmark/c/benchmark.length.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 69e91189d3f3..7b06d7c93b1a 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 @@ -100,8 +100,8 @@ static double benchmark1( int iterations, int len ) { float *y; double t; int i; - x=(float*)malloc(len*2*sizeof(float)); - y=(float*)malloc(len*2*sizeof(float)); + 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; @@ -138,8 +138,8 @@ static double benchmark2( int iterations, int len ) { float *y; double t; int i; - x=(float*)malloc(len*2*sizeof(float)); - y=(float*)malloc(len*2*sizeof(float)); + 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; From 07cf471d4f8f8b702cfcd73eb14e5f86c2772146 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 22:51:49 -0800 Subject: [PATCH 3/4] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c | 2 ++ 1 file changed, 2 insertions(+) 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 7b06d7c93b1a..26749d48050f 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 @@ -100,6 +100,7 @@ static double benchmark1( int iterations, int len ) { 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++ ) { @@ -138,6 +139,7 @@ static double benchmark2( int iterations, int len ) { 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++ ) { From 2cfd91f83ce6016e33284a0c94cf62c1382a538f Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 9 Dec 2025 22:52:21 -0800 Subject: [PATCH 4/4] style: fix spacing Signed-off-by: Athan --- .../@stdlib/blas/base/ccopy/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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 26749d48050f..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 @@ -160,8 +160,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } - free(x); - free(y); + free( x ); + free( y ); return elapsed; }