From f2835000c971fddc1328266b2aadf78481975b20 Mon Sep 17 00:00:00 2001 From: sujalcharati Date: Thu, 11 Dec 2025 23:43:26 +0530 Subject: [PATCH 1/4] bench: refactor to use dynamic memory allocation in blas/ext/base/cfill --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../ext/base/cfill/benchmark/c/benchmark.length.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c index 12943c8d38a9..bd563aaae635 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c @@ -97,11 +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; + x = (float *) malloc( len * 2 * sizeof(float) ); + alpha = stdlib_complex64( 1.0f, 0.0f ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; @@ -120,6 +122,8 @@ static double benchmark1( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + + free( x ); return elapsed; } @@ -132,11 +136,11 @@ 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; - + x = (float *) malloc( len * 2 * sizeof(float) ); alpha = stdlib_complex64( 1.0f, 0.0f ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; @@ -155,6 +159,8 @@ static double benchmark2( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } + + free( x ); return elapsed; } From fa2995e1efa7be5446e456eb692e52203ea4e43c Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 14 Dec 2025 23:47:00 -0800 Subject: [PATCH 2/4] Apply suggestions from code review Signed-off-by: Athan --- .../blas/ext/base/cfill/benchmark/c/benchmark.length.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c index bd563aaae635..8a7b348709c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c @@ -102,7 +102,7 @@ static double benchmark1( int iterations, int len ) { double t; int i; - x = (float *) malloc( len * 2 * sizeof(float) ); + x = (float *) malloc( len * 2 * sizeof( float ) ); alpha = stdlib_complex64( 1.0f, 0.0f ); for ( i = 0; i < len*2; i += 2 ) { @@ -122,7 +122,6 @@ static double benchmark1( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } - free( x ); return elapsed; } @@ -140,7 +139,8 @@ static double benchmark2( int iterations, int len ) { double elapsed; double t; int i; - x = (float *) malloc( len * 2 * sizeof(float) ); + x = (float *) malloc( len * 2 * sizeof( float ) ); + alpha = stdlib_complex64( 1.0f, 0.0f ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; @@ -159,7 +159,6 @@ static double benchmark2( int iterations, int len ) { if ( x[ 0 ] != x[ 0 ] ) { printf( "should not return NaN\n" ); } - free( x ); return elapsed; } From 4fbcb828a6e498461c3360f2e0d82ef677779158 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 14 Dec 2025 23:47:33 -0800 Subject: [PATCH 3/4] style: add blank line Signed-off-by: Athan --- .../@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c index 8a7b348709c5..d0d748a07d19 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c @@ -139,6 +139,7 @@ static double benchmark2( int iterations, int len ) { double elapsed; double t; int i; + x = (float *) malloc( len * 2 * sizeof( float ) ); alpha = stdlib_complex64( 1.0f, 0.0f ); From e9d30b7a7727de52bb4c6ea1b9df4a589b950f80 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 14 Dec 2025 23:48:15 -0800 Subject: [PATCH 4/4] style: reorder variable declarations Signed-off-by: Athan --- .../blas/ext/base/cfill/benchmark/c/benchmark.length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c index d0d748a07d19..1475341a96fa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/cfill/benchmark/c/benchmark.length.c @@ -97,9 +97,9 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { stdlib_complex64_t alpha; - float *x; double elapsed; double t; + float *x; int i; x = (float *) malloc( len * 2 * sizeof( float ) ); @@ -135,9 +135,9 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { stdlib_complex64_t alpha; - float *x; double elapsed; double t; + float *x; int i; x = (float *) malloc( len * 2 * sizeof( float ) );