Skip to content

Commit 925d4e1

Browse files
author
Ashwin Sekhar T K
committed
Add IAMAX and NRM2 benchmarks
1 parent 437c7d6 commit 925d4e1

File tree

3 files changed

+470
-2
lines changed

3 files changed

+470
-2
lines changed

Diff for: benchmark/Makefile

+90-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
173173
sgetri.goto dgetri.goto cgetri.goto zgetri.goto \
174174
spotrf.goto dpotrf.goto cpotrf.goto zpotrf.goto \
175175
ssymm.goto dsymm.goto csymm.goto zsymm.goto \
176-
smallscaling
176+
smallscaling \
177+
isamax.goto idamax.goto icamax.goto izamax.goto \
178+
snrm2.goto dnrm2.goto scnrm2.goto dznrm2.goto
177179

178180
acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
179181
scholesky.acml dcholesky.acml ccholesky.acml zcholesky.acml \
@@ -226,7 +228,9 @@ atlas :: slinpack.atlas dlinpack.atlas clinpack.atlas zlinpack.atlas \
226228
sgesv.atlas dgesv.atlas cgesv.atlas zgesv.atlas \
227229
sgetri.atlas dgetri.atlas cgetri.atlas zgetri.atlas \
228230
spotrf.atlas dpotrf.atlas cpotrf.atlas zpotrf.atlas \
229-
ssymm.atlas dsymm.atlas csymm.atlas zsymm.atlas
231+
ssymm.atlas dsymm.atlas csymm.atlas zsymm.atlas \
232+
isamax.atlas idamax.atlas icamax.atlas izamax.atlas \
233+
snrm2.goto dnrm2.goto scnrm2.goto dznrm2.goto
230234

231235
mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
232236
scholesky.mkl dcholesky.mkl ccholesky.mkl zcholesky.mkl \
@@ -1937,6 +1941,63 @@ zgemm3m.mkl : zgemm3m.$(SUFFIX)
19371941
zgemm3m.veclib : zgemm3m.$(SUFFIX)
19381942
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBVECLIB) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
19391943

1944+
############################################## ISAMAX ##############################################
1945+
isamax.goto : isamax.$(SUFFIX) ../$(LIBNAME)
1946+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1947+
1948+
isamax.atlas : isamax.$(SUFFIX)
1949+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1950+
1951+
############################################## IDAMAX ##############################################
1952+
idamax.goto : idamax.$(SUFFIX) ../$(LIBNAME)
1953+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1954+
1955+
idamax.atlas : idamax.$(SUFFIX)
1956+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1957+
1958+
############################################## ICAMAX ##############################################
1959+
icamax.goto : icamax.$(SUFFIX) ../$(LIBNAME)
1960+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1961+
1962+
icamax.atlas : icamax.$(SUFFIX)
1963+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1964+
1965+
############################################## IZAMAX ##############################################
1966+
izamax.goto : izamax.$(SUFFIX) ../$(LIBNAME)
1967+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1968+
1969+
izamax.atlas : izamax.$(SUFFIX)
1970+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1971+
1972+
############################################## SNRM2 ##############################################
1973+
snrm2.goto : snrm2.$(SUFFIX) ../$(LIBNAME)
1974+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1975+
1976+
snrm2.atlas : snrm2.$(SUFFIX)
1977+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1978+
1979+
############################################## DNRM2 ##############################################
1980+
dnrm2.goto : dnrm2.$(SUFFIX) ../$(LIBNAME)
1981+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1982+
1983+
dnrm2.atlas : dnrm2.$(SUFFIX)
1984+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1985+
1986+
############################################## Sscnrm2 ##############################################
1987+
scnrm2.goto : scnrm2.$(SUFFIX) ../$(LIBNAME)
1988+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1989+
1990+
scnrm2.atlas : scnrm2.$(SUFFIX)
1991+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1992+
1993+
############################################## Ddznrm2 ##############################################
1994+
dznrm2.goto : dznrm2.$(SUFFIX) ../$(LIBNAME)
1995+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
1996+
1997+
dznrm2.atlas : dznrm2.$(SUFFIX)
1998+
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
1999+
2000+
19402001
###################################################################################################
19412002

19422003
slinpack.$(SUFFIX) : linpack.c
@@ -2243,6 +2304,33 @@ cgemm3m.$(SUFFIX) : gemm3m.c
22432304
zgemm3m.$(SUFFIX) : gemm3m.c
22442305
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
22452306

2307+
2308+
isamax.$(SUFFIX) : iamax.c
2309+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
2310+
2311+
idamax.$(SUFFIX) : iamax.c
2312+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
2313+
2314+
icamax.$(SUFFIX) : iamax.c
2315+
$(CC) $(CFLAGS) -c -DCOMPLEX -UDOUBLE -o $(@F) $^
2316+
2317+
izamax.$(SUFFIX) : iamax.c
2318+
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
2319+
2320+
2321+
snrm2.$(SUFFIX) : nrm2.c
2322+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
2323+
2324+
dnrm2.$(SUFFIX) : nrm2.c
2325+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
2326+
2327+
scnrm2.$(SUFFIX) : nrm2.c
2328+
$(CC) $(CFLAGS) -c -DCOMPLEX -UDOUBLE -o $(@F) $^
2329+
2330+
dznrm2.$(SUFFIX) : nrm2.c
2331+
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
2332+
2333+
22462334
smallscaling: smallscaling.c ../$(LIBNAME)
22472335
$(CC) $(CFLAGS) -o $(@F) $^ $(EXTRALIB) -fopenmp -lm -lpthread
22482336

Diff for: benchmark/iamax.c

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/***************************************************************************
2+
Copyright (c) 2016, 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 IAMAX
37+
38+
#ifdef COMPLEX
39+
#ifdef DOUBLE
40+
#define IAMAX BLASFUNC(izamax)
41+
#else
42+
#define IAMAX BLASFUNC(icamax)
43+
#endif
44+
#else
45+
#ifdef DOUBLE
46+
#define IAMAX BLASFUNC(idamax)
47+
#else
48+
#define IAMAX BLASFUNC(isamax)
49+
#endif
50+
#endif
51+
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[]){
118+
119+
FLOAT *x;
120+
blasint m, i;
121+
blasint inc_x=1;
122+
int loops = 1;
123+
int l;
124+
char *p;
125+
126+
int from = 1;
127+
int to = 200;
128+
int step = 1;
129+
130+
struct timeval start, stop;
131+
double time1,timeg;
132+
133+
argc--;argv++;
134+
135+
if (argc > 0) { from = atol(*argv); argc--; argv++;}
136+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
137+
if (argc > 0) { step = atol(*argv); argc--; argv++;}
138+
139+
if ((p = getenv("OPENBLAS_LOOPS"))) loops = atoi(p);
140+
if ((p = getenv("OPENBLAS_INCX"))) inc_x = atoi(p);
141+
142+
fprintf(stderr, "From : %3d To : %3d Step = %3d Inc_x = %d Loops = %d\n", from, to, step,inc_x,loops);
143+
144+
if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_x) * COMPSIZE)) == NULL){
145+
fprintf(stderr,"Out of Memory!!\n");exit(1);
146+
}
147+
148+
#ifdef linux
149+
srandom(getpid());
150+
#endif
151+
152+
fprintf(stderr, " SIZE Time\n");
153+
154+
for(m = from; m <= to; m += step)
155+
{
156+
157+
timeg=0;
158+
159+
fprintf(stderr, " %6d : ", (int)m);
160+
161+
162+
for (l=0; l<loops; l++)
163+
{
164+
165+
for(i = 0; i < m * COMPSIZE * abs(inc_x); i++){
166+
x[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
167+
}
168+
169+
gettimeofday( &start, (struct timezone *)0);
170+
171+
IAMAX (&m, x, &inc_x);
172+
173+
gettimeofday( &stop, (struct timezone *)0);
174+
175+
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
176+
177+
timeg += time1;
178+
179+
}
180+
181+
timeg /= loops;
182+
183+
fprintf(stderr, " %10.6f secs\n", timeg);
184+
185+
}
186+
187+
return 0;
188+
}
189+
190+
// void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));

0 commit comments

Comments
 (0)