@@ -25,125 +25,73 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25
25
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
26
*****************************************************************************/
27
27
28
- #include <stdio.h>
29
- #include <stdlib.h>
30
- #ifdef __CYGWIN32__
31
- #include <sys/time.h>
32
- #endif
33
- #include "common.h"
34
-
28
+ #include "bench.h"
35
29
36
30
#undef AMAX
37
31
38
32
#ifdef COMPLEX
39
33
#ifdef DOUBLE
40
- #define AMAX BLASFUNC(dzamax)
34
+ #define AMAX BLASFUNC(dzamax)
41
35
#else
42
- #define AMAX BLASFUNC(scamax)
36
+ #define AMAX BLASFUNC(scamax)
43
37
#endif
44
38
#else
45
39
#ifdef DOUBLE
46
- #define AMAX BLASFUNC(damax)
40
+ #define AMAX BLASFUNC(damax)
47
41
#else
48
- #define AMAX BLASFUNC(samax)
42
+ #define AMAX BLASFUNC(samax)
49
43
#endif
50
44
#endif
51
45
52
- #if defined(__WIN32__ ) || defined(__WIN64__ )
53
-
54
- #ifndef DELTA_EPOCH_IN_MICROSECS
55
- #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
56
- #endif
57
-
58
- int gettimeofday (struct timeval * tv , void * tz ){
59
-
60
- FILETIME ft ;
61
- unsigned __int64 tmpres = 0 ;
62
- static int tzflag ;
63
-
64
- if (NULL != tv )
65
- {
66
- GetSystemTimeAsFileTime (& ft );
67
-
68
- tmpres |= ft .dwHighDateTime ;
69
- tmpres <<= 32 ;
70
- tmpres |= ft .dwLowDateTime ;
71
-
72
- /*converting file time to unix epoch*/
73
- tmpres /= 10 ; /*convert into microseconds*/
74
- tmpres -= DELTA_EPOCH_IN_MICROSECS ;
75
- tv -> tv_sec = (long )(tmpres / 1000000UL );
76
- tv -> tv_usec = (long )(tmpres % 1000000UL );
77
- }
78
-
79
- return 0 ;
80
- }
81
-
82
- #endif
83
-
84
- #if !defined(__WIN32__ ) && !defined(__WIN64__ ) && !defined(__CYGWIN32__ ) && 0
85
-
86
- static void * huge_malloc (BLASLONG size ){
87
- int shmid ;
88
- void * address ;
89
-
90
- #ifndef SHM_HUGETLB
91
- #define SHM_HUGETLB 04000
92
- #endif
93
-
94
- if ((shmid = shmget (IPC_PRIVATE ,
95
- (size + HUGE_PAGESIZE ) & ~(HUGE_PAGESIZE - 1 ),
96
- SHM_HUGETLB | IPC_CREAT |0600 )) < 0 ) {
97
- printf ( "Memory allocation failed(shmget).\n" );
98
- exit (1 );
99
- }
100
-
101
- address = shmat (shmid , NULL , SHM_RND );
102
-
103
- if ((BLASLONG )address == -1 ){
104
- printf ( "Memory allocation failed(shmat).\n" );
105
- exit (1 );
106
- }
107
-
108
- shmctl (shmid , IPC_RMID , 0 );
109
-
110
- return address ;
111
- }
112
-
113
- #define malloc huge_malloc
114
-
115
- #endif
116
-
117
- int main (int argc , char * argv []){
46
+ int main (int argc , char * argv [])
47
+ {
118
48
119
49
FLOAT * x ;
120
50
blasint m , i ;
121
- blasint inc_x = 1 ;
51
+ blasint inc_x = 1 ;
122
52
int loops = 1 ;
123
53
int l ;
124
54
char * p ;
125
55
56
+ int from = 1 ;
57
+ int to = 200 ;
58
+ int step = 1 ;
126
59
127
- int from = 1 ;
128
- int to = 200 ;
129
- int step = 1 ;
130
-
131
- struct timeval start , stop ;
132
- double time1 ,timeg ;
60
+ double time1 , timeg ;
133
61
134
- argc -- ;argv ++ ;
62
+ argc -- ;
63
+ argv ++ ;
135
64
136
- if (argc > 0 ) { from = atol (* argv ); argc -- ; argv ++ ;}
137
- if (argc > 0 ) { to = MAX (atol (* argv ), from ); argc -- ; argv ++ ;}
138
- if (argc > 0 ) { step = atol (* argv ); argc -- ; argv ++ ;}
65
+ if (argc > 0 )
66
+ {
67
+ from = atol (* argv );
68
+ argc -- ;
69
+ argv ++ ;
70
+ }
71
+ if (argc > 0 )
72
+ {
73
+ to = MAX (atol (* argv ), from );
74
+ argc -- ;
75
+ argv ++ ;
76
+ }
77
+ if (argc > 0 )
78
+ {
79
+ step = atol (* argv );
80
+ argc -- ;
81
+ argv ++ ;
82
+ }
139
83
140
- if ((p = getenv ("OPENBLAS_LOOPS" ))) loops = atoi (p );
141
- if ((p = getenv ("OPENBLAS_INCX" ))) inc_x = atoi (p );
84
+ if ((p = getenv ("OPENBLAS_LOOPS" )))
85
+ loops = atoi (p );
86
+ if ((p = getenv ("OPENBLAS_INCX" )))
87
+ inc_x = atoi (p );
142
88
143
- fprintf (stderr , "From : %3d To : %3d Step = %3d Inc_x = %d Loops = %d\n" , from , to , step ,inc_x ,loops );
89
+ fprintf (stderr , "From : %3d To : %3d Step = %3d Inc_x = %d Loops = %d\n" , from , to , step , inc_x , loops );
144
90
145
- if (( x = (FLOAT * )malloc (sizeof (FLOAT ) * to * abs (inc_x ) * COMPSIZE )) == NULL ){
146
- fprintf (stderr ,"Out of Memory!!\n" );exit (1 );
91
+ if ((x = (FLOAT * )malloc (sizeof (FLOAT ) * to * abs (inc_x ) * COMPSIZE )) == NULL )
92
+ {
93
+ fprintf (stderr , "Out of Memory!!\n" );
94
+ exit (1 );
147
95
}
148
96
149
97
#ifdef __linux
@@ -152,37 +100,31 @@ int main(int argc, char *argv[]){
152
100
153
101
fprintf (stderr , " SIZE Flops\n" );
154
102
155
- for (m = from ; m <= to ; m += step )
103
+ for (m = from ; m <= to ; m += step )
156
104
{
157
105
158
- timeg = 0 ;
159
-
160
- fprintf (stderr , " %6d : " , (int )m );
106
+ timeg = 0 ;
107
+ fprintf (stderr , " %6d : " , (int )m );
161
108
109
+ for (l = 0 ; l < loops ; l ++ )
110
+ {
162
111
163
- for (l = 0 ; l < loops ; l ++ )
164
- {
165
-
166
- for (i = 0 ; i < m * COMPSIZE * abs (inc_x ); i ++ ){
167
- x [i ] = ((FLOAT ) rand () / (FLOAT ) RAND_MAX ) - 0.5 ;
168
- }
169
-
170
- gettimeofday ( & start , (struct timezone * )0 );
171
- AMAX (& m , x , & inc_x );
172
- gettimeofday ( & stop , (struct timezone * )0 );
173
-
174
- time1 = (double )(stop .tv_sec - start .tv_sec ) + (double )((stop .tv_usec - start .tv_usec )) * 1.e-6 ;
175
-
176
- timeg += time1 ;
112
+ for (i = 0 ; i < m * COMPSIZE * abs (inc_x ); i ++ )
113
+ {
114
+ x [i ] = ((FLOAT )rand () / (FLOAT )RAND_MAX ) - 0.5 ;
115
+ }
177
116
117
+ begin ();
118
+ AMAX (& m , x , & inc_x );
119
+ end ();
120
+ timeg += getsec ();
178
121
}
179
122
180
123
timeg /= loops ;
181
124
182
125
fprintf (stderr ,
183
- " %10.2f MFlops %10.6f sec\n" ,
184
- COMPSIZE * sizeof (FLOAT ) * 1. * (double )m / timeg * 1.e-6 , timeg );
185
-
126
+ " %10.2f MFlops %10.6f sec\n" ,
127
+ COMPSIZE * sizeof (FLOAT ) * 1. * (double )m / timeg * 1.e-6 , timeg );
186
128
}
187
129
188
130
return 0 ;
0 commit comments