You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. #include <stdio.h>
  39. #include "common.h"
  40. #ifdef FUNCTION_PROFILE
  41. #include "functable.h"
  42. #endif
  43. #ifdef XDOUBLE
  44. #define ERROR_NAME "QGBMV "
  45. #elif defined(DOUBLE)
  46. #define ERROR_NAME "DGBMV "
  47. #else
  48. #define ERROR_NAME "SGBMV "
  49. #endif
  50. static void (*gbmv[])(BLASLONG, BLASLONG, BLASLONG, BLASLONG, FLOAT,
  51. FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, void *) = {
  52. #ifdef XDOUBLE
  53. qgbmv_n, qgbmv_t,
  54. #elif defined(DOUBLE)
  55. dgbmv_n, dgbmv_t,
  56. #else
  57. sgbmv_n, sgbmv_t,
  58. #endif
  59. };
  60. #ifdef SMP
  61. static int (*gbmv_thread[])(BLASLONG, BLASLONG, BLASLONG, BLASLONG, FLOAT,
  62. FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, BLASLONG, FLOAT *, int) = {
  63. #ifdef XDOUBLE
  64. qgbmv_thread_n, qgbmv_thread_t,
  65. #elif defined(DOUBLE)
  66. dgbmv_thread_n, dgbmv_thread_t,
  67. #else
  68. sgbmv_thread_n, sgbmv_thread_t,
  69. #endif
  70. };
  71. #endif
  72. #ifndef CBLAS
  73. void NAME(char *TRANS, blasint *M, blasint *N,
  74. blasint *KU, blasint *KL,
  75. FLOAT *ALPHA, FLOAT *a, blasint *LDA,
  76. FLOAT *x, blasint *INCX,
  77. FLOAT *BETA, FLOAT *y, blasint *INCY){
  78. char trans = *TRANS;
  79. blasint m = *M;
  80. blasint n = *N;
  81. blasint ku = *KU;
  82. blasint kl = *KL;
  83. blasint lda = *LDA;
  84. blasint incx = *INCX;
  85. blasint incy = *INCY;
  86. FLOAT *buffer;
  87. #ifdef SMP
  88. int nthreads;
  89. #endif
  90. FLOAT alpha = *ALPHA;
  91. FLOAT beta = *BETA;
  92. blasint info;
  93. blasint lenx, leny;
  94. blasint i;
  95. PRINT_DEBUG_NAME;
  96. TOUPPER(trans);
  97. info = 0;
  98. i = -1;
  99. if (trans == 'N') i = 0;
  100. if (trans == 'T') i = 1;
  101. if (trans == 'R') i = 0;
  102. if (trans == 'C') i = 1;
  103. if (incy == 0) info = 13;
  104. if (incx == 0) info = 10;
  105. if (lda < kl + ku + 1) info = 8;
  106. if (kl < 0) info = 5;
  107. if (ku < 0) info = 4;
  108. if (n < 0) info = 3;
  109. if (m < 0) info = 2;
  110. if (i < 0) info = 1;
  111. trans = i;
  112. if (info != 0){
  113. BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
  114. return;
  115. }
  116. #else
  117. void CNAME(enum CBLAS_ORDER order,
  118. enum CBLAS_TRANSPOSE TransA,
  119. blasint m, blasint n,
  120. blasint ku, blasint kl,
  121. FLOAT alpha,
  122. FLOAT *a, blasint lda,
  123. FLOAT *x, blasint incx,
  124. FLOAT beta,
  125. FLOAT *y, blasint incy){
  126. FLOAT *buffer;
  127. blasint lenx, leny, info, t;
  128. int trans;
  129. #ifdef SMP
  130. int nthreads;
  131. #endif
  132. PRINT_DEBUG_CNAME;
  133. trans = -1;
  134. info = 0;
  135. if (order == CblasColMajor) {
  136. if (TransA == CblasNoTrans) trans = 0;
  137. if (TransA == CblasTrans) trans = 1;
  138. if (TransA == CblasConjNoTrans) trans = 0;
  139. if (TransA == CblasConjTrans) trans = 1;
  140. info = -1;
  141. if (incy == 0) info = 13;
  142. if (incx == 0) info = 10;
  143. if (lda < kl + ku + 1) info = 8;
  144. if (kl < 0) info = 5;
  145. if (ku < 0) info = 4;
  146. if (n < 0) info = 3;
  147. if (m < 0) info = 2;
  148. if (trans < 0) info = 1;
  149. }
  150. if (order == CblasRowMajor) {
  151. if (TransA == CblasNoTrans) trans = 1;
  152. if (TransA == CblasTrans) trans = 0;
  153. if (TransA == CblasConjNoTrans) trans = 1;
  154. if (TransA == CblasConjTrans) trans = 0;
  155. info = -1;
  156. t = n;
  157. n = m;
  158. m = t;
  159. t = ku;
  160. ku = kl;
  161. kl = t;
  162. if (incy == 0) info = 13;
  163. if (incx == 0) info = 10;
  164. if (lda < kl + ku + 1) info = 8;
  165. if (kl < 0) info = 5;
  166. if (ku < 0) info = 4;
  167. if (n < 0) info = 3;
  168. if (m < 0) info = 2;
  169. if (trans < 0) info = 1;
  170. }
  171. if (info >= 0) {
  172. BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
  173. return;
  174. }
  175. #endif
  176. if ((m==0) || (n==0)) return;
  177. lenx = n;
  178. leny = m;
  179. if (trans) lenx = m;
  180. if (trans) leny = n;
  181. if (beta != ONE) SCAL_K(leny, 0, 0, beta, y, blasabs(incy), NULL, 0, NULL, 0);
  182. if (alpha == ZERO) return;
  183. IDEBUG_START;
  184. FUNCTION_PROFILE_START();
  185. if (incx < 0) x -= (lenx-1)*incx;
  186. if (incy < 0) y -= (leny-1)*incy;
  187. buffer = (FLOAT *)blas_memory_alloc(1);
  188. #ifdef SMP
  189. nthreads = num_cpu_avail(2);
  190. if (nthreads == 1) {
  191. #endif
  192. (gbmv[(int)trans])(m, n, kl, ku, alpha, a, lda, x, incx, y, incy, buffer);
  193. #ifdef SMP
  194. } else {
  195. (gbmv_thread[(int)trans])(m, n, kl, ku, alpha, a, lda, x, incx, y, incy, buffer, nthreads);
  196. }
  197. #endif
  198. blas_memory_free(buffer);
  199. FUNCTION_PROFILE_END(1, m * n / 2 + n, m * n);
  200. IDEBUG_END;
  201. return;
  202. }