|
| 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