From ffaa5765a41e283916049820a8fc9d805c72f04f Mon Sep 17 00:00:00 2001 From: gxw Date: Thu, 17 Oct 2024 12:32:54 +0000 Subject: [PATCH] Bench: Add omatcopy --- benchmark/Makefile | 39 +++++++++++++- benchmark/omatcopy.c | 122 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 benchmark/omatcopy.c diff --git a/benchmark/Makefile b/benchmark/Makefile index b7493950a..c295b1458 100644 --- a/benchmark/Makefile +++ b/benchmark/Makefile @@ -103,6 +103,7 @@ goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \ sgetri.goto dgetri.goto cgetri.goto zgetri.goto \ spotrf.goto dpotrf.goto cpotrf.goto zpotrf.goto \ ssymm.goto dsymm.goto csymm.goto zsymm.goto \ + somatcopy.goto domatcopy.goto comatcopy.goto zomatcopy.goto \ saxpby.goto daxpby.goto caxpby.goto zaxpby.goto $(GOTO_HALF_TARGETS) acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \ @@ -276,6 +277,7 @@ goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \ samin.goto damin.goto camin.goto zamin.goto \ smin.goto dmin.goto \ saxpby.goto daxpby.goto caxpby.goto zaxpby.goto \ + somatcopy.goto domatcopy.goto comatcopy.goto zomatcopy.goto \ snrm2.goto dnrm2.goto scnrm2.goto dznrm2.goto $(GOTO_LAPACK_TARGETS) $(GOTO_HALF_TARGETS) acml :: slinpack.acml dlinpack.acml clinpack.acml zlinpack.acml \ @@ -2906,6 +2908,29 @@ dznrm2.goto : dznrm2.$(SUFFIX) ../$(LIBNAME) dznrm2.atlas : dznrm2.$(SUFFIX) -$(CC) $(CFLAGS) -o $(@F) $^ $(LIBATLAS) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) +################################################################################################### + +############################################ SOMATCOPY ############################################ +somatcopy.goto : somatcopy.$(SUFFIX) ../$(LIBNAME) + $(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm + +################################################################################################### + +############################################ DOMATCOPY ############################################ +domatcopy.goto : domatcopy.$(SUFFIX) ../$(LIBNAME) + $(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm + +################################################################################################### + +############################################ COMATCOPY ############################################ +comatcopy.goto : comatcopy.$(SUFFIX) ../$(LIBNAME) + $(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm + +################################################################################################### + +############################################ ZOMATCOPY ############################################ +zomatcopy.goto : zomatcopy.$(SUFFIX) ../$(LIBNAME) + $(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm ################################################################################################### @@ -3435,6 +3460,18 @@ scnrm2.$(SUFFIX) : nrm2.c dznrm2.$(SUFFIX) : nrm2.c $(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^ +somatcopy.$(SUFFIX) : omatcopy.c + $(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^ + +domatcopy.$(SUFFIX) : omatcopy.c + $(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^ + +comatcopy.$(SUFFIX) : omatcopy.c + $(CC) $(CFLAGS) -c -DCOMPLEX -UDOUBLE -o $(@F) $^ + +zomatcopy.$(SUFFIX) : omatcopy.c + $(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^ + smallscaling: smallscaling.c ../$(LIBNAME) $(CC) $(CFLAGS) -o $(@F) $^ $(EXTRALIB) -fopenmp -lm -lpthread @@ -3442,4 +3479,4 @@ smallscaling: smallscaling.c ../$(LIBNAME) clean :: @rm -f *.goto *.mkl *.acml *.atlas *.veclib *.essl smallscaling -include $(TOPDIR)/Makefile.tail \ No newline at end of file +include $(TOPDIR)/Makefile.tail diff --git a/benchmark/omatcopy.c b/benchmark/omatcopy.c new file mode 100644 index 000000000..c3348c9be --- /dev/null +++ b/benchmark/omatcopy.c @@ -0,0 +1,122 @@ +/*************************************************************************** +Copyright (c) 2024, The OpenBLAS Project +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +3. Neither the name of the OpenBLAS project nor the names of +its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*****************************************************************************/ + +#include "bench.h" + +#undef OMATCOPY + +#ifndef COMPLEX +#ifdef DOUBLE +#define OMATCOPY BLASFUNC(domatcopy) +#else +#define OMATCOPY BLASFUNC(somatcopy) +#endif +#else +#ifdef DOUBLE +#define OMATCOPY BLASFUNC(zomatcopy) +#else +#define OMATCOPY BLASFUNC(comatcopy) +#endif +#endif +int main(int argc, char *argv[]){ + FLOAT *a, *b; + FLOAT alpha[] = {1.0, 0.0}; + char trans = 'N'; + char order = 'C'; + blasint crows, ccols, clda, cldb; + int loops = 1; + char *p; + + int from = 1; + int to = 200; + int step = 1; + int i, j; + + double time1, timeg; + + argc--;argv++; + + if (argc > 0) { from = atol(*argv); argc--; argv++; } + if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++; } + if (argc > 0) { step = atol(*argv); argc--; argv++; } + + if ((p = getenv("OPENBLAS_TRANS"))) { + trans=*p; + } + if ((p = getenv("OPENBLAS_ORDER"))) { + order=*p; + } + TOUPPER(trans); + TOUPPER(order); + fprintf(stderr, "From : %3d To : %3d Step=%d : Trans=%c : Order=%c\n", from, to, step, trans, order); + p = getenv("OPENBLAS_LOOPS"); + if ( p != NULL ) { + loops = atoi(p); + } + + if (( a = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL) { + fprintf(stderr,"Out of Memory!!\n");exit(1); + } + if (( b = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL) { + fprintf(stderr,"Out of Memory!!\n");exit(1); + } + +#ifdef __linux + srandom(getpid()); +#endif + + for (i = 0; i < to * to * COMPSIZE; i++) { + a[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5; + } + for (i = 0; i < to * to * COMPSIZE; i++) { + b[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5; + } + + fprintf(stderr, " SIZE Flops Time\n"); + for (i = from; i <= to; i += step) { + cldb = clda = crows = ccols = i; + fprintf(stderr, " ROWS=%4d, COLS=%4d : ", (int)crows, (int)ccols); + begin(); + + for (j=0; j