Skip to content

Commit b89b3a0

Browse files
bench: refactor to use dynamic memory allocation in blas/base/sdot
--- 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 0a3bfa2 commit b89b3a0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

lib/node_modules/@stdlib/blas/base/sdot/benchmark/c/benchmark.length.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ static float rand_float( void ) {
9696
*/
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
99-
float x[ len ];
100-
float y[ len ];
99+
float *x;
100+
float *y;
101101
float z;
102102
double t;
103103
int i;
104104

105+
x = (float *) malloc( len * sizeof( float ) );
106+
y = (float *) malloc( len * sizeof( float ) );
105107
for ( i = 0; i < len; i++ ) {
106108
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
107109
y[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
@@ -120,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
120122
if ( z != z ) {
121123
printf( "should not return NaN\n" );
122124
}
125+
free( x );
126+
free( y );
123127
return elapsed;
124128
}
125129

@@ -132,12 +136,14 @@ static double benchmark1( int iterations, int len ) {
132136
*/
133137
static double benchmark2( int iterations, int len ) {
134138
double elapsed;
135-
float x[ len ];
136-
float y[ len ];
139+
float *x;
140+
float *y;
137141
float z;
138142
double t;
139143
int i;
140144

145+
x = (float *) malloc( len * sizeof( float ) );
146+
y = (float *) malloc( len * sizeof( float ) );
141147
for ( i = 0; i < len; i++ ) {
142148
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
143149
y[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
@@ -156,6 +162,8 @@ static double benchmark2( int iterations, int len ) {
156162
if ( z != z ) {
157163
printf( "should not return NaN\n" );
158164
}
165+
free( x );
166+
free( y );
159167
return elapsed;
160168
}
161169

0 commit comments

Comments
 (0)