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.

potrf_U_single.c 5.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. static FLOAT dm1 = -1.;
  41. #ifndef COMPLEX
  42. #define TRSM_KERNEL TRSM_KERNEL_LT
  43. #else
  44. #define TRSM_KERNEL TRSM_KERNEL_LC
  45. #undef SYRK_KERNEL_U
  46. #ifdef XDOUBLE
  47. #define SYRK_KERNEL_U xherk_kernel_UC
  48. #elif defined(DOUBLE)
  49. #define SYRK_KERNEL_U zherk_kernel_UC
  50. #else
  51. #define SYRK_KERNEL_U cherk_kernel_UC
  52. #endif
  53. #endif
  54. #if 0
  55. #undef GEMM_P
  56. #undef GEMM_Q
  57. #undef GEMM_R
  58. #define GEMM_P 8
  59. #define GEMM_Q 20
  60. #define GEMM_R 64
  61. #endif
  62. #define GEMM_PQ MAX(GEMM_P, GEMM_Q)
  63. #define REAL_GEMM_R (GEMM_R - GEMM_PQ)
  64. #if 0
  65. #define SHARED_ARRAY
  66. #define SA aa
  67. #else
  68. #undef SHARED_ARRAY
  69. #define SA sa
  70. #endif
  71. blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG myid) {
  72. BLASLONG n, lda;
  73. FLOAT *a;
  74. BLASLONG info;
  75. BLASLONG bk, blocking;
  76. BLASLONG is, min_i;
  77. BLASLONG jjs, min_jj;
  78. BLASLONG range_N[2];
  79. BLASLONG j, js, min_j;
  80. #ifdef SHARED_ARRAY
  81. FLOAT *aa;
  82. #endif
  83. FLOAT *sb2 = (FLOAT *)((((BLASLONG)sb
  84. + GEMM_PQ * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)
  85. + GEMM_OFFSET_B);
  86. n = args -> n;
  87. a = (FLOAT *)args -> a;
  88. lda = args -> lda;
  89. if (range_n) {
  90. n = range_n[1] - range_n[0];
  91. a += range_n[0] * (lda + 1) * COMPSIZE;
  92. }
  93. if (n <= DTB_ENTRIES / 2) {
  94. info = POTF2_U(args, NULL, range_n, sa, sb, 0);
  95. return info;
  96. }
  97. blocking = GEMM_Q;
  98. if (n <= 4 * GEMM_Q) blocking = (n + 3) / 4;
  99. for (j = 0; j < n; j += blocking) {
  100. bk = n - j;
  101. if (bk > blocking) bk = blocking;
  102. if (!range_n) {
  103. range_N[0] = j;
  104. range_N[1] = j + bk;
  105. } else {
  106. range_N[0] = range_n[0] + j;
  107. range_N[1] = range_n[0] + j + bk;
  108. }
  109. info = CNAME(args, NULL, range_N, sa, sb, 0);
  110. if (info) return info + j;
  111. if (n - j - bk > 0) {
  112. TRSM_IUNCOPY(bk, bk, a + (j + j * lda) * COMPSIZE, lda, 0, sb);
  113. for(js = j + bk; js < n; js += REAL_GEMM_R) {
  114. min_j = n - js;
  115. if (min_j > REAL_GEMM_R) min_j = REAL_GEMM_R;
  116. for(jjs = js; jjs < js + min_j; jjs += GEMM_UNROLL_N){
  117. min_jj = min_j + js - jjs;
  118. if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
  119. GEMM_ONCOPY(bk, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sb2 + bk * (jjs - js) * COMPSIZE);
  120. for (is = 0; is < bk; is += GEMM_P) {
  121. min_i = bk - is;
  122. if (min_i > GEMM_P) min_i = GEMM_P;
  123. TRSM_KERNEL (min_i, min_jj, bk, dm1,
  124. #ifdef COMPLEX
  125. ZERO,
  126. #endif
  127. sb + bk * is * COMPSIZE,
  128. sb2 + bk * (jjs - js) * COMPSIZE,
  129. a + (j + is + jjs * lda) * COMPSIZE, lda, is);
  130. }
  131. }
  132. for (is = j + bk; is < js + min_j; is += min_i) {
  133. min_i = js + min_j - is;
  134. if (min_i >= GEMM_P * 2) {
  135. min_i = GEMM_P;
  136. } else
  137. if (min_i > GEMM_P) {
  138. min_i = ((min_i / 2 + GEMM_UNROLL_MN - 1)/GEMM_UNROLL_MN) * GEMM_UNROLL_MN;
  139. }
  140. #ifdef SHARED_ARRAY
  141. if ((is >= js) && (is + min_i <= js + min_j)) {
  142. aa = sb2 + bk * (is - js) * COMPSIZE;
  143. } else {
  144. GEMM_INCOPY(bk, min_i, a + (j + is * lda) * COMPSIZE, lda, sa);
  145. aa = sa;
  146. }
  147. #else
  148. GEMM_INCOPY(bk, min_i, a + (j + is * lda) * COMPSIZE, lda, sa);
  149. #endif
  150. SYRK_KERNEL_U(min_i, min_j, bk,
  151. dm1,
  152. SA, sb2,
  153. a + (is + js * lda) * COMPSIZE, lda,
  154. is - js);
  155. }
  156. }
  157. }
  158. }
  159. return 0;
  160. }