Skip to content

Commit 602b75a

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/dsnannsumors
PR-URL: #10746 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent c3882ed commit 602b75a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ 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
CBLAS_INT n;
101101
double v;
102102
double t;
103103
int i;
104104

105+
x = (float *) malloc( len * sizeof( float ) );
105106
for ( i = 0; i < len; i++ ) {
106107
if ( rand_float() < 0.2f ) {
107108
x[ i ] = 0.0f / 0.0f; // NaN
@@ -124,6 +125,7 @@ static double benchmark1( int iterations, int len ) {
124125
if ( v != v || n < 0 ) {
125126
printf( "should not return NaN\n" );
126127
}
128+
free( x );
127129
return elapsed;
128130
}
129131

@@ -136,12 +138,13 @@ static double benchmark1( int iterations, int len ) {
136138
*/
137139
static double benchmark2( int iterations, int len ) {
138140
double elapsed;
139-
float x[ len ];
141+
float *x;
140142
CBLAS_INT n;
141143
double v;
142144
double t;
143145
int i;
144146

147+
x = (float *) malloc( len * sizeof( float ) );
145148
for ( i = 0; i < len; i++ ) {
146149
if ( rand_float() < 0.2f ) {
147150
x[ i ] = 0.0f / 0.0f; // NaN
@@ -164,6 +167,7 @@ static double benchmark2( int iterations, int len ) {
164167
if ( v != v || n < 0 ) {
165168
printf( "should not return NaN\n" );
166169
}
170+
free( x );
167171
return elapsed;
168172
}
169173

0 commit comments

Comments
 (0)