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