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 /*********************************************************************/
42 #ifdef FUNCTION_PROFILE
43 #include "functable.h"
47 #define ERROR_NAME "XHBMV "
49 #define ERROR_NAME "ZHBMV "
51 #define ERROR_NAME "CHBMV "
54 static int (*hbmv[])(BLASLONG, BLASLONG, FLOAT, FLOAT, FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, void *) = {
56 xhbmv_U, xhbmv_L, xhbmv_V, xhbmv_M,
58 zhbmv_U, zhbmv_L, zhbmv_V, zhbmv_M,
60 chbmv_U, chbmv_L, chbmv_V, chbmv_M,
65 static int (*hbmv_thread[])(BLASLONG, BLASLONG, FLOAT *, FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, int) = {
67 xhbmv_thread_U, xhbmv_thread_L, xhbmv_thread_V, xhbmv_thread_M,
69 zhbmv_thread_U, zhbmv_thread_L, zhbmv_thread_V, zhbmv_thread_M,
71 chbmv_thread_U, chbmv_thread_L, chbmv_thread_V, chbmv_thread_M,
78 void NAME(char *UPLO, blasint *N, blasint *K, FLOAT *ALPHA, FLOAT *a, blasint *LDA,
79 FLOAT *x, blasint *INCX, FLOAT *BETA, FLOAT *y, blasint *INCY){
81 char uplo_arg = *UPLO;
84 FLOAT alpha_r = ALPHA[0];
85 FLOAT alpha_i = ALPHA[1];
88 FLOAT beta_r = BETA[0];
89 FLOAT beta_i = BETA[1];
104 if (uplo_arg == 'U') uplo = 0;
105 if (uplo_arg == 'L') uplo = 1;
106 if (uplo_arg == 'V') uplo = 2;
107 if (uplo_arg == 'M') uplo = 3;
111 if (incy == 0) info = 11;
112 if (incx == 0) info = 8;
113 if (lda < k + 1) info = 6;
116 if (uplo < 0) info = 1;
119 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
125 void CNAME(enum CBLAS_ORDER order,
126 enum CBLAS_UPLO Uplo,
127 blasint n, blasint k,
129 void *va, blasint lda,
130 void *vx, blasint incx,
132 void *vy, blasint incy){
134 FLOAT* ALPHA = (FLOAT*) VALPHA;
135 FLOAT* BETA = (FLOAT*) VBETA;
136 FLOAT* a = (FLOAT*) va;
137 FLOAT* x = (FLOAT*) vx;
138 FLOAT* y = (FLOAT*) vy;
140 FLOAT alpha_r = ALPHA[0];
141 FLOAT alpha_i = ALPHA[1];
142 FLOAT beta_r = BETA[0];
143 FLOAT beta_i = BETA[1];
156 if (order == CblasColMajor) {
157 if (Uplo == CblasUpper) uplo = 0;
158 if (Uplo == CblasLower) uplo = 1;
162 if (incy == 0) info = 11;
163 if (incx == 0) info = 8;
164 if (lda < k + 1) info = 6;
167 if (uplo < 0) info = 1;
170 if (order == CblasRowMajor) {
171 if (Uplo == CblasUpper) uplo = 3;
172 if (Uplo == CblasLower) uplo = 2;
176 if (incy == 0) info = 11;
177 if (incx == 0) info = 8;
178 if (lda < k + 1) info = 6;
181 if (uplo < 0) info = 1;
185 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
193 if ((beta_r != ONE) || (beta_i != ZERO)) SCAL_K(n, 0, 0, beta_r, beta_i, y, blasabs(incy), NULL, 0, NULL, 0);
195 if ((alpha_r == ZERO) && (alpha_i == ZERO)) return;
199 FUNCTION_PROFILE_START();
201 if (incx < 0 ) x -= (n - 1) * incx * COMPSIZE;
202 if (incy < 0 ) y -= (n - 1) * incy * COMPSIZE;
204 buffer = (FLOAT *)blas_memory_alloc(1);
207 nthreads = num_cpu_avail(2);
212 (hbmv[uplo])(n, k, alpha_r, alpha_i, a, lda, x, incx, y, incy, buffer);
217 (hbmv_thread[uplo])(n, k, ALPHA, a, lda, x, incx, y, incy, buffer, nthreads);
222 blas_memory_free(buffer);
224 FUNCTION_PROFILE_END(4, n * k / 2 + n, n * k);