Skip to content

Commit 1dc9764

Browse files
bench: refactor to use dynamic memory allocation in blas/base/drotm
PR-URL: #9088 Ref: #8643 Reviewed-by: Athan Reines <[email protected]>
1 parent 5e0faf8 commit 1dc9764

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
99-
double x[ len ];
100-
double y[ len ];
99+
double *x;
100+
double *y;
101101
double t;
102102
int i;
103103

104104
const double param[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
105+
x = (double *) malloc( len * sizeof( double ) );
106+
y = (double *) malloc( len * sizeof( double ) );
105107
for ( i = 0; i < len; i++ ) {
106108
x[ i ] = ( rand_double()*200.0 ) - 100.0;
107109
y[ i ] = ( rand_double()*200.0 ) - 100.0;
@@ -119,6 +121,8 @@ static double benchmark1( int iterations, int len ) {
119121
if ( y[ 0 ] != y[ 0 ] ) {
120122
printf( "should not return NaN\n" );
121123
}
124+
free( x );
125+
free( y );
122126
return elapsed;
123127
}
124128

@@ -131,12 +135,14 @@ static double benchmark1( int iterations, int len ) {
131135
*/
132136
static double benchmark2( int iterations, int len ) {
133137
double elapsed;
134-
double x[ len ];
135-
double y[ len ];
138+
double *x;
139+
double *y;
136140
double t;
137141
int i;
138142

139143
const double param[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
144+
x = (double *) malloc( len * sizeof( double ) );
145+
y = (double *) malloc( len * sizeof( double ) );
140146
for ( i = 0; i < len; i++ ) {
141147
x[ i ] = ( rand_double()*200.0 ) - 100.0;
142148
y[ i ] = ( rand_double()*200.0 ) - 100.0;
@@ -154,6 +160,8 @@ static double benchmark2( int iterations, int len ) {
154160
if ( y[ 0 ] != y[ 0 ] ) {
155161
printf( "should not return NaN\n" );
156162
}
163+
free( x );
164+
free( y );
157165
return elapsed;
158166
}
159167

0 commit comments

Comments
 (0)