Skip to content

Commit e359094

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/dnannsumkbn
PR-URL: #10652 Ref: #8643 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent d4d6328 commit e359094

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ static double rand_double( void ) {
9797
*/
9898
static double benchmark1( int iterations, int len ) {
9999
double elapsed;
100-
double x[ len ];
100+
double *x;
101101
CBLAS_INT n;
102102
double v;
103103
double t;
104104
int i;
105105

106+
x = (double *) malloc( len * sizeof( double ) );
106107
for ( i = 0; i < len; i++ ) {
107108
if ( rand_double() < 0.2 ) {
108109
x[ i ] = 0.0 / 0.0; // NaN
@@ -125,6 +126,7 @@ static double benchmark1( int iterations, int len ) {
125126
if ( v != v || n < 0 ) {
126127
printf( "should not return NaN\n" );
127128
}
129+
free( x );
128130
return elapsed;
129131
}
130132

@@ -137,12 +139,13 @@ static double benchmark1( int iterations, int len ) {
137139
*/
138140
static double benchmark2( int iterations, int len ) {
139141
double elapsed;
140-
double x[ len ];
142+
double *x;
141143
CBLAS_INT n;
142144
double v;
143145
double t;
144146
int i;
145147

148+
x = (double *) malloc( len * sizeof( double ) );
146149
for ( i = 0; i < len; i++ ) {
147150
if ( rand_double() < 0.2 ) {
148151
x[ i ] = 0.0 / 0.0; // NaN
@@ -165,6 +168,7 @@ static double benchmark2( int iterations, int len ) {
165168
if ( v != v || n < 0 ) {
166169
printf( "should not return NaN\n" );
167170
}
171+
free( x );
168172
return elapsed;
169173
}
170174

0 commit comments

Comments
 (0)