Skip to content

Commit ffaa576

Browse files
committed
Bench: Add omatcopy
1 parent bb31bbe commit ffaa576

File tree

2 files changed

+160
-1
lines changed

2 files changed

+160
-1
lines changed

benchmark/Makefile

+38-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
103103
sgetri.goto dgetri.goto cgetri.goto zgetri.goto \
104104
spotrf.goto dpotrf.goto cpotrf.goto zpotrf.goto \
105105
ssymm.goto dsymm.goto csymm.goto zsymm.goto \
106+
somatcopy.goto domatcopy.goto comatcopy.goto zomatcopy.goto \
106107
saxpby.goto daxpby.goto caxpby.goto zaxpby.goto $(GOTO_HALF_TARGETS)
107108

108109
acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
@@ -276,6 +277,7 @@ goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
276277
samin.goto damin.goto camin.goto zamin.goto \
277278
smin.goto dmin.goto \
278279
saxpby.goto daxpby.goto caxpby.goto zaxpby.goto \
280+
somatcopy.goto domatcopy.goto comatcopy.goto zomatcopy.goto \
279281
snrm2.goto dnrm2.goto scnrm2.goto dznrm2.goto $(GOTO_LAPACK_TARGETS) $(GOTO_HALF_TARGETS)
280282

281283
acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \
@@ -2906,6 +2908,29 @@ dznrm2.goto : dznrm2.$(SUFFIX) ../$(LIBNAME)
29062908
dznrm2.atlas : dznrm2.$(SUFFIX)
29072909
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)
29082910

2911+
###################################################################################################
2912+
2913+
############################################ SOMATCOPY ############################################
2914+
somatcopy.goto : somatcopy.$(SUFFIX) ../$(LIBNAME)
2915+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
2916+
2917+
###################################################################################################
2918+
2919+
############################################ DOMATCOPY ############################################
2920+
domatcopy.goto : domatcopy.$(SUFFIX) ../$(LIBNAME)
2921+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
2922+
2923+
###################################################################################################
2924+
2925+
############################################ COMATCOPY ############################################
2926+
comatcopy.goto : comatcopy.$(SUFFIX) ../$(LIBNAME)
2927+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
2928+
2929+
###################################################################################################
2930+
2931+
############################################ ZOMATCOPY ############################################
2932+
zomatcopy.goto : zomatcopy.$(SUFFIX) ../$(LIBNAME)
2933+
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm
29092934

29102935
###################################################################################################
29112936

@@ -3435,11 +3460,23 @@ scnrm2.$(SUFFIX) : nrm2.c
34353460
dznrm2.$(SUFFIX) : nrm2.c
34363461
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
34373462

3463+
somatcopy.$(SUFFIX) : omatcopy.c
3464+
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^
3465+
3466+
domatcopy.$(SUFFIX) : omatcopy.c
3467+
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^
3468+
3469+
comatcopy.$(SUFFIX) : omatcopy.c
3470+
$(CC) $(CFLAGS) -c -DCOMPLEX -UDOUBLE -o $(@F) $^
3471+
3472+
zomatcopy.$(SUFFIX) : omatcopy.c
3473+
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^
3474+
34383475

34393476
smallscaling: smallscaling.c ../$(LIBNAME)
34403477
$(CC) $(CFLAGS) -o $(@F) $^ $(EXTRALIB) -fopenmp -lm -lpthread
34413478

34423479
clean ::
34433480
@rm -f *.goto *.mkl *.acml *.atlas *.veclib *.essl smallscaling
34443481

3445-
include $(TOPDIR)/Makefile.tail
3482+
include $(TOPDIR)/Makefile.tail

benchmark/omatcopy.c

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/***************************************************************************
2+
Copyright (c) 2024, 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 "bench.h"
29+
30+
#undef OMATCOPY
31+
32+
#ifndef COMPLEX
33+
#ifdef DOUBLE
34+
#define OMATCOPY BLASFUNC(domatcopy)
35+
#else
36+
#define OMATCOPY BLASFUNC(somatcopy)
37+
#endif
38+
#else
39+
#ifdef DOUBLE
40+
#define OMATCOPY BLASFUNC(zomatcopy)
41+
#else
42+
#define OMATCOPY BLASFUNC(comatcopy)
43+
#endif
44+
#endif
45+
int main(int argc, char *argv[]){
46+
FLOAT *a, *b;
47+
FLOAT alpha[] = {1.0, 0.0};
48+
char trans = 'N';
49+
char order = 'C';
50+
blasint crows, ccols, clda, cldb;
51+
int loops = 1;
52+
char *p;
53+
54+
int from = 1;
55+
int to = 200;
56+
int step = 1;
57+
int i, j;
58+
59+
double time1, timeg;
60+
61+
argc--;argv++;
62+
63+
if (argc > 0) { from = atol(*argv); argc--; argv++; }
64+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++; }
65+
if (argc > 0) { step = atol(*argv); argc--; argv++; }
66+
67+
if ((p = getenv("OPENBLAS_TRANS"))) {
68+
trans=*p;
69+
}
70+
if ((p = getenv("OPENBLAS_ORDER"))) {
71+
order=*p;
72+
}
73+
TOUPPER(trans);
74+
TOUPPER(order);
75+
fprintf(stderr, "From : %3d To : %3d Step=%d : Trans=%c : Order=%c\n", from, to, step, trans, order);
76+
p = getenv("OPENBLAS_LOOPS");
77+
if ( p != NULL ) {
78+
loops = atoi(p);
79+
}
80+
81+
if (( a = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL) {
82+
fprintf(stderr,"Out of Memory!!\n");exit(1);
83+
}
84+
if (( b = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL) {
85+
fprintf(stderr,"Out of Memory!!\n");exit(1);
86+
}
87+
88+
#ifdef __linux
89+
srandom(getpid());
90+
#endif
91+
92+
for (i = 0; i < to * to * COMPSIZE; i++) {
93+
a[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
94+
}
95+
for (i = 0; i < to * to * COMPSIZE; i++) {
96+
b[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
97+
}
98+
99+
fprintf(stderr, " SIZE Flops Time\n");
100+
for (i = from; i <= to; i += step) {
101+
cldb = clda = crows = ccols = i;
102+
fprintf(stderr, " ROWS=%4d, COLS=%4d : ", (int)crows, (int)ccols);
103+
begin();
104+
105+
for (j=0; j<loops; j++) {
106+
OMATCOPY (&order, &trans, &crows, &ccols, alpha, a, &clda, b, &cldb);
107+
}
108+
109+
end();
110+
time1 = getsec();
111+
112+
timeg = time1/loops;
113+
fprintf(stderr,
114+
" %10.2f MFlops %10.6f sec\n",
115+
COMPSIZE * COMPSIZE * (double)ccols * (double)crows / timeg * 1.e-6, time1);
116+
}
117+
118+
free(a);
119+
free(b);
120+
121+
return 0;
122+
}

0 commit comments

Comments
 (0)