Skip to content

Commit acf1ab1

Browse files
committed
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 ---
1 parent 53ce62b commit acf1ab1

File tree

1 file changed

+18
-6
lines changed
  • lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c

1 file changed

+18
-6
lines changed

lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/c/benchmark.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ static double tic( void ) {
8888
*/
8989
static double benchmark1( int iterations, int N ) {
9090
double elapsed;
91-
float A[ N*N ];
92-
float x[ N ];
93-
float y[ N ];
91+
float *A;
92+
float *x;
93+
float *y;
9494
double t;
9595
int i;
9696

97+
x = (float *)malloc( N * sizeof( float ) );
98+
y = (float *)malloc( N * sizeof( float ) );
99+
A = (float *)malloc( N * N * sizeof( float ) );
97100
stdlib_strided_sfill( N, 1.0f, x, 1 );
98101
stdlib_strided_sfill( N, 1.0f, y, 1 );
99102
stdlib_strided_sfill( N*N, 1.0f, A, 1 );
@@ -109,6 +112,9 @@ static double benchmark1( int iterations, int N ) {
109112
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
110113
printf( "should not return NaN\n" );
111114
}
115+
free( x );
116+
free( y );
117+
free( A );
112118
return elapsed;
113119
}
114120

@@ -121,12 +127,15 @@ static double benchmark1( int iterations, int N ) {
121127
*/
122128
static double benchmark2( int iterations, int N ) {
123129
double elapsed;
124-
float A[ N*N ];
125-
float x[ N ];
126-
float y[ N ];
130+
float *A;
131+
float *x;
132+
float *y;
127133
double t;
128134
int i;
129135

136+
x = (float *)malloc( N * sizeof( float ) );
137+
y = (float *)malloc( N * sizeof( float ) );
138+
A = (float *)malloc( N * N * sizeof( float ) );
130139
stdlib_strided_sfill( N, 1.0f, x, 1 );
131140
stdlib_strided_sfill( N, 1.0f, y, 1 );
132141
stdlib_strided_sfill( N*N, 1.0f, A, 1 );
@@ -142,6 +151,9 @@ static double benchmark2( int iterations, int N ) {
142151
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
143152
printf( "should not return NaN\n" );
144153
}
154+
free( x );
155+
free( y );
156+
free( A );
145157
return elapsed;
146158
}
147159

0 commit comments

Comments
 (0)