1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
4 /* */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
8 /* */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
11 /* disclaimer. */
12 /* */
13 /* 2. Redistributions in binary form must reproduce the above */
14 /* copyright notice, this list of conditions and the following */
15 /* disclaimer in the documentation and/or other materials */
16 /* provided with the distribution. */
17 /* */
18 /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19 /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23 /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27 /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30 /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31 /* POSSIBILITY OF SUCH DAMAGE. */
32 /* */
33 /* The views and conclusions contained in the software and */
34 /* documentation are those of the authors and should not be */
35 /* interpreted as representing official policies, either expressed */
36 /* or implied, of The University of Texas at Austin. */
37 /*********************************************************************/
38
39 #include <stdio.h>
40 #include <ctype.h>
41 #include "common.h"
42 #include "symcopy.h"
43
CNAME(BLASLONG m,BLASLONG offset,FLOAT alpha_r,FLOAT alpha_i,FLOAT * a,BLASLONG lda,FLOAT * x,BLASLONG incx,FLOAT * y,BLASLONG incy,FLOAT * buffer)44 int CNAME(BLASLONG m, BLASLONG offset, FLOAT alpha_r, FLOAT alpha_i,
45 FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG incx, FLOAT *y, BLASLONG incy, FLOAT *buffer){
46
47 BLASLONG is, min_i;
48 FLOAT *X = x;
49 FLOAT *Y = y;
50 FLOAT *symbuffer = buffer;
51 FLOAT *gemvbuffer = (FLOAT *)(((BLASLONG)buffer + SYMV_P * SYMV_P * sizeof(FLOAT) * 2 + 4095) & ~4095);
52 FLOAT *bufferY = gemvbuffer;
53 FLOAT *bufferX = gemvbuffer;
54
55 if (incy != 1) {
56 Y = bufferY;
57 bufferX = (FLOAT *)(((BLASLONG)bufferY + m * sizeof(FLOAT) * 2 + 4095) & ~4095);
58 gemvbuffer = bufferX;
59 COPY_K(m, y, incy, Y, 1);
60 }
61
62 if (incx != 1) {
63 X = bufferX;
64 gemvbuffer = (FLOAT *)(((BLASLONG)bufferX + m * sizeof(FLOAT) * 2 + 4095) & ~4095);
65 COPY_K(m, x, incx, X, 1);
66 }
67
68 #ifndef LOWER
69 for(is = m - offset; is < m; is += SYMV_P){
70 min_i = MIN(m - is, SYMV_P);
71 #else
72 for(is = 0; is < offset; is += SYMV_P){
73 min_i = MIN(offset - is, SYMV_P);
74 #endif
75
76 #ifndef LOWER
77 if (is > 0){
78 #ifndef HEMVREV
79 GEMV_C(is, min_i, 0, alpha_r, alpha_i,
80 a + is * lda * 2, lda,
81 X, 1,
82 Y + is * 2, 1, gemvbuffer);
83
84 GEMV_N(is, min_i, 0, alpha_r, alpha_i,
85 a + is * lda * 2, lda,
86 X + is * 2, 1,
87 Y, 1, gemvbuffer);
88 #else
89 GEMV_T(is, min_i, 0, alpha_r, alpha_i,
90 a + is * lda * 2, lda,
91 X, 1,
92 Y + is * 2, 1, gemvbuffer);
93
94 GEMV_R(is, min_i, 0, alpha_r, alpha_i,
95 a + is * lda * 2, lda,
96 X + is * 2, 1,
97 Y, 1, gemvbuffer);
98 #endif
99 }
100 #endif
101
102 #ifndef HEMVREV
103 #ifdef LOWER
104 ZHEMCOPY_L(min_i, a + (is + is * lda) * 2, lda, symbuffer);
105 #else
106 ZHEMCOPY_U(min_i, a + (is + is * lda) * 2, lda, symbuffer);
107 #endif
108 #else
109 #ifdef LOWER
110 ZHEMCOPY_M(min_i, a + (is + is * lda) * 2, lda, symbuffer);
111 #else
112 ZHEMCOPY_V(min_i, a + (is + is * lda) * 2, lda, symbuffer);
113 #endif
114 #endif
115
116 GEMV_N(min_i, min_i, 0, alpha_r, alpha_i,
117 symbuffer, min_i,
118 X + is * 2, 1,
119 Y + is * 2, 1, gemvbuffer);
120
121 #ifdef LOWER
122 if (m - is - min_i > 0){
123
124 #ifndef HEMVREV
125 GEMV_C(m - is - min_i, min_i, 0, alpha_r, alpha_i,
126 a + ((is + min_i) + is * lda) * 2, lda,
127 X + (is + min_i) * 2, 1,
128 Y + is * 2, 1, gemvbuffer);
129
130 GEMV_N(m - is - min_i, min_i, 0, alpha_r, alpha_i,
131 a + ((is + min_i) + is * lda) * 2, lda,
132 X + is * 2, 1,
133 Y + (is + min_i) * 2, 1, gemvbuffer);
134 #else
135 GEMV_T(m - is - min_i, min_i, 0, alpha_r, alpha_i,
136 a + ((is + min_i) + is * lda) * 2, lda,
137 X + (is + min_i) * 2, 1,
138 Y + is * 2, 1, gemvbuffer);
139
140 GEMV_R(m - is - min_i, min_i, 0, alpha_r, alpha_i,
141 a + ((is + min_i) + is * lda) * 2, lda,
142 X + is * 2, 1,
143 Y + (is + min_i) * 2, 1, gemvbuffer);
144 #endif
145
146 }
147 #endif
148
149 } /* end of is */
150
151 if (incy != 1) {
152 COPY_K(m, Y, 1, y, incy);
153 }
154
155 return 0;
156 }
157
158