Skip to content

Commit 69d4687

Browse files
authored
Merge pull request #2464 from Darkness303/develop
Add syr benchmark
2 parents a731a9b + e106240 commit 69d4687

File tree

2 files changed

+234
-2
lines changed

2 files changed

+234
-2
lines changed

benchmark/Makefile

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ include $(TOPDIR)/Makefile.system
1212
# ACML 6.1 custom
1313
ACML=/home/saar/acml6.1/gfortran64_mp/lib
1414
LIBACML = -fopenmp $(ACML)/libacml_mp.so -lgfortran -lm
15-
1615

17-
# Atlas Ubuntu
16+
17+
# Atlas Ubuntu
1818
#ATLAS=/usr/lib/atlas-base
1919
#LIBATLAS = -fopenmp $(ATLAS)/liblapack_atlas.a $(ATLAS)/libptcblas.a $(ATLAS)/libptf77blas.a $(ATLAS)/libatlas.a -lgfortran -lm
2020

@@ -56,6 +56,7 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
5656
sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
5757
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
5858
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
59+
ssyr.goto dsyr.goto \
5960
ssyrk.goto dsyrk.goto csyrk.goto zsyrk.goto \
6061
ssyr2k.goto dsyr2k.goto csyr2k.goto zsyr2k.goto \
6162
sger.goto dger.goto cger.goto zger.goto \
@@ -83,6 +84,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
8384
sgemm.acml dgemm.acml cgemm.acml zgemm.acml \
8485
strmm.acml dtrmm.acml ctrmm.acml ztrmm.acml \
8586
strsm.acml dtrsm.acml ctrsm.acml ztrsm.acml \
87+
ssyr.acml dsyr.acml \
8688
ssyrk.acml dsyrk.acml csyrk.acml zsyrk.acml \
8789
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
8890
sger.acml dger.acml cger.acml zger.acml \
@@ -109,6 +111,7 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
109111
sgemm.atlas dgemm.atlas cgemm.atlas zgemm.atlas \
110112
strmm.atlas dtrmm.atlas ctrmm.atlas ztrmm.atlas \
111113
strsm.atlas dtrsm.atlas ctrsm.atlas ztrsm.atlas \
114+
ssyr.goto dsyr.atlas \
112115
ssyrk.atlas dsyrk.atlas csyrk.atlas zsyrk.atlas \
113116
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
114117
sger.atlas dger.atlas cger.atlas zger.atlas\
@@ -136,6 +139,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
136139
sgemm.mkl dgemm.mkl cgemm.mkl zgemm.mkl \
137140
strmm.mkl dtrmm.mkl ctrmm.mkl ztrmm.mkl \
138141
strsm.mkl dtrsm.mkl ctrsm.mkl ztrsm.mkl \
142+
ssyr.mkl dsyr.mkl \
139143
ssyrk.mkl dsyrk.mkl csyrk.mkl zsyrk.mkl \
140144
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
141145
sger.mkl dger.mkl cger.mkl zger.mkl \
@@ -162,6 +166,7 @@ else
162166
goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
163167
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
164168
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
169+
ssyr.goto dsyr.goto \
165170
ssyrk.goto dsyrk.goto csyrk.goto zsyrk.goto \
166171
ssyr2k.goto dsyr2k.goto csyr2k.goto zsyr2k.goto \
167172
sger.goto dger.goto cger.goto zger.goto \
@@ -188,6 +193,7 @@ acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
188193
sgemm.acml dgemm.acml cgemm.acml zgemm.acml \
189194
strmm.acml dtrmm.acml ctrmm.acml ztrmm.acml \
190195
strsm.acml dtrsm.acml ctrsm.acml ztrsm.acml \
196+
ssyr.acml dsyr.acml \
191197
ssyrk.acml dsyrk.acml csyrk.acml zsyrk.acml \
192198
ssyr2k.acml dsyr2k.acml csyr2k.acml zsyr2k.acml \
193199
sger.acml dger.acml cger.acml zger.acml \
@@ -214,6 +220,7 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
214220
sgemm.atlas dgemm.atlas cgemm.atlas zgemm.atlas \
215221
strmm.atlas dtrmm.atlas ctrmm.atlas ztrmm.atlas \
216222
strsm.atlas dtrsm.atlas ctrsm.atlas ztrsm.atlas \
223+
ssyr.atlas dsyr.atlas \
217224
ssyrk.atlas dsyrk.atlas csyrk.atlas zsyrk.atlas \
218225
ssyr2k.atlas dsyr2k.atlas csyr2k.atlas zsyr2k.atlas \
219226
sger.atlas dger.atlas cger.atlas zger.atlas\
@@ -243,6 +250,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
243250
sgemm.mkl dgemm.mkl cgemm.mkl zgemm.mkl \
244251
strmm.mkl dtrmm.mkl ctrmm.mkl ztrmm.mkl \
245252
strsm.mkl dtrsm.mkl ctrsm.mkl ztrsm.mkl \
253+
ssyr.mkl dsyr.mkl \
246254
ssyrk.mkl dsyrk.mkl csyrk.mkl zsyrk.mkl \
247255
ssyr2k.mkl dsyr2k.mkl csyr2k.mkl zsyr2k.mkl \
248256
sger.mkl dger.mkl cger.mkl zger.mkl \
@@ -280,6 +288,7 @@ veclib :: slinpack.veclib dlinpack.veclib clinpack.veclib zlinpack.veclib \
280288
sgemm.veclib dgemm.veclib cgemm.veclib zgemm.veclib \
281289
strmm.veclib dtrmm.veclib ctrmm.veclib ztrmm.veclib \
282290
strsm.veclib dtrsm.veclib ctrsm.veclib ztrsm.veclib \
291+
ssyr.veclib dsyr.veclib \
283292
ssyrk.veclib dsyrk.veclib csyrk.veclib zsyrk.veclib \
284293
ssyr2k.veclib dsyr2k.veclib csyr2k.veclib zsyr2k.veclib \
285294
sger.veclib dger.veclib cger.veclib zger.veclib \
@@ -768,6 +777,36 @@ ztrsm.veclib : ztrsm.$(SUFFIX)
768777

769778
ztrsm.essl : ztrsm.$(SUFFIX)
770779
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBESSL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
780+
##################################### Ssyr ####################################################
781+
ssyr.goto : ssyr.$(SUFFIX) ../$(LIBNAME)
782+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
783+
784+
ssyr.acml : ssyr.$(SUFFIX)
785+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
786+
787+
ssyr.atlas : ssyr.$(SUFFIX)
788+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
789+
790+
ssyr.mkl : ssyr.$(SUFFIX)
791+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
792+
793+
ssyr.veclib : ssyr.$(SUFFIX)
794+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
795+
##################################### Dsyr ####################################################
796+
dsyr.goto : dsyr.$(SUFFIX) ../$(LIBNAME)
797+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
798+
799+
dsyr.acml : dsyr.$(SUFFIX)
800+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
801+
802+
dsyr.atlas : dsyr.$(SUFFIX)
803+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
804+
805+
dsyr.mkl : dsyr.$(SUFFIX)
806+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBMKL) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
807+
808+
dsyr.veclib : dsyr.$(SUFFIX)
809+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
771810

772811
##################################### Ssyrk ####################################################
773812
ssyrk.goto : ssyrk.$(SUFFIX) ../$(LIBNAME)
@@ -2078,6 +2117,12 @@ ctrsm.$(SUFFIX) : trsm.c
20782117
ztrsm.$(SUFFIX) : trsm.c
20792118
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
20802119

2120+
ssyr.$(SUFFIX) : syr.c
2121+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
2122+
2123+
dsyr.$(SUFFIX) : syr.c
2124+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
2125+
20812126
ssyrk.$(SUFFIX) : syrk.c
20822127
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
20832128

benchmark/syr.c

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
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 SYR
37+
38+
#ifdef DOUBLE
39+
#define SYR BLASFUNC(dsyr)
40+
#else
41+
#define SYR BLASFUNC(ssyr)
42+
#endif
43+
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,*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+
int from = 1;
124+
int to = 200;
125+
int step = 1;
126+
127+
struct timeval start, stop;
128+
double time1;
129+
130+
argc--;argv++;
131+
132+
if (argc > 0) { from = atol(*argv); argc--; argv++;}
133+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
134+
if (argc > 0) { step = atol(*argv); argc--; argv++;}
135+
136+
fprintf(stderr, "From : %3d To : %3d Step = %3d Uplo = %c Inc_x = %d\n", from, to, step,uplo,inc_x);
137+
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+
#ifdef linux
148+
srandom(getpid());
149+
#endif
150+
151+
fprintf(stderr, " SIZE Flops\n");
152+
153+
for(m = from; m <= to; m += step)
154+
{
155+
156+
fprintf(stderr, " %6d : ", (int)m);
157+
158+
for(i = 0; i < m * COMPSIZE * abs(inc_x); i++){
159+
x[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
160+
}
161+
162+
for(j = 0; j < m; j++){
163+
for(i = 0; i < m * COMPSIZE; i++){
164+
a[(long)i + (long)j * (long)m * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
165+
}
166+
}
167+
168+
gettimeofday( &start, (struct timezone *)0);
169+
170+
SYR (&uplo, &m, alpha, x, &inc_x, a, &m );
171+
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+
gettimeofday( &start, (struct timezone *)0);
177+
178+
fprintf(stderr,
179+
" %10.2f MFlops\n",
180+
COMPSIZE * COMPSIZE * 1. * (double)m * (double)m * (double)m / time1 * 1.e-6);
181+
182+
}
183+
184+
return 0;
185+
}
186+
187+
// void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));

0 commit comments

Comments
 (0)