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 "XTPMV "
49 #define ERROR_NAME "ZTPMV "
51 #define ERROR_NAME "CTPMV "
54 static int (*tpmv[])(BLASLONG, FLOAT *, FLOAT *, BLASLONG, void *) = {
56 xtpmv_NUU, xtpmv_NUN, xtpmv_NLU, xtpmv_NLN,
57 xtpmv_TUU, xtpmv_TUN, xtpmv_TLU, xtpmv_TLN,
58 xtpmv_RUU, xtpmv_RUN, xtpmv_RLU, xtpmv_RLN,
59 xtpmv_CUU, xtpmv_CUN, xtpmv_CLU, xtpmv_CLN,
61 ztpmv_NUU, ztpmv_NUN, ztpmv_NLU, ztpmv_NLN,
62 ztpmv_TUU, ztpmv_TUN, ztpmv_TLU, ztpmv_TLN,
63 ztpmv_RUU, ztpmv_RUN, ztpmv_RLU, ztpmv_RLN,
64 ztpmv_CUU, ztpmv_CUN, ztpmv_CLU, ztpmv_CLN,
66 ctpmv_NUU, ctpmv_NUN, ctpmv_NLU, ctpmv_NLN,
67 ctpmv_TUU, ctpmv_TUN, ctpmv_TLU, ctpmv_TLN,
68 ctpmv_RUU, ctpmv_RUN, ctpmv_RLU, ctpmv_RLN,
69 ctpmv_CUU, ctpmv_CUN, ctpmv_CLU, ctpmv_CLN,
74 static int (*tpmv_thread[])(BLASLONG, FLOAT *, FLOAT *, BLASLONG, FLOAT *, int) = {
76 xtpmv_thread_NUU, xtpmv_thread_NUN, xtpmv_thread_NLU, xtpmv_thread_NLN,
77 xtpmv_thread_TUU, xtpmv_thread_TUN, xtpmv_thread_TLU, xtpmv_thread_TLN,
78 xtpmv_thread_RUU, xtpmv_thread_RUN, xtpmv_thread_RLU, xtpmv_thread_RLN,
79 xtpmv_thread_CUU, xtpmv_thread_CUN, xtpmv_thread_CLU, xtpmv_thread_CLN,
81 ztpmv_thread_NUU, ztpmv_thread_NUN, ztpmv_thread_NLU, ztpmv_thread_NLN,
82 ztpmv_thread_TUU, ztpmv_thread_TUN, ztpmv_thread_TLU, ztpmv_thread_TLN,
83 ztpmv_thread_RUU, ztpmv_thread_RUN, ztpmv_thread_RLU, ztpmv_thread_RLN,
84 ztpmv_thread_CUU, ztpmv_thread_CUN, ztpmv_thread_CLU, ztpmv_thread_CLN,
86 ctpmv_thread_NUU, ctpmv_thread_NUN, ctpmv_thread_NLU, ctpmv_thread_NLN,
87 ctpmv_thread_TUU, ctpmv_thread_TUN, ctpmv_thread_TLU, ctpmv_thread_TLN,
88 ctpmv_thread_RUU, ctpmv_thread_RUN, ctpmv_thread_RLU, ctpmv_thread_RLN,
89 ctpmv_thread_CUU, ctpmv_thread_CUN, ctpmv_thread_CLU, ctpmv_thread_CLN,
96 void NAME(char *UPLO, char *TRANS, char *DIAG,
97 blasint *N, FLOAT *a, FLOAT *x, blasint *INCX){
99 char uplo_arg = *UPLO;
100 char trans_arg = *TRANS;
101 char diag_arg = *DIAG;
104 blasint incx = *INCX;
125 if (trans_arg == 'N') trans = 0;
126 if (trans_arg == 'T') trans = 1;
127 if (trans_arg == 'R') trans = 2;
128 if (trans_arg == 'C') trans = 3;
130 if (diag_arg == 'U') unit = 0;
131 if (diag_arg == 'N') unit = 1;
133 if (uplo_arg == 'U') uplo = 0;
134 if (uplo_arg == 'L') uplo = 1;
138 if (incx == 0) info = 7;
140 if (unit < 0) info = 3;
141 if (trans < 0) info = 2;
142 if (uplo < 0) info = 1;
145 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
151 void CNAME(enum CBLAS_ORDER order, enum CBLAS_UPLO Uplo,
152 enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag,
153 blasint n, void *va, void *vx, blasint incx) {
155 FLOAT *a = (FLOAT*) va;
156 FLOAT *x = (FLOAT*) vx;
158 int trans, uplo, unit;
172 if (order == CblasColMajor) {
173 if (Uplo == CblasUpper) uplo = 0;
174 if (Uplo == CblasLower) uplo = 1;
176 if (TransA == CblasNoTrans) trans = 0;
177 if (TransA == CblasTrans) trans = 1;
178 if (TransA == CblasConjNoTrans) trans = 2;
179 if (TransA == CblasConjTrans) trans = 3;
181 if (Diag == CblasUnit) unit = 0;
182 if (Diag == CblasNonUnit) unit = 1;
186 if (incx == 0) info = 7;
188 if (unit < 0) info = 3;
189 if (trans < 0) info = 2;
190 if (uplo < 0) info = 1;
193 if (order == CblasRowMajor) {
194 if (Uplo == CblasUpper) uplo = 1;
195 if (Uplo == CblasLower) uplo = 0;
197 if (TransA == CblasNoTrans) trans = 1;
198 if (TransA == CblasTrans) trans = 0;
199 if (TransA == CblasConjNoTrans) trans = 3;
200 if (TransA == CblasConjTrans) trans = 2;
202 if (Diag == CblasUnit) unit = 0;
203 if (Diag == CblasNonUnit) unit = 1;
207 if (incx == 0) info = 7;
209 if (unit < 0) info = 3;
210 if (trans < 0) info = 2;
211 if (uplo < 0) info = 1;
215 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
225 FUNCTION_PROFILE_START();
227 if (incx < 0 ) x -= (n - 1) * incx * 2;
229 buffer = (FLOAT *)blas_memory_alloc(1);
232 nthreads = num_cpu_avail(2);
237 (tpmv[(trans<<2) | (uplo<<1) | unit])(n, a, x, incx, buffer);
243 (tpmv_thread[(trans<<2) | (uplo<<1) | unit])(n, a, x, incx, buffer, nthreads);
248 blas_memory_free(buffer);
250 FUNCTION_PROFILE_END(4, n * n / 2 + n, n * n);