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,FLOAT * a,BLASLONG lda,FLOAT * x,BLASLONG incx,FLOAT * y,BLASLONG incy,FLOAT * buffer)44 int CNAME(BLASLONG m, BLASLONG offset, FLOAT alpha, FLOAT *a, BLASLONG lda,
45 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) + 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) + 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) + 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 GEMV_T(is, min_i, 0, alpha,
79 a + is * lda, lda,
80 X, 1,
81 Y + is, 1, gemvbuffer);
82
83 GEMV_N(is, min_i, 0, alpha,
84 a + is * lda, lda,
85 X + is, 1,
86 Y, 1, gemvbuffer);
87 }
88 #endif
89
90 #ifdef LOWER
91 SYMCOPY_L(min_i, a + is + is * lda, lda, symbuffer);
92 #else
93 SYMCOPY_U(min_i, a + is + is * lda, lda, symbuffer);
94 #endif
95
96 GEMV_N(min_i, min_i, 0, alpha,
97 symbuffer, min_i,
98 X + is, 1,
99 Y + is, 1, gemvbuffer);
100
101 #ifdef LOWER
102 if (m - is > min_i){
103 GEMV_T(m - is - min_i, min_i, 0, alpha,
104 a + (is + min_i) + is * lda, lda,
105 X + (is + min_i), 1,
106 Y + is, 1, gemvbuffer);
107
108 GEMV_N(m - is - min_i, min_i, 0, alpha,
109 a + (is + min_i) + is * lda, lda,
110 X + is, 1,
111 Y + (is + min_i), 1, gemvbuffer);
112 }
113 #endif
114
115 } /* end of is */
116
117 if (incy != 1) {
118 COPY_K(m, Y, 1, y, incy);
119 }
120
121 return 0;
122 }
123
124