Skip to content

Commit 8b5ae6f

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/ssumors
PR-URL: #10775 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 5ed244e commit 8b5ae6f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/ssumors/benchmark/c/benchmark.length.c

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

104+
x = (float *) malloc( len * sizeof( float ) );
104105
for ( i = 0; i < len; i++ ) {
105106
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
106107
}
@@ -118,16 +119,18 @@ static double benchmark1( int iterations, int len ) {
118119
if ( v != v ) {
119120
printf( "should not return NaN\n" );
120121
}
122+
free( x );
121123
return elapsed;
122124
}
123125

124126
static double benchmark2( int iterations, int len ) {
125127
double elapsed;
126-
float x[ len ];
128+
float *x;
127129
float v;
128130
double t;
129131
int i;
130132

133+
x = (float *) malloc( len * sizeof( float ) );
131134
for ( i = 0; i < len; i++ ) {
132135
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
133136
}
@@ -145,6 +148,7 @@ static double benchmark2( int iterations, int len ) {
145148
if ( v != v ) {
146149
printf( "should not return NaN\n" );
147150
}
151+
free( x );
148152
return elapsed;
149153
}
150154

0 commit comments

Comments
 (0)