1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
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. */
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. */
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 /*********************************************************************/
41 #ifdef FUNCTION_PROFILE
42 #include "functable.h"
46 #define ERROR_NAME "XGBMV "
48 #define ERROR_NAME "ZGBMV "
50 #define ERROR_NAME "CGBMV "
53 static void (*gbmv[])(BLASLONG, BLASLONG, BLASLONG, BLASLONG, FLOAT, FLOAT,
54 FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, void *) = {
56 xgbmv_n, xgbmv_t, xgbmv_r, xgbmv_c,
57 xgbmv_o, xgbmv_u, xgbmv_s, xgbmv_d,
59 zgbmv_n, zgbmv_t, zgbmv_r, zgbmv_c,
60 zgbmv_o, zgbmv_u, zgbmv_s, zgbmv_d,
62 cgbmv_n, cgbmv_t, cgbmv_r, cgbmv_c,
63 cgbmv_o, cgbmv_u, cgbmv_s, cgbmv_d,
68 static int (*gbmv_thread[])(BLASLONG, BLASLONG, BLASLONG, BLASLONG, FLOAT *,
69 FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, int) = {
71 xgbmv_thread_n, xgbmv_thread_t, xgbmv_thread_r, xgbmv_thread_c,
72 xgbmv_thread_o, xgbmv_thread_u, xgbmv_thread_s, xgbmv_thread_d,
74 zgbmv_thread_n, zgbmv_thread_t, zgbmv_thread_r, zgbmv_thread_c,
75 zgbmv_thread_o, zgbmv_thread_u, zgbmv_thread_s, zgbmv_thread_d,
77 cgbmv_thread_n, cgbmv_thread_t, cgbmv_thread_r, cgbmv_thread_c,
78 cgbmv_thread_o, cgbmv_thread_u, cgbmv_thread_s, cgbmv_thread_d,
85 void NAME(char *TRANS, blasint *M, blasint *N,
86 blasint *KU, blasint *KL,
87 FLOAT *ALPHA, FLOAT *a, blasint *LDA,
88 FLOAT *x, blasint *INCX,
89 FLOAT *BETA, FLOAT *y, blasint *INCY){
104 FLOAT alpha_r = ALPHA[0];
105 FLOAT alpha_i = ALPHA[1];
106 FLOAT beta_r = BETA[0];
107 FLOAT beta_i = BETA[1];
121 if (trans == 'N') i = 0;
122 if (trans == 'T') i = 1;
123 if (trans == 'R') i = 2;
124 if (trans == 'C') i = 3;
125 if (trans == 'O') i = 4;
126 if (trans == 'U') i = 5;
127 if (trans == 'S') i = 6;
128 if (trans == 'D') i = 7;
130 if (incy == 0) info = 13;
131 if (incx == 0) info = 10;
132 if (lda < kl + ku + 1) info = 8;
133 if (kl < 0) info = 5;
134 if (ku < 0) info = 4;
142 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
148 void CNAME(enum CBLAS_ORDER order,
149 enum CBLAS_TRANSPOSE TransA,
150 blasint m, blasint n,
151 blasint ku, blasint kl,
153 void *va, blasint lda,
154 void *vx, blasint incx,
156 void *vy, blasint incy){
158 FLOAT* ALPHA = (FLOAT*) VALPHA;
159 FLOAT* BETA = (FLOAT*) VBETA;
160 FLOAT* a = (FLOAT*) va;
161 FLOAT* x = (FLOAT*) vx;
162 FLOAT* y = (FLOAT*) vy;
164 FLOAT alpha_r = ALPHA[0];
165 FLOAT alpha_i = ALPHA[1];
166 FLOAT beta_r = BETA[0];
167 FLOAT beta_i = BETA[1];
182 if (order == CblasColMajor) {
183 if (TransA == CblasNoTrans) trans = 0;
184 if (TransA == CblasTrans) trans = 1;
185 if (TransA == CblasConjNoTrans) trans = 2;
186 if (TransA == CblasConjTrans) trans = 3;
190 if (incy == 0) info = 13;
191 if (incx == 0) info = 10;
192 if (lda < kl + ku + 1) info = 8;
193 if (kl < 0) info = 5;
194 if (ku < 0) info = 4;
197 if (trans < 0) info = 1;
200 if (order == CblasRowMajor) {
201 if (TransA == CblasNoTrans) trans = 1;
202 if (TransA == CblasTrans) trans = 0;
203 if (TransA == CblasConjNoTrans) trans = 3;
204 if (TransA == CblasConjTrans) trans = 2;
216 if (incy == 0) info = 13;
217 if (incx == 0) info = 10;
218 if (lda < kl + ku + 1) info = 8;
219 if (kl < 0) info = 5;
220 if (ku < 0) info = 4;
223 if (trans < 0) info = 1;
227 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
233 if ((m==0) || (n==0)) return;
237 if (trans & 1) lenx = m;
238 if (trans & 1) leny = n;
240 if (beta_r != ONE || beta_i != ZERO) SCAL_K(leny, 0, 0, beta_r, beta_i, y, blasabs(incy), NULL, 0, NULL, 0);
242 if (alpha_r == ZERO && alpha_i == ZERO) return;
246 FUNCTION_PROFILE_START();
248 if (incx < 0) x -= (lenx - 1) * incx * 2;
249 if (incy < 0) y -= (leny - 1) * incy * 2;
251 buffer = (FLOAT *)blas_memory_alloc(1);
254 nthreads = num_cpu_avail(2);
259 (gbmv[(int)trans])(m, n, kl, ku, alpha_r, alpha_i, a, lda, x, incx, y, incy, buffer);
265 (gbmv_thread[(int)trans])(m, n, kl, ku, ALPHA, a, lda, x, incx, y, incy, buffer, nthreads);
270 blas_memory_free(buffer);
272 FUNCTION_PROFILE_END(4, m * n / 2 + n, m * n);