From 1a5b2066bfb7b37d586324a76a23abe040ad49ac Mon Sep 17 00:00:00 2001 From: Omar Mohamed Date: Thu, 4 Dec 2025 04:35:27 +0200 Subject: [PATCH 1/4] perf:replace static memory allocation of large arrays in C benchmarks with dynamic memory allocation --- .../ext/base/ssumkbn/benchmark/c/benchmark.length.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c index 0d5820ea02f9..917cb26caf24 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c @@ -96,11 +96,11 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; float v; double t; int i; - + x = (float *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; } @@ -118,6 +118,7 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free(x); return elapsed; } @@ -130,11 +131,11 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; float v; double t; int i; - + x = (float *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; } @@ -152,6 +153,7 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free(x); return elapsed; } From 1842e5667662cd8fc8058d57482475d2ac14dce4 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 3 Dec 2025 22:10:19 -0800 Subject: [PATCH 2/4] style: add whitespace Signed-off-by: Athan --- .../blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c index 917cb26caf24..867d30a5a487 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c @@ -100,6 +100,7 @@ static double benchmark1( int iterations, int len ) { float v; double t; int i; + x = (float *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; @@ -118,7 +119,7 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } - free(x); + free( x ); return elapsed; } @@ -135,6 +136,7 @@ static double benchmark2( int iterations, int len ) { float v; double t; int i; + x = (float *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; @@ -153,7 +155,7 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } - free(x); + free( x ); return elapsed; } From 678cdd05e0c9c324fe447c88302b3679742e5282 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 3 Dec 2025 22:10:40 -0800 Subject: [PATCH 3/4] bench: fix dtype Signed-off-by: Athan --- .../blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c index 867d30a5a487..a65587d28a8d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c @@ -101,7 +101,7 @@ static double benchmark1( int iterations, int len ) { double t; int i; - x = (float *) malloc( len * sizeof( double ) ); + x = (float *) malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; } From cdc78ffd33f168d1b8d0bd05c5c4826007ba22ad Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 3 Dec 2025 22:10:57 -0800 Subject: [PATCH 4/4] bench: fix dtype Signed-off-by: Athan --- .../blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c index a65587d28a8d..641048c9a936 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ssumkbn/benchmark/c/benchmark.length.c @@ -137,7 +137,7 @@ static double benchmark2( int iterations, int len ) { double t; int i; - x = (float *) malloc( len * sizeof( double ) ); + x = (float *) malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; }