From 68d09ddb8960ada45397433b6c3c5562d1326606 Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Thu, 18 Dec 2025 15:58:59 +0530 Subject: [PATCH] bench: refactor to use dynamic memory allocation in blas/base/dsyr2 --- 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/dsyr2/benchmark/c/benchmark.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index 7605a9f065f7..9460d16af8db 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -88,12 +88,15 @@ static double tic( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; + x = (double *)malloc( N * sizeof( double ) ); + y = (double *)malloc( N * sizeof( double ) ); + A = (double *)malloc( N * N * sizeof( double ) ); stdlib_strided_dfill( N, 1.0, x, 1 ); stdlib_strided_dfill( N, 1.0, y, 1 ); stdlib_strided_dfill( N*N, 1.0, 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; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double *A; + double *x; + double *y; double t; int i; + x = (double *)malloc( N * sizeof( double ) ); + y = (double *)malloc( N * sizeof( double ) ); + A = (double *)malloc( N * N * sizeof( double ) ); stdlib_strided_dfill( N, 1.0, x, 1 ); stdlib_strided_dfill( N, 1.0, y, 1 ); stdlib_strided_dfill( N*N, 1.0, 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; }