From acf1ab1aa4c377e503cab7288b92d94c8c6e0c4b Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Thu, 18 Dec 2025 19:41:28 +0530 Subject: [PATCH] bench(blas/base/ssyr2): refactor to use dynamic memory allocation --- 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 --- --- .../blas/base/ssyr2/benchmark/c/benchmark.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c/benchmark.c index 42301bba4da3..8010deb33e89 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c/benchmark.c @@ -88,12 +88,15 @@ static double tic( 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; + x = (float *)malloc( N * sizeof( float ) ); + y = (float *)malloc( N * sizeof( float ) ); + A = (float *)malloc( N * N * sizeof( float ) ); stdlib_strided_sfill( N, 1.0f, x, 1 ); stdlib_strided_sfill( N, 1.0f, y, 1 ); stdlib_strided_sfill( N*N, 1.0f, A, 1 ); @@ -109,6 +112,9 @@ static double benchmark1( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); + free( A ); return elapsed; } @@ -121,12 +127,15 @@ 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; + x = (float *)malloc( N * sizeof( float ) ); + y = (float *)malloc( N * sizeof( float ) ); + A = (float *)malloc( N * N * sizeof( float ) ); stdlib_strided_sfill( N, 1.0f, x, 1 ); stdlib_strided_sfill( N, 1.0f, y, 1 ); stdlib_strided_sfill( N*N, 1.0f, A, 1 ); @@ -142,6 +151,9 @@ static double benchmark2( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); + free( A ); return elapsed; }