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