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 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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) * GEMM_UNROLL_N;
  67. if (blocking > GEMM_Q) blocking = GEMM_Q;
  68. #ifdef POWER8
  69. if (blocking <= GEMM_UNROLL_N) {
  70. info = GETF2(args, NULL, range_n, sa, sb, 0);
  71. return info;
  72. }
  73. #else
  74. if (blocking <= GEMM_UNROLL_N * 2) {
  75. info = GETF2(args, NULL, range_n, sa, sb, 0);
  76. return info;
  77. }
  78. #endif
  79. sbb = (FLOAT *)((((BLASULONG)(sb + blocking * blocking * COMPSIZE) + GEMM_ALIGN) & ~GEMM_ALIGN) + GEMM_OFFSET_B);
  80. info = 0;
  81. for (j = 0; j < mn; j += blocking) {
  82. jb = mn - j;
  83. if (jb > blocking) jb = blocking;
  84. offsetA = a + j * lda * COMPSIZE;
  85. // offsetB = a + (j + jb) * lda * COMPSIZE;
  86. range_N[0] = offset + j;
  87. range_N[1] = offset + j + jb;
  88. iinfo = CNAME(args, NULL, range_N, sa, sb, 0);
  89. if (iinfo && !info) info = iinfo + j;
  90. if (j + jb < n) {
  91. TRSM_ILTCOPY(jb, jb, offsetA + j * COMPSIZE, lda, 0, sb);
  92. for (js = j + jb; js < n; js += REAL_GEMM_R){
  93. jmin = n - js;
  94. if (jmin > REAL_GEMM_R) jmin = REAL_GEMM_R;
  95. for (jjs = js; jjs < js + jmin; jjs += GEMM_UNROLL_N){
  96. min_jj = js + jmin - jjs;
  97. if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
  98. #if 1
  99. LASWP_PLUS(min_jj, j + offset + 1, j + jb + offset, ZERO,
  100. #ifdef COMPLEX
  101. ZERO,
  102. #endif
  103. a + (- offset + jjs * lda) * COMPSIZE, lda, NULL, 0 , ipiv, 1);
  104. GEMM_ONCOPY (jb, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sbb + jb * (jjs - js) * COMPSIZE);
  105. #else
  106. LASWP_NCOPY(min_jj, j + offset + 1, j + jb + offset,
  107. a + (- offset + jjs * lda) * COMPSIZE, lda, ipiv, sbb + jb * (jjs - js) * COMPSIZE);
  108. #endif
  109. for (jc = 0; jc < jb; jc += GEMM_P) {
  110. jcmin = jb - jc;
  111. if (jcmin > GEMM_P) jcmin = GEMM_P;
  112. TRSM_KERNEL_LT(jcmin, min_jj, jb, dm1,
  113. #ifdef COMPLEX
  114. ZERO,
  115. #endif
  116. sb + jb * jc * COMPSIZE,
  117. sbb + jb * (jjs - js) * COMPSIZE,
  118. a + (j + jc + jjs * lda) * COMPSIZE, lda, jc);
  119. }
  120. }
  121. for (is = j + jb; is < m; is += GEMM_P){
  122. imin = m - is;
  123. if (imin > GEMM_P) imin = GEMM_P;
  124. GEMM_ITCOPY (jb, imin, offsetA + is * COMPSIZE, lda, sa);
  125. GEMM_KERNEL_N(imin, jmin, jb, dm1,
  126. #ifdef COMPLEX
  127. ZERO,
  128. #endif
  129. sa, sbb, a + (is + js * lda) * COMPSIZE, lda);
  130. }
  131. }
  132. }
  133. }
  134. for (j = 0; j < mn; j += jb) {
  135. jb = MIN(mn - j, blocking);
  136. LASWP_PLUS(jb, j + jb + offset + 1, mn + offset, ZERO,
  137. #ifdef COMPLEX
  138. ZERO,
  139. #endif
  140. a - (offset - j * lda) * COMPSIZE, lda, NULL, 0 , ipiv, 1);
  141. }
  142. return info;
  143. }