Skip to content

Commit 114dbec

Browse files
committed
1.Add syr2 benchmark
2.Fixed some errors
1 parent 0f65c05 commit 114dbec

3 files changed

Lines changed: 241 additions & 4 deletions

File tree

benchmark/Makefile

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
5757
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
5858
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
5959
ssyr.goto dsyr.goto \
60+
ssyr2.goto dsyr2.goto \
6061
ssyrk.goto dsyrk.goto csyrk.goto zsyrk.goto \
6162
ssyr2k.goto dsyr2k.goto csyr2k.goto zsyr2k.goto \
6263
sger.goto dger.goto cger.goto zger.goto \
@@ -85,6 +86,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
8586
strmm.acml dtrmm.acml ctrmm.acml ztrmm.acml \
8687
strsm.acml dtrsm.acml ctrsm.acml ztrsm.acml \
8788
ssyr.acml dsyr.acml \
89+
ssyr2.acml dsyr2.acml \
8890
ssyrk.acml dsyrk.acml csyrk.acml zsyrk.acml \
8991
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
9092
sger.acml dger.acml cger.acml zger.acml \
@@ -111,7 +113,8 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
111113
sgemm.atlas dgemm.atlas cgemm.atlas zgemm.atlas \
112114
strmm.atlas dtrmm.atlas ctrmm.atlas ztrmm.atlas \
113115
strsm.atlas dtrsm.atlas ctrsm.atlas ztrsm.atlas \
114-
ssyr.goto dsyr.atlas \
116+
ssyr.atlas dsyr.atlas \
117+
ssyr2.atlas dsyr2.atlas \
115118
ssyrk.atlas dsyrk.atlas csyrk.atlas zsyrk.atlas \
116119
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
117120
sger.atlas dger.atlas cger.atlas zger.atlas\
@@ -140,6 +143,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
140143
strmm.mkl dtrmm.mkl ctrmm.mkl ztrmm.mkl \
141144
strsm.mkl dtrsm.mkl ctrsm.mkl ztrsm.mkl \
142145
ssyr.mkl dsyr.mkl \
146+
ssyr2.mkl dsyr2.mkl \
143147
ssyrk.mkl dsyrk.mkl csyrk.mkl zsyrk.mkl \
144148
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
145149
sger.mkl dger.mkl cger.mkl zger.mkl \
@@ -167,6 +171,7 @@ goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
167171
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
168172
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
169173
ssyr.goto dsyr.goto \
174+
ssyr2.goto dsyr2.goto \
170175
ssyrk.goto dsyrk.goto csyrk.goto zsyrk.goto \
171176
ssyr2k.goto dsyr2k.goto csyr2k.goto zsyr2k.goto \
172177
sger.goto dger.goto cger.goto zger.goto \
@@ -194,6 +199,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
194199
strmm.acml dtrmm.acml ctrmm.acml ztrmm.acml \
195200
strsm.acml dtrsm.acml ctrsm.acml ztrsm.acml \
196201
ssyr.acml dsyr.acml \
202+
ssyr2.acml dsyr2.acml \
197203
ssyrk.acml dsyrk.acml csyrk.acml zsyrk.acml \
198204
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
199205
sger.acml dger.acml cger.acml zger.acml \
@@ -221,6 +227,7 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
221227
strmm.atlas dtrmm.atlas ctrmm.atlas ztrmm.atlas \
222228
strsm.atlas dtrsm.atlas ctrsm.atlas ztrsm.atlas \
223229
ssyr.atlas dsyr.atlas \
230+
ssyr2.atlas dsyr2.atlas \
224231
ssyrk.atlas dsyrk.atlas csyrk.atlas zsyrk.atlas \
225232
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
226233
sger.atlas dger.atlas cger.atlas zger.atlas\
@@ -251,6 +258,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
251258
strmm.mkl dtrmm.mkl ctrmm.mkl ztrmm.mkl \
252259
strsm.mkl dtrsm.mkl ctrsm.mkl ztrsm.mkl \
253260
ssyr.mkl dsyr.mkl \
261+
ssyr2.mkl dsyr2.mkl \
254262
ssyrk.mkl dsyrk.mkl csyrk.mkl zsyrk.mkl \
255263
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
256264
sger.mkl dger.mkl cger.mkl zger.mkl \
@@ -289,6 +297,7 @@ veclib :: slinpack.veclib dlinpack.veclib clinpack.veclib zlinpack.veclib \
289297
strmm.veclib dtrmm.veclib ctrmm.veclib ztrmm.veclib \
290298
strsm.veclib dtrsm.veclib ctrsm.veclib ztrsm.veclib \
291299
ssyr.veclib dsyr.veclib \
300+
ssyr2.veclib dsyr2.veclib \
292301
ssyrk.veclib dsyrk.veclib csyrk.veclib zsyrk.veclib \
293302
ssyr2k.veclib dsyr2k.veclib csyr2k.veclib zsyr2k.veclib \
294303
sger.veclib dger.veclib cger.veclib zger.veclib \
@@ -807,6 +816,36 @@ dsyr.mkl : dsyr.$(SUFFIX)
807816

808817
dsyr.veclib : dsyr.$(SUFFIX)
809818
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
819+
##################################### Ssyr2 ####################################################
820+
ssyr2.goto : ssyr2.$(SUFFIX) ../$(LIBNAME)
821+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
822+
823+
ssyr2.acml : ssyr2.$(SUFFIX)
824+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
825+
826+
ssyr2.atlas : ssyr2.$(SUFFIX)
827+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
828+
829+
ssyr2.mkl : ssyr2.$(SUFFIX)
830+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
831+
832+
ssyr2.veclib : ssyr2.$(SUFFIX)
833+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
834+
##################################### Dsyr2 ####################################################
835+
dsyr2.goto : dsyr2.$(SUFFIX) ../$(LIBNAME)
836+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
837+
838+
dsyr2.acml : dsyr2.$(SUFFIX)
839+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
840+
841+
dsyr2.atlas : dsyr2.$(SUFFIX)
842+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
843+
844+
dsyr2.mkl : dsyr2.$(SUFFIX)
845+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
846+
847+
dsyr2.veclib : dsyr2.$(SUFFIX)
848+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
810849

811850
##################################### Ssyrk ####################################################
812851
ssyrk.goto : ssyrk.$(SUFFIX) ../$(LIBNAME)
@@ -2123,6 +2162,12 @@ ssyr.$(SUFFIX) : syr.c
21232162
dsyr.$(SUFFIX) : syr.c
21242163
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
21252164

2165+
ssyr2.$(SUFFIX) : syr2.c
2166+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
2167+
2168+
dsyr2.$(SUFFIX) : syr2.c
2169+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
2170+
21262171
ssyrk.$(SUFFIX) : syrk.c
21272172
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
21282173

benchmark/syr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,9 @@ int main(int argc, char *argv[]){
173173

174174
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
175175

176-
gettimeofday( &start, (struct timezone *)0);
177-
178176
fprintf(stderr,
179177
" %10.2f MFlops\n",
180-
COMPSIZE * COMPSIZE * 1. * (double)m * (double)m * (double)m / time1 * 1.e-6);
178+
COMPSIZE * COMPSIZE * 1. * (double)m * (double)m / time1 * 1.e-6);
181179

182180
}
183181

benchmark/syr2.c

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
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 CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25+
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+
36+
#undef SYR2
37+
38+
39+
#ifdef DOUBLE
40+
#define SYR2 BLASFUNC(dsyr2)
41+
#else
42+
#define SYR2 BLASFUNC(ssyr2)
43+
#endif
44+
45+
46+
#if defined(__WIN32__) || defined(__WIN64__)
47+
48+
#ifndef DELTA_EPOCH_IN_MICROSECS
49+
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
50+
#endif
51+
52+
int gettimeofday(struct timeval *tv, void *tz){
53+
54+
FILETIME ft;
55+
unsigned __int64 tmpres = 0;
56+
static int tzflag;
57+
58+
if (NULL != tv)
59+
{
60+
GetSystemTimeAsFileTime(&ft);
61+
62+
tmpres |= ft.dwHighDateTime;
63+
tmpres <<= 32;
64+
tmpres |= ft.dwLowDateTime;
65+
66+
/*converting file time to unix epoch*/
67+
tmpres /= 10; /*convert into microseconds*/
68+
tmpres -= DELTA_EPOCH_IN_MICROSECS;
69+
tv->tv_sec = (long)(tmpres / 1000000UL);
70+
tv->tv_usec = (long)(tmpres % 1000000UL);
71+
}
72+
73+
return 0;
74+
}
75+
76+
#endif
77+
78+
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
79+
80+
static void *huge_malloc(BLASLONG size){
81+
int shmid;
82+
void *address;
83+
84+
#ifndef SHM_HUGETLB
85+
#define SHM_HUGETLB 04000
86+
#endif
87+
88+
if ((shmid =shmget(IPC_PRIVATE,
89+
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
90+
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
91+
printf( "Memory allocation failed(shmget).\n");
92+
exit(1);
93+
}
94+
95+
address = shmat(shmid, NULL, SHM_RND);
96+
97+
if ((BLASLONG)address == -1){
98+
printf( "Memory allocation failed(shmat).\n");
99+
exit(1);
100+
}
101+
102+
shmctl(shmid, IPC_RMID, 0);
103+
104+
return address;
105+
}
106+
107+
#define malloc huge_malloc
108+
109+
#endif
110+
111+
int main(int argc, char *argv[]){
112+
113+
FLOAT *x, *y, *a;
114+
FLOAT alpha[] = {1.0, 1.0};
115+
char *p;
116+
117+
char uplo='U';
118+
119+
if ((p = getenv("OPENBLAS_UPLO"))) uplo=*p;
120+
121+
blasint m, i, j;
122+
blasint inc_x= 1;
123+
blasint inc_y= 1;
124+
int from = 1;
125+
int to = 200;
126+
int step = 1;
127+
128+
struct timeval start, stop;
129+
double time1;
130+
131+
argc--;argv++;
132+
133+
if (argc > 0) { from = atol(*argv); argc--; argv++;}
134+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
135+
if (argc > 0) { step = atol(*argv); argc--; argv++;}
136+
137+
fprintf(stderr, "From : %3d To : %3d Step = %3d Uplo = %c Inc_x = %d Inc_y = %d\n", from, to, step,uplo,inc_x,inc_y);
138+
139+
if (( a = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL){
140+
fprintf(stderr,"Out of Memory!!\n");exit(1);
141+
}
142+
143+
if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_x) * COMPSIZE)) == NULL){
144+
fprintf(stderr,"Out of Memory!!\n");exit(1);
145+
}
146+
147+
if (( y = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_y) * COMPSIZE)) == NULL){
148+
fprintf(stderr,"Out of Memory!!\n");exit(1);
149+
}
150+
151+
152+
153+
#ifdef linux
154+
srandom(getpid());
155+
#endif
156+
157+
fprintf(stderr, " SIZE Flops\n");
158+
159+
for(m = from; m <= to; m += step)
160+
{
161+
162+
fprintf(stderr, " %6d : ", (int)m);
163+
for(i = 0; i < m * COMPSIZE * abs(inc_x); i++){
164+
x[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
165+
}
166+
167+
for(i = 0; i < m * COMPSIZE * abs(inc_y); i++){
168+
y[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
169+
}
170+
171+
for(j = 0; j < m; j++){
172+
for(i = 0; i < m * COMPSIZE; i++){
173+
a[(long)i + (long)j * (long)m * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
174+
}
175+
}
176+
177+
gettimeofday( &start, (struct timezone *)0);
178+
179+
SYR2 (&uplo, &m, alpha, x, &inc_x, y, &inc_y, a, &m );
180+
181+
gettimeofday( &stop, (struct timezone *)0);
182+
183+
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
184+
185+
fprintf(stderr,
186+
" %10.2f MFlops\n",
187+
COMPSIZE * COMPSIZE * 2. * (double)m * (double)m / time1 * 1.e-6);
188+
189+
}
190+
191+
return 0;
192+
}
193+
194+
// void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));

0 commit comments

Comments
 (0)