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