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.

zger.c 6.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. #ifndef CONJ
  45. #define ERROR_NAME "XGERU "
  46. #else
  47. #define ERROR_NAME "XGERC "
  48. #endif
  49. #elif defined DOUBLE
  50. #ifndef CONJ
  51. #define ERROR_NAME "ZGERU "
  52. #else
  53. #define ERROR_NAME "ZGERC "
  54. #endif
  55. #else
  56. #ifndef CONJ
  57. #define ERROR_NAME "CGERU "
  58. #else
  59. #define ERROR_NAME "CGERC "
  60. #endif
  61. #endif
  62. #if defined XDOUBLE
  63. #ifndef CONJ
  64. #define GER GERU_K
  65. #define GER_THREAD xger_thread_U
  66. #else
  67. #define GER GERC_K
  68. #define GER_THREAD xger_thread_C
  69. #define GERV GERV_K
  70. #define GERV_THREAD xger_thread_V
  71. #endif
  72. #elif defined DOUBLE
  73. #ifndef CONJ
  74. #define GER GERU_K
  75. #define GER_THREAD zger_thread_U
  76. #else
  77. #define GER GERC_K
  78. #define GER_THREAD zger_thread_C
  79. #define GERV GERV_K
  80. #define GERV_THREAD zger_thread_V
  81. #endif
  82. #else
  83. #ifndef CONJ
  84. #define GER GERU_K
  85. #define GER_THREAD cger_thread_U
  86. #else
  87. #define GER GERC_K
  88. #define GER_THREAD cger_thread_C
  89. #define GERV GERV_K
  90. #define GERV_THREAD cger_thread_V
  91. #endif
  92. #endif
  93. #ifndef CBLAS
  94. void NAME(blasint *M, blasint *N, FLOAT *Alpha,
  95. FLOAT *x, blasint *INCX,
  96. FLOAT *y, blasint *INCY,
  97. FLOAT *a, blasint *LDA){
  98. blasint m = *M;
  99. blasint n = *N;
  100. FLOAT alpha_r = Alpha[0];
  101. FLOAT alpha_i = Alpha[1];
  102. blasint incx = *INCX;
  103. blasint incy = *INCY;
  104. blasint lda = *LDA;
  105. FLOAT *buffer;
  106. #ifdef SMP
  107. int nthreads;
  108. #endif
  109. blasint info;
  110. PRINT_DEBUG_NAME;
  111. info = 0;
  112. if (lda < MAX(1,m)) info = 9;
  113. if (incy == 0) info = 7;
  114. if (incx == 0) info = 5;
  115. if (n < 0) info = 2;
  116. if (m < 0) info = 1;
  117. if (info){
  118. BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
  119. return;
  120. }
  121. #else
  122. void CNAME(enum CBLAS_ORDER order,
  123. blasint m, blasint n,
  124. FLOAT *Alpha,
  125. FLOAT *x, blasint incx,
  126. FLOAT *y, blasint incy,
  127. FLOAT *a, blasint lda) {
  128. FLOAT alpha_r = Alpha[0];
  129. FLOAT alpha_i = Alpha[1];
  130. FLOAT *buffer;
  131. blasint info, t;
  132. #ifdef SMP
  133. int nthreads;
  134. #endif
  135. PRINT_DEBUG_CNAME;
  136. info = 0;
  137. if (order == CblasColMajor) {
  138. info = -1;
  139. if (lda < MAX(1,m)) info = 9;
  140. if (incy == 0) info = 7;
  141. if (incx == 0) info = 5;
  142. if (n < 0) info = 2;
  143. if (m < 0) info = 1;
  144. }
  145. if (order == CblasRowMajor) {
  146. info = -1;
  147. t = n;
  148. n = m;
  149. m = t;
  150. t = incx;
  151. incx = incy;
  152. incy = t;
  153. buffer = x;
  154. x = y;
  155. y = buffer;
  156. if (lda < MAX(1,m)) info = 9;
  157. if (incy == 0) info = 7;
  158. if (incx == 0) info = 5;
  159. if (n < 0) info = 2;
  160. if (m < 0) info = 1;
  161. }
  162. if (info >= 0) {
  163. BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
  164. return;
  165. }
  166. #endif
  167. /* Quick return if possible. */
  168. if (m == 0 || n == 0) return;
  169. if ((alpha_r == 0.) && (alpha_i == 0.)) return;
  170. IDEBUG_START;
  171. FUNCTION_PROFILE_START();
  172. if (incy < 0) y -= (n - 1) * incy * 2;
  173. if (incx < 0) x -= (m - 1) * incx * 2;
  174. buffer = (FLOAT *)blas_memory_alloc(1);
  175. #ifdef SMP
  176. nthreads = num_cpu_avail(2);
  177. if (nthreads == 1) {
  178. #endif
  179. #if !defined(CBLAS) || !defined(CONJ)
  180. GER(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
  181. #else
  182. if (order == CblasColMajor) {
  183. GER(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
  184. } else {
  185. GERV(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
  186. }
  187. #endif
  188. #ifdef SMP
  189. } else {
  190. #if !defined(CBLAS) || !defined(CONJ)
  191. GER_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
  192. #else
  193. if (order == CblasColMajor) {
  194. GER_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
  195. } else {
  196. GERV_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
  197. }
  198. #endif
  199. }
  200. #endif
  201. blas_memory_free(buffer);
  202. FUNCTION_PROFILE_END(4, m * n + m + n, 2 * m * n);
  203. IDEBUG_END;
  204. return;
  205. }

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.