Skip to content

Commit f917c26

Browse files
committed
Refractoring remaining benchmark cases.
1 parent dd6ebdf commit f917c26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+184
-3114
lines changed

benchmark/amin.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ int main(int argc, char *argv[])
5757
int to = 200;
5858
int step = 1;
5959

60-
struct timeval start, stop;
6160
double time1, timeg;
6261

6362
argc--;

benchmark/bench.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static void *huge_malloc(BLASLONG size){
6767
return address;
6868
}
6969

70+
7071
#define malloc huge_malloc
7172

7273
#endif

benchmark/dot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ int main(int argc, char *argv[]){
4949
int to = 200;
5050
int step = 1;
5151

52-
struct timeval start, stop;
5352
double time1,timeg;
5453

5554
argc--;argv++;

benchmark/gemm3m.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ int main(int argc, char *argv[]){
6262
int to = 200;
6363
int step = 1;
6464

65-
struct timeval start, stop;
6665
double time1,timeg;
6766

6867
argc--;argv++;

benchmark/gemv.c

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2525
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
*****************************************************************************/
2727

28-
#include <stdio.h>
29-
#include <stdlib.h>
30-
#ifdef __CYGWIN32__
31-
#include <sys/time.h>
32-
#endif
33-
#include "common.h"
28+
#include "bench.h"
3429

3530

3631
#undef GEMV
@@ -52,72 +47,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5247
#endif
5348

5449
#endif
55-
56-
#if defined(__WIN32__) || defined(__WIN64__)
57-
58-
#ifndef DELTA_EPOCH_IN_MICROSECS
59-
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
60-
#endif
61-
62-
int gettimeofday(struct timeval *tv, void *tz){
63-
64-
FILETIME ft;
65-
unsigned __int64 tmpres = 0;
66-
static int tzflag;
67-
68-
if (NULL != tv)
69-
{
70-
GetSystemTimeAsFileTime(&ft);
71-
72-
tmpres |= ft.dwHighDateTime;
73-
tmpres <<= 32;
74-
tmpres |= ft.dwLowDateTime;
75-
76-
/*converting file time to unix epoch*/
77-
tmpres /= 10; /*convert into microseconds*/
78-
tmpres -= DELTA_EPOCH_IN_MICROSECS;
79-
tv->tv_sec = (long)(tmpres / 1000000UL);
80-
tv->tv_usec = (long)(tmpres % 1000000UL);
81-
}
82-
83-
return 0;
84-
}
85-
86-
#endif
87-
88-
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
89-
90-
static void *huge_malloc(BLASLONG size){
91-
int shmid;
92-
void *address;
93-
94-
#ifndef SHM_HUGETLB
95-
#define SHM_HUGETLB 04000
96-
#endif
97-
98-
if ((shmid =shmget(IPC_PRIVATE,
99-
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
100-
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
101-
printf( "Memory allocation failed(shmget).\n");
102-
exit(1);
103-
}
104-
105-
address = shmat(shmid, NULL, SHM_RND);
106-
107-
if ((BLASLONG)address == -1){
108-
printf( "Memory allocation failed(shmat).\n");
109-
exit(1);
110-
}
111-
112-
shmctl(shmid, IPC_RMID, 0);
113-
114-
return address;
115-
}
116-
117-
#define malloc huge_malloc
118-
119-
#endif
120-
12150
int main(int argc, char *argv[]){
12251

12352
FLOAT *a, *x, *y;
@@ -137,7 +66,6 @@ int main(int argc, char *argv[]){
13766
int to = 200;
13867
int step = 1;
13968

140-
struct timeval start, stop;
14169
double time1,timeg;
14270

14371
argc--;argv++;
@@ -211,10 +139,10 @@ int main(int argc, char *argv[]){
211139
for(i = 0; i < m * COMPSIZE * abs(inc_y); i++){
212140
y[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
213141
}
214-
gettimeofday( &start, (struct timezone *)0);
142+
begin();
215143
GEMV (&trans, &m, &n, alpha, a, &m, x, &inc_x, beta, y, &inc_y );
216-
gettimeofday( &stop, (struct timezone *)0);
217-
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
144+
end();
145+
time1 = getsec();
218146
timeg += time1;
219147

220148
}
@@ -248,10 +176,10 @@ int main(int argc, char *argv[]){
248176
for(i = 0; i < m * COMPSIZE * abs(inc_y); i++){
249177
y[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
250178
}
251-
gettimeofday( &start, (struct timezone *)0);
179+
begin();
252180
GEMV (&trans, &m, &n, alpha, a, &m, x, &inc_x, beta, y, &inc_y );
253-
gettimeofday( &stop, (struct timezone *)0);
254-
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
181+
end();
182+
time1 = getsec();
255183
timeg += time1;
256184

257185
}

benchmark/ger.c

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2525
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
*****************************************************************************/
2727

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"
3529

3630
#undef GER
3731

@@ -49,72 +43,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4943
#endif
5044
#endif
5145

52-
53-
#if defined(__WIN32__) || defined(__WIN64__)
54-
55-
#ifndef DELTA_EPOCH_IN_MICROSECS
56-
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
57-
#endif
58-
59-
int gettimeofday(struct timeval *tv, void *tz){
60-
61-
FILETIME ft;
62-
unsigned __int64 tmpres = 0;
63-
static int tzflag;
64-
65-
if (NULL != tv)
66-
{
67-
GetSystemTimeAsFileTime(&ft);
68-
69-
tmpres |= ft.dwHighDateTime;
70-
tmpres <<= 32;
71-
tmpres |= ft.dwLowDateTime;
72-
73-
/*converting file time to unix epoch*/
74-
tmpres /= 10; /*convert into microseconds*/
75-
tmpres -= DELTA_EPOCH_IN_MICROSECS;
76-
tv->tv_sec = (long)(tmpres / 1000000UL);
77-
tv->tv_usec = (long)(tmpres % 1000000UL);
78-
}
79-
80-
return 0;
81-
}
82-
83-
#endif
84-
85-
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
86-
87-
static void *huge_malloc(BLASLONG size){
88-
int shmid;
89-
void *address;
90-
91-
#ifndef SHM_HUGETLB
92-
#define SHM_HUGETLB 04000
93-
#endif
94-
95-
if ((shmid =shmget(IPC_PRIVATE,
96-
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
97-
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
98-
printf( "Memory allocation failed(shmget).\n");
99-
exit(1);
100-
}
101-
102-
address = shmat(shmid, NULL, SHM_RND);
103-
104-
if ((BLASLONG)address == -1){
105-
printf( "Memory allocation failed(shmat).\n");
106-
exit(1);
107-
}
108-
109-
shmctl(shmid, IPC_RMID, 0);
110-
111-
return address;
112-
}
113-
114-
#define malloc huge_malloc
115-
116-
#endif
117-
11846
int main(int argc, char *argv[]){
11947

12048
FLOAT *a, *x, *y;
@@ -131,7 +59,6 @@ int main(int argc, char *argv[]){
13159
int to = 200;
13260
int step = 1;
13361

134-
struct timeval start, stop;
13562
double time1,timeg;
13663

13764
argc--;argv++;
@@ -198,16 +125,13 @@ int main(int argc, char *argv[]){
198125
for (l=0; l<loops; l++)
199126
{
200127

201-
gettimeofday( &start, (struct timezone *)0);
128+
begin();
202129

203130
GER (&m, &n, alpha, x, &inc_x, y, &inc_y, a , &m);
204131

205-
gettimeofday( &stop, (struct timezone *)0);
206-
207-
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
208-
209-
timeg += time1;
210-
132+
end();
133+
134+
timeg += getsec();
211135
}
212136

213137
timeg /= loops;

benchmark/gesv.c

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@
3636
/* or implied, of The University of Texas at Austin. */
3737
/*********************************************************************/
3838

39-
#include <stdio.h>
40-
#include <stdlib.h>
41-
#ifdef __CYGWIN32__
42-
#include <sys/time.h>
43-
#endif
44-
#include "common.h"
39+
#include "bench.h"
4540

4641
double fabs(double);
4742

@@ -66,71 +61,6 @@ double fabs(double);
6661
#endif
6762
#endif
6863

69-
#if defined(__WIN32__) || defined(__WIN64__)
70-
71-
#ifndef DELTA_EPOCH_IN_MICROSECS
72-
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
73-
#endif
74-
75-
int gettimeofday(struct timeval *tv, void *tz){
76-
77-
FILETIME ft;
78-
unsigned __int64 tmpres = 0;
79-
static int tzflag;
80-
81-
if (NULL != tv)
82-
{
83-
GetSystemTimeAsFileTime(&ft);
84-
85-
tmpres |= ft.dwHighDateTime;
86-
tmpres <<= 32;
87-
tmpres |= ft.dwLowDateTime;
88-
89-
/*converting file time to unix epoch*/
90-
tmpres /= 10; /*convert into microseconds*/
91-
tmpres -= DELTA_EPOCH_IN_MICROSECS;
92-
tv->tv_sec = (long)(tmpres / 1000000UL);
93-
tv->tv_usec = (long)(tmpres % 1000000UL);
94-
}
95-
96-
return 0;
97-
}
98-
99-
#endif
100-
101-
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
102-
103-
static void *huge_malloc(BLASLONG size){
104-
int shmid;
105-
void *address;
106-
107-
#ifndef SHM_HUGETLB
108-
#define SHM_HUGETLB 04000
109-
#endif
110-
111-
if ((shmid =shmget(IPC_PRIVATE,
112-
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
113-
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
114-
printf( "Memory allocation failed(shmget).\n");
115-
exit(1);
116-
}
117-
118-
address = shmat(shmid, NULL, SHM_RND);
119-
120-
if ((BLASLONG)address == -1){
121-
printf( "Memory allocation failed(shmat).\n");
122-
exit(1);
123-
}
124-
125-
shmctl(shmid, IPC_RMID, 0);
126-
127-
return address;
128-
}
129-
130-
#define malloc huge_malloc
131-
132-
#endif
133-
13464
int main(int argc, char *argv[]){
13565

13666
FLOAT *a, *b;
@@ -142,7 +72,6 @@ int main(int argc, char *argv[]){
14272
int to = 200;
14373
int step = 1;
14474

145-
struct timeval start, stop;
14675
double time1;
14776

14877
argc--;argv++;
@@ -194,22 +123,18 @@ int main(int argc, char *argv[]){
194123
}
195124
}
196125

197-
gettimeofday( &start, (struct timezone *)0);
126+
begin();
198127

199128
GESV (&m, &m, a, &m, ipiv, b, &m, &info);
200129

201-
gettimeofday( &stop, (struct timezone *)0);
202-
203-
204-
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
205-
130+
end();
206131

132+
time1 = getsec();
207133

208134
fprintf(stderr,
209135
"%10.2f MFlops %10.6f s\n",
210136
COMPSIZE * COMPSIZE * (2. / 3. * (double)m * (double)m * (double)m + 2. * (double)m * (double)m * (double)m ) / (time1) * 1.e-6 , time1);
211137

212-
213138
}
214139

215140
return 0;

0 commit comments

Comments
 (0)