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 "bench.h"
29 
30 #undef COPY
31 
32 #ifdef COMPLEX
33 #ifdef DOUBLE
34 #define COPY   BLASFUNC(zcopy)
35 #else
36 #define COPY   BLASFUNC(ccopy)
37 #endif
38 #else
39 #ifdef DOUBLE
40 #define COPY   BLASFUNC(dcopy)
41 #else
42 #define COPY   BLASFUNC(scopy)
43 #endif
44 #endif
45 
main(int argc,char * argv[])46 int main(int argc, char *argv[]){
47 
48   FLOAT *x, *y;
49   FLOAT alpha[2] = { 2.0, 2.0 };
50   blasint m, i;
51   blasint inc_x=1,inc_y=1;
52   int loops = 1;
53   int l;
54   char *p;
55 
56   int from =   1;
57   int to   = 200;
58   int step =   1;
59 
60   double time1 = 0.0, timeg = 0.0;
61   long nanos = 0;
62   time_t seconds = 0;
63 
64   argc--;argv++;
65 
66   if (argc > 0) { from     = atol(*argv);		argc--; argv++;}
67   if (argc > 0) { to       = MAX(atol(*argv), from);	argc--; argv++;}
68   if (argc > 0) { step     = atol(*argv);		argc--; argv++;}
69 
70   if ((p = getenv("OPENBLAS_LOOPS")))  loops = atoi(p);
71   if ((p = getenv("OPENBLAS_INCX")))   inc_x = atoi(p);
72   if ((p = getenv("OPENBLAS_INCY")))   inc_y = atoi(p);
73 
74   fprintf(stderr, "From : %3d  To : %3d Step = %3d Inc_x = %d Inc_y = %d Loops = %d\n", from, to, step,inc_x,inc_y,loops);
75 
76   if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_x) * COMPSIZE)) == NULL){
77     fprintf(stderr,"Out of Memory!!\n");exit(1);
78   }
79 
80   if (( y = (FLOAT *)malloc(sizeof(FLOAT) * to * abs(inc_y) * COMPSIZE)) == NULL){
81     fprintf(stderr,"Out of Memory!!\n");exit(1);
82   }
83 
84 #ifdef __linux
85   srandom(getpid());
86 #endif
87 
88   fprintf(stderr, "   SIZE       Flops\n");
89 
90   for(m = from; m <= to; m += step)
91   {
92 
93    timeg=0;
94 
95    fprintf(stderr, " %6d : ", (int)m);
96    for(i = 0; i < m * COMPSIZE * abs(inc_x); i++){
97        x[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
98    }
99 
100    for(i = 0; i < m * COMPSIZE * abs(inc_y); i++){
101        y[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
102    }
103 
104    for (l=0; l<loops; l++)
105    {
106        begin();
107        COPY (&m, x, &inc_x, y, &inc_y );
108        end();
109        timeg += getsec();
110    }
111 
112       timeg /= loops;
113 
114       fprintf(stderr,
115 	    " %10.2f MBytes %12.9f sec\n",
116 	    COMPSIZE * sizeof(FLOAT) * 1. * (double)m / timeg / 1.e6, timeg);
117 
118   }
119 
120   return 0;
121 }
122 
123 // void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));
124