File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
lib/node_modules/@stdlib/blas/base/sdot/benchmark/c Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -96,12 +96,14 @@ static float rand_float( void ) {
9696*/
9797static double benchmark1 ( int iterations , int len ) {
9898 double elapsed ;
99- float x [ len ] ;
100- float y [ len ] ;
99+ float * x ;
100+ float * y ;
101101 float z ;
102102 double t ;
103103 int i ;
104104
105+ x = (float * ) malloc ( len * sizeof ( float ) );
106+ y = (float * ) malloc ( len * sizeof ( float ) );
105107 for ( i = 0 ; i < len ; i ++ ) {
106108 x [ i ] = ( rand_float ()* 20000.0f ) - 10000.0f ;
107109 y [ i ] = ( rand_float ()* 20000.0f ) - 10000.0f ;
@@ -120,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
120122 if ( z != z ) {
121123 printf ( "should not return NaN\n" );
122124 }
125+ free ( x );
126+ free ( y );
123127 return elapsed ;
124128}
125129
@@ -132,12 +136,14 @@ static double benchmark1( int iterations, int len ) {
132136*/
133137static double benchmark2 ( int iterations , int len ) {
134138 double elapsed ;
135- float x [ len ] ;
136- float y [ len ] ;
139+ float * x ;
140+ float * y ;
137141 float z ;
138142 double t ;
139143 int i ;
140144
145+ x = (float * ) malloc ( len * sizeof ( float ) );
146+ y = (float * ) malloc ( len * sizeof ( float ) );
141147 for ( i = 0 ; i < len ; i ++ ) {
142148 x [ i ] = ( rand_float ()* 20000.0f ) - 10000.0f ;
143149 y [ i ] = ( rand_float ()* 20000.0f ) - 10000.0f ;
@@ -156,6 +162,8 @@ static double benchmark2( int iterations, int len ) {
156162 if ( z != z ) {
157163 printf ( "should not return NaN\n" );
158164 }
165+ free ( x );
166+ free ( y );
159167 return elapsed ;
160168}
161169
You can’t perform that action at this time.
0 commit comments