Skip to content

Commit 6f01a24

Browse files
Omar-2718kgryte
andauthored
bench: refactor to use dynamic memory allocation in blas/ext/base/ssumkbn
PR-URL: #8762 Ref: #8643 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 6ec2cb3 commit 6f01a24

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/node_modules/@stdlib/blas/ext/base/ssumkbn/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,6 +119,7 @@ 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

@@ -130,11 +132,12 @@ static double benchmark1( int iterations, int len ) {
130132
*/
131133
static double benchmark2( int iterations, int len ) {
132134
double elapsed;
133-
float x[ len ];
135+
float *x;
134136
float v;
135137
double t;
136138
int i;
137139

140+
x = (float *) malloc( len * sizeof( float ) );
138141
for ( i = 0; i < len; i++ ) {
139142
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
140143
}
@@ -152,6 +155,7 @@ static double benchmark2( int iterations, int len ) {
152155
if ( v != v ) {
153156
printf( "should not return NaN\n" );
154157
}
158+
free( x );
155159
return elapsed;
156160
}
157161

0 commit comments

Comments
 (0)