Skip to content

Commit faac90b

Browse files
Faraz GhaniFaraz Ghani
authored andcommitted
bench: refactor to use dynamic memory allocation in blas/base/ddot
--- 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 c354cf2 commit faac90b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

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

105+
x = (double *) malloc( len * sizeof( double ) );
106+
y = (double *) malloc( len * sizeof( double ) );
107+
105108
for ( i = 0; i < len; i++ ) {
106109
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
107110
y[ i ] = ( rand_double()*20000.0 ) - 10000.0;
@@ -119,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
119122
if ( z != z ) {
120123
printf( "should not return NaN\n" );
121124
}
125+
free( x );
126+
free( y );
122127
return elapsed;
123128
}
124129

@@ -131,12 +136,15 @@ static double benchmark1( int iterations, int len ) {
131136
*/
132137
static double benchmark2( int iterations, int len ) {
133138
double elapsed;
134-
double x[ len ];
135-
double y[ len ];
139+
double *x;
140+
double *y;
136141
double z;
137142
double t;
138143
int i;
139144

145+
x = (double *) malloc( len * sizeof( double ) );
146+
y = (double *) malloc( len * sizeof( double ) );
147+
140148
for ( i = 0; i < len; i++ ) {
141149
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
142150
y[ i ] = ( rand_double()*20000.0 ) - 10000.0;
@@ -154,6 +162,9 @@ static double benchmark2( int iterations, int len ) {
154162
if ( z != z ) {
155163
printf( "should not return NaN\n" );
156164
}
165+
166+
free( x );
167+
free( y );
157168
return elapsed;
158169
}
159170

0 commit comments

Comments
 (0)