@@ -82,9 +82,9 @@ static double tic( void ) {
8282*
8383* @return random number
8484*/
85- static double rand_double ( void ) {
85+ static double rand_float ( void ) {
8686 int r = rand ();
87- return (double )r / ( (double )RAND_MAX + 1.0 );
87+ return (float )r / ( (float )RAND_MAX + 1.0f );
8888}
8989
9090/**
@@ -96,20 +96,20 @@ static double rand_double( void ) {
9696*/
9797static double benchmark1 ( int iterations , int len ) {
9898 double elapsed ;
99- double * x ;
100- double * y ;
10199 double t ;
100+ float * x ;
101+ float * y ;
102102 int i ;
103103
104- x = ( double * )malloc ( len * sizeof (double ) );
105- y = ( double * )malloc ( len * sizeof (double ) );
104+ x = ( float * )malloc ( len * sizeof (float ) );
105+ y = ( float * )malloc ( len * sizeof (float ) );
106106 for ( i = 0 ; i < len ; i ++ ) {
107- x [ i ] = ( rand_double ()* 20.0 ) - 10.0 ;
108- y [ i ] = ( rand_double ()* 20.0 ) - 10.0 ;
107+ x [ i ] = ( rand_float ()* 20.0f ) - 10.0f ;
108+ y [ i ] = ( rand_float ()* 20.0f ) - 10.0f ;
109109 }
110110 t = tic ();
111111 for ( i = 0 ; i < iterations ; i ++ ) {
112- stdlib_strided_ssort2hp ( len , 1.0 , x , 1 , y , 1 );
112+ stdlib_strided_ssort2hp ( len , 1.0f , x , 1 , y , 1 );
113113 if ( y [ 0 ] != y [ 0 ] ) {
114114 printf ( "should not return NaN\n" );
115115 break ;
@@ -133,20 +133,20 @@ static double benchmark1( int iterations, int len ) {
133133*/
134134static double benchmark2 ( int iterations , int len ) {
135135 double elapsed ;
136- double * x ;
137- double * y ;
138136 double t ;
137+ float * x ;
138+ float * y ;
139139 int i ;
140140
141- x = (double * )malloc ( len * sizeof (double ) );
142- y = (double * )malloc ( len * sizeof (double ) );
141+ x = (float * )malloc ( len * sizeof (float ) );
142+ y = (float * )malloc ( len * sizeof (float ) );
143143 for ( i = 0 ; i < len ; i ++ ) {
144- x [ i ] = ( rand_double ()* 20.0 ) - 10.0 ;
145- y [ i ] = ( rand_double ()* 20.0 ) - 10.0 ;
144+ x [ i ] = ( rand_float ()* 20.0f ) - 10.0f ;
145+ y [ i ] = ( rand_float ()* 20.0f ) - 10.0f ;
146146 }
147147 t = tic ();
148148 for ( i = 0 ; i < iterations ; i ++ ) {
149- stdlib_strided_ssort2hp_ndarray ( len , 1.0 , x , 1 , 0 , y , 1 , 0 );
149+ stdlib_strided_ssort2hp_ndarray ( len , 1.0f , x , 1 , 0 , y , 1 , 0 );
150150 if ( y [ 0 ] != y [ 0 ] ) {
151151 printf ( "should not return NaN\n" );
152152 break ;
0 commit comments