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.

getrf_single.c 5.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #define GEMM_PQ MAX(GEMM_P, GEMM_Q)
  41. #define REAL_GEMM_R (GEMM_R - GEMM_PQ)
  42. static FLOAT dm1 = -1.;
  43. blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG myid) {
  44. BLASLONG m, n, lda, offset;
  45. BLASLONG j, js, jmin, is, imin, jc, jcmin;
  46. BLASLONG jjs, min_jj;
  47. blasint *ipiv, iinfo, info;
  48. BLASLONG jb, mn, blocking;
  49. FLOAT *a, *offsetA, *offsetB;
  50. BLASLONG range_N[2];
  51. FLOAT *sbb;
  52. m = args -> m;
  53. n = args -> n;
  54. a = (FLOAT *)args -> a;
  55. lda = args -> lda;
  56. ipiv = (blasint *)args -> c;
  57. offset = 0;
  58. if (range_n) {
  59. m -= range_n[0];
  60. n = range_n[1] - range_n[0];
  61. offset = range_n[0];
  62. a += range_n[0] * (lda + 1) * COMPSIZE;
  63. }
  64. if (m <= 0 || n <= 0) return 0;
  65. mn = MIN(m, n);
  66. blocking = (mn / 2 + GEMM_UNROLL_N - 1) & ~(GEMM_UNROLL_N - 1);
  67. if (blocking > GEMM_Q) blocking = GEMM_Q;
  68. if (blocking <= GEMM_UNROLL_N * 2) {
  69. info = GETF2(args, NULL, range_n, sa, sb, 0);
  70. return info;
  71. }
  72. sbb = (FLOAT *)((((BLASULONG)(sb + blocking * blocking * COMPSIZE) + GEMM_ALIGN) & ~GEMM_ALIGN) + GEMM_OFFSET_B);
  73. info = 0;
  74. for (j = 0; j < mn; j += blocking) {
  75. jb = mn - j;
  76. if (jb > blocking) jb = blocking;
  77. offsetA = a + j * lda * COMPSIZE;
  78. offsetB = a + (j + jb) * lda * COMPSIZE;
  79. range_N[0] = offset + j;
  80. range_N[1] = offset + j + jb;
  81. iinfo = CNAME(args, NULL, range_N, sa, sb, 0);
  82. if (iinfo && !info) info = iinfo + j;
  83. if (j + jb < n) {
  84. TRSM_ILTCOPY(jb, jb, offsetA + j * COMPSIZE, lda, 0, sb);
  85. for (js = j + jb; js < n; js += REAL_GEMM_R){
  86. jmin = n - js;
  87. if (jmin > REAL_GEMM_R) jmin = REAL_GEMM_R;
  88. for (jjs = js; jjs < js + jmin; jjs += GEMM_UNROLL_N){
  89. min_jj = js + jmin - jjs;
  90. if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
  91. #if 1
  92. LASWP_PLUS(min_jj, j + offset + 1, j + jb + offset, ZERO,
  93. #ifdef COMPLEX
  94. ZERO,
  95. #endif
  96. a + (- offset + jjs * lda) * COMPSIZE, lda, NULL, 0 , ipiv, 1);
  97. GEMM_ONCOPY (jb, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sbb + jb * (jjs - js) * COMPSIZE);
  98. #else
  99. LASWP_NCOPY(min_jj, j + offset + 1, j + jb + offset,
  100. a + (- offset + jjs * lda) * COMPSIZE, lda, ipiv, sbb + jb * (jjs - js) * COMPSIZE);
  101. #endif
  102. for (jc = 0; jc < jb; jc += GEMM_P) {
  103. jcmin = jb - jc;
  104. if (jcmin > GEMM_P) jcmin = GEMM_P;
  105. TRSM_KERNEL_LT(jcmin, min_jj, jb, dm1,
  106. #ifdef COMPLEX
  107. ZERO,
  108. #endif
  109. sb + jb * jc * COMPSIZE,
  110. sbb + jb * (jjs - js) * COMPSIZE,
  111. a + (j + jc + jjs * lda) * COMPSIZE, lda, jc);
  112. }
  113. }
  114. for (is = j + jb; is < m; is += GEMM_P){
  115. imin = m - is;
  116. if (imin > GEMM_P) imin = GEMM_P;
  117. GEMM_ITCOPY (jb, imin, offsetA + is * COMPSIZE, lda, sa);
  118. GEMM_KERNEL_N(imin, jmin, jb, dm1,
  119. #ifdef COMPLEX
  120. ZERO,
  121. #endif
  122. sa, sbb, a + (is + js * lda) * COMPSIZE, lda);
  123. }
  124. }
  125. }
  126. }
  127. for (j = 0; j < mn; j += jb) {
  128. jb = MIN(mn - j, blocking);
  129. LASWP_PLUS(jb, j + jb + offset + 1, mn + offset, ZERO,
  130. #ifdef COMPLEX
  131. ZERO,
  132. #endif
  133. a - (offset - j * lda) * COMPSIZE, lda, NULL, 0 , ipiv, 1);
  134. }
  135. return info;
  136. }