Skip to content

Commit c9f8db9

Browse files
authored
Merge pull request #2490 from shengyang-3390/develop
Add benchmark file rotm.c and modify benchmark/Makefile to test s/drotm
2 parents 18099de + e0df948 commit c9f8db9

2 files changed

Lines changed: 254 additions & 0 deletions

File tree

benchmark/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
6565
sger.goto dger.goto cger.goto zger.goto \
6666
sdot.goto ddot.goto \
6767
srot.goto drot.goto \
68+
srotm.goto drotm.goto \
6869
saxpy.goto daxpy.goto caxpy.goto zaxpy.goto \
6970
scopy.goto dcopy.goto ccopy.goto zcopy.goto \
7071
sswap.goto dswap.goto cswap.goto zswap.goto \
@@ -97,6 +98,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
9798
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
9899
sger.acml dger.acml cger.acml zger.acml \
99100
sdot.acml ddot.acml \
101+
srotm.acml drotm.acml \
100102
saxpy.acml daxpy.acml caxpy.acml zaxpy.acml \
101103
scopy.acml dcopy.acml ccopy.acml zcopy.acml \
102104
sswap.acml dswap.acml cswap.acml zswap.acml \
@@ -129,6 +131,7 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
129131
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
130132
sger.atlas dger.atlas cger.atlas zger.atlas\
131133
sdot.atlas ddot.atlas \
134+
srotm.atlas drotm.atlas \
132135
saxpy.atlas daxpy.atlas caxpy.atlas zaxpy.atlas \
133136
scopy.atlas dcopy.atlas ccopy.atlas zcopy.atlas \
134137
sswap.atlas dswap.atlas cswap.atlas zswap.atlas \
@@ -162,6 +165,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
162165
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
163166
sger.mkl dger.mkl cger.mkl zger.mkl \
164167
sdot.mkl ddot.mkl \
168+
srotm.mkl drotm.mkl \
165169
saxpy.mkl daxpy.mkl caxpy.mkl zaxpy.mkl \
166170
scopy.mkl dcopy.mkl ccopy.mkl zcopy.mkl \
167171
sswap.mkl dswap.mkl cswap.mkl zswap.mkl \
@@ -195,6 +199,7 @@ goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
195199
sger.goto dger.goto cger.goto zger.goto \
196200
sdot.goto ddot.goto cdot.goto zdot.goto \
197201
srot.goto drot.goto \
202+
srotm.goto drotm.goto \
198203
saxpy.goto daxpy.goto caxpy.goto zaxpy.goto \
199204
scopy.goto dcopy.goto ccopy.goto zcopy.goto \
200205
sswap.goto dswap.goto cswap.goto zswap.goto \
@@ -226,6 +231,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
226231
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
227232
sger.acml dger.acml cger.acml zger.acml \
228233
sdot.acml ddot.acml \
234+
srotm.acml drotm.acml \
229235
saxpy.acml daxpy.acml caxpy.acml zaxpy.acml \
230236
scopy.acml dcopy.acml ccopy.acml zcopy.acml \
231237
sswap.acml dswap.acml cswap.acml zswap.acml \
@@ -258,6 +264,7 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
258264
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
259265
sger.atlas dger.atlas cger.atlas zger.atlas\
260266
sdot.atlas ddot.atlas \
267+
srotm.atlas drotm.atlas \
261268
saxpy.atlas daxpy.atlas caxpy.atlas zaxpy.atlas \
262269
scopy.atlas dcopy.atlas ccopy.atlas zcopy.atlas \
263270
sswap.atlas dswap.atlas cswap.atlas zswap.atlas \
@@ -293,6 +300,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
293300
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
294301
sger.mkl dger.mkl cger.mkl zger.mkl \
295302
sdot.mkl ddot.mkl cdot.mkl zdot.mkl \
303+
srotm.atlas drotm.atlas \
296304
saxpy.mkl daxpy.mkl caxpy.mkl zaxpy.mkl \
297305
scopy.mkl dcopy.mkl ccopy.mkl zcopy.mkl \
298306
sswap.mkl dswap.mkl cswap.mkl zswap.mkl \
@@ -336,6 +344,7 @@ veclib :: slinpack.veclib dlinpack.veclib clinpack.veclib zlinpack.veclib \
336344
ssyr2k.veclib dsyr2k.veclib csyr2k.veclib zsyr2k.veclib \
337345
sger.veclib dger.veclib cger.veclib zger.veclib \
338346
sdot.veclib ddot.veclib cdot.veclib zdot.veclib \
347+
srotm.veclib drotm.veclib \
339348
saxpy.veclib daxpy.veclib caxpy.veclib zaxpy.veclib \
340349
scopy.veclib dcopy.veclib ccopy.veclib zcopy.veclib \
341350
sswap.veclib dswap.veclib cswap.veclib zswap.veclib \
@@ -1835,6 +1844,37 @@ drot.mkl : drot.$(SUFFIX)
18351844
drot.veclib : drot.$(SUFFIX)
18361845
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
18371846

1847+
##################################### srotm ####################################################
1848+
srotm.goto : srotm.$(SUFFIX) ../$(LIBNAME)
1849+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1850+
1851+
srotm.acml : srotm.$(SUFFIX)
1852+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1853+
1854+
srotm.atlas : srotm.$(SUFFIX)
1855+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1856+
1857+
srotm.mkl : srotm.$(SUFFIX)
1858+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1859+
1860+
srotm.veclib : srotm.$(SUFFIX)
1861+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1862+
1863+
##################################### drotm ####################################################
1864+
drotm.goto : drotm.$(SUFFIX) ../$(LIBNAME)
1865+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1866+
1867+
drotm.acml : drotm.$(SUFFIX)
1868+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1869+
1870+
drotm.atlas : drotm.$(SUFFIX)
1871+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1872+
1873+
drotm.mkl : drotm.$(SUFFIX)
1874+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1875+
1876+
drotm.veclib : drotm.$(SUFFIX)
1877+
$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
18381878

18391879
##################################### Saxpy ####################################################
18401880
saxpy.goto : saxpy.$(SUFFIX) ../$(LIBNAME)
@@ -2658,7 +2698,11 @@ srot.$(SUFFIX) : rot.c
26582698
drot.$(SUFFIX) : rot.c
26592699
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
26602700

2701+
srotm.$(SUFFIX) : rotm.c
2702+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
26612703

2704+
drotm.$(SUFFIX) : rotm.c
2705+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
26622706

26632707

26642708

benchmark/rotm.c

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/***************************************************************************
2+
Copyright (c) 2014, The OpenBLAS Project
3+
All rights reserved.
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in
11+
the documentation and/or other materials provided with the
12+
distribution.
13+
3. Neither the name of the OpenBLAS project nor the names of
14+
its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
25+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*****************************************************************************/
27+
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#ifdef __CYGWIN32__
31+
#include <sys/time.h>
32+
#endif
33+
#include "common.h"
34+
35+
#undef ROTM
36+
37+
#ifdef DOUBLE
38+
#define ROTM BLASFUNC(drotm)
39+
#else
40+
#define ROTM BLASFUNC(srotm)
41+
#endif
42+
43+
#if defined(__WIN32__) || defined(__WIN64__)
44+
45+
#ifndef DELTA_EPOCH_IN_MICROSECS
46+
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
47+
#endif
48+
49+
int gettimeofday(struct timeval *tv, void *tz)
50+
{
51+
52+
FILETIME ft;
53+
unsigned __int64 tmpres = 0;
54+
static int tzflag;
55+
56+
if (NULL != tv) {
57+
GetSystemTimeAsFileTime(&ft);
58+
59+
tmpres |= ft.dwHighDateTime;
60+
tmpres <<= 32;
61+
tmpres |= ft.dwLowDateTime;
62+
63+
/*converting file time to unix epoch*/
64+
tmpres /= 10; /*convert into microseconds*/
65+
tmpres -= DELTA_EPOCH_IN_MICROSECS;
66+
tv->tv_sec = (long)(tmpres / 1000000UL);
67+
tv->tv_usec = (long)(tmpres % 1000000UL);
68+
}
69+
70+
return 0;
71+
}
72+
73+
#endif
74+
75+
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
76+
77+
static void *huge_malloc(BLASLONG size)
78+
{
79+
int shmid;
80+
void *address;
81+
82+
#ifndef SHM_HUGETLB
83+
#define SHM_HUGETLB 04000
84+
#endif
85+
86+
if ((shmid =
87+
shmget(IPC_PRIVATE, (size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
88+
SHM_HUGETLB | IPC_CREAT | 0600)) < 0) {
89+
printf("Memory allocation failed(shmget).\n");
90+
exit(1);
91+
}
92+
93+
address = shmat(shmid, NULL, SHM_RND);
94+
95+
if ((BLASLONG)address == -1) {
96+
printf("Memory allocation failed(shmat).\n");
97+
exit(1);
98+
}
99+
100+
shmctl(shmid, IPC_RMID, 0);
101+
102+
return address;
103+
}
104+
105+
#define malloc huge_malloc
106+
107+
#endif
108+
109+
int main(int argc, char *argv[])
110+
{
111+
112+
FLOAT *x, *y;
113+
// FLOAT result;
114+
blasint m, i;
115+
blasint inc_x = 1, inc_y = 1;
116+
FLOAT param[5] = {1, 2.0, 3.0, 4.0, 5.0};
117+
int loops = 1;
118+
int l;
119+
char *p;
120+
121+
int from = 1;
122+
int to = 200;
123+
int step = 1;
124+
125+
struct timeval start, stop;
126+
double time1, timeg;
127+
128+
argc--;
129+
argv++;
130+
131+
if (argc > 0) {
132+
from = atol(*argv);
133+
argc--;
134+
argv++;
135+
}
136+
if (argc > 0) {
137+
to = MAX(atol(*argv), from);
138+
argc--;
139+
argv++;
140+
}
141+
if (argc > 0) {
142+
step = atol(*argv);
143+
argc--;
144+
argv++;
145+
}
146+
147+
if ((p = getenv("OPENBLAS_LOOPS")))
148+
loops = atoi(p);
149+
if ((p = getenv("OPENBLAS_INCX")))
150+
inc_x = atoi(p);
151+
if ((p = getenv("OPENBLAS_INCY")))
152+
inc_y = atoi(p);
153+
154+
fprintf(
155+
stderr,
156+
"From : %3d To : %3d Step = %3d Inc_x = %d Inc_y = %d Loops = %d\n",
157+
from, to, step, inc_x, inc_y, loops);
158+
159+
if ((x = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_x) * COMPSIZE)) ==
160+
NULL) {
161+
fprintf(stderr, "Out of Memory!!\n");
162+
exit(1);
163+
}
164+
165+
if ((y = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_y) * COMPSIZE)) ==
166+
NULL) {
167+
fprintf(stderr, "Out of Memory!!\n");
168+
exit(1);
169+
}
170+
171+
#ifdef linux
172+
srandom(getpid());
173+
#endif
174+
175+
fprintf(stderr, " SIZE Flops\n");
176+
177+
for (m = from; m <= to; m += step) {
178+
179+
timeg = 0;
180+
181+
fprintf(stderr, " %6d : ", (int)m);
182+
for (i = 0; i < m * COMPSIZE * abs(inc_x); i++) {
183+
x[i] = ((FLOAT)rand() / (FLOAT)RAND_MAX) - 0.5;
184+
}
185+
186+
for (i = 0; i < m * COMPSIZE * abs(inc_y); i++) {
187+
y[i] = ((FLOAT)rand() / (FLOAT)RAND_MAX) - 0.5;
188+
}
189+
190+
for (l = 0; l < loops; l++) {
191+
gettimeofday(&start, (struct timezone *)0);
192+
193+
ROTM(&m, x, &inc_x, y, &inc_y, param);
194+
195+
gettimeofday(&stop, (struct timezone *)0);
196+
197+
time1 = (double)(stop.tv_sec - start.tv_sec) +
198+
(double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
199+
200+
timeg += time1;
201+
}
202+
203+
timeg /= loops;
204+
205+
fprintf(stderr, " %10.2f MFlops %10.6f sec\n",
206+
COMPSIZE * COMPSIZE * 6. * (double)m / timeg * 1.e-6, timeg);
207+
}
208+
209+
return 0;
210+
}

0 commit comments

Comments
 (0)