Skip to content

Commit 350c422

Browse files
sujalcharatikgryte
andauthored
bench: refactor to use dynamic memory allocation in blas/ext/base/cfill
PR-URL: #8970 Ref: #8643 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]>
1 parent 9ee9547 commit 350c422

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ static float rand_float( void ) {
9797
*/
9898
static double benchmark1( int iterations, int len ) {
9999
stdlib_complex64_t alpha;
100-
float x[ len*2 ];
101100
double elapsed;
102101
double t;
102+
float *x;
103103
int i;
104104

105+
x = (float *) malloc( len * 2 * sizeof( float ) );
106+
105107
alpha = stdlib_complex64( 1.0f, 0.0f );
106108
for ( i = 0; i < len*2; i += 2 ) {
107109
x[ i ] = ( rand_float()*2.0f ) - 1.0f;
@@ -120,6 +122,7 @@ static double benchmark1( int iterations, int len ) {
120122
if ( x[ 0 ] != x[ 0 ] ) {
121123
printf( "should not return NaN\n" );
122124
}
125+
free( x );
123126
return elapsed;
124127
}
125128

@@ -132,11 +135,13 @@ static double benchmark1( int iterations, int len ) {
132135
*/
133136
static double benchmark2( int iterations, int len ) {
134137
stdlib_complex64_t alpha;
135-
float x[ len*2 ];
136138
double elapsed;
137139
double t;
140+
float *x;
138141
int i;
139142

143+
x = (float *) malloc( len * 2 * sizeof( float ) );
144+
140145
alpha = stdlib_complex64( 1.0f, 0.0f );
141146
for ( i = 0; i < len*2; i += 2 ) {
142147
x[ i ] = ( rand_float()*2.0f ) - 1.0f;
@@ -155,6 +160,7 @@ static double benchmark2( int iterations, int len ) {
155160
if ( x[ 0 ] != x[ 0 ] ) {
156161
printf( "should not return NaN\n" );
157162
}
163+
free( x );
158164
return elapsed;
159165
}
160166

0 commit comments

Comments
 (0)