Skip to content

Commit 9a18a03

Browse files
bench: refactor to use dynamic memory allocation in blas/base/sspr
PR-URL: #10332 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 338737a commit 9a18a03

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/node_modules/@stdlib/blas/base/sspr/benchmark/c/benchmark.length.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ static double tic( void ) {
8888
*/
8989
static double benchmark1( int iterations, int len ) {
9090
double elapsed;
91-
float AP[ len*(len+1)/2 ];
92-
float x[ len ];
91+
float *AP;
92+
float *x;
9393
double t;
9494
int i;
9595

96+
AP = (float *) malloc( ( len*(len+1)/2 ) * sizeof( float ) );
97+
x = (float *) malloc( len * sizeof( float ) );
9698
stdlib_strided_sfill( len, 0.5f, x, 1 );
9799
stdlib_strided_sfill( len*(len+1)/2, 1.0f, AP, 1 );
98100
t = tic();
@@ -107,6 +109,8 @@ static double benchmark1( int iterations, int len ) {
107109
if ( AP[ 0 ] != AP[ 0 ] ) {
108110
printf( "should not return NaN\n" );
109111
}
112+
free( AP );
113+
free( x );
110114
return elapsed;
111115
}
112116

@@ -119,11 +123,13 @@ static double benchmark1( int iterations, int len ) {
119123
*/
120124
static double benchmark2( int iterations, int len ) {
121125
double elapsed;
122-
float AP[ len*(len+1)/2 ];
123-
float x[ len ];
126+
float *AP;
127+
float *x;
124128
double t;
125129
int i;
126130

131+
AP = (float *) malloc( ( len*(len+1)/2 ) * sizeof( float ) );
132+
x = (float *) malloc( len * sizeof( float ) );
127133
stdlib_strided_sfill( len, 0.5f, x, 1 );
128134
stdlib_strided_sfill( len*(len+1)/2, 1.0f, AP, 1 );
129135
t = tic();
@@ -138,6 +144,8 @@ static double benchmark2( int iterations, int len ) {
138144
if ( AP[ 0 ] != AP[ 0 ] ) {
139145
printf( "should not return NaN\n" );
140146
}
147+
free( AP );
148+
free( x );
141149
return elapsed;
142150
}
143151

0 commit comments

Comments
 (0)