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_L_single.c 6.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_RN
  43. #else
  44. #define TRSM_KERNEL TRSM_KERNEL_RR
  45. #undef SYRK_KERNEL_L
  46. #ifdef XDOUBLE
  47. #define SYRK_KERNEL_L xherk_kernel_LN
  48. #elif defined(DOUBLE)
  49. #define SYRK_KERNEL_L zherk_kernel_LN
  50. #else
  51. #define SYRK_KERNEL_L cherk_kernel_LN
  52. #endif
  53. #endif
  54. #if 0
  55. #undef GEMM_P
  56. #undef GEMM_Q
  57. #undef GEMM_R
  58. #define GEMM_P 128
  59. #define GEMM_Q 128
  60. #define GEMM_R 4000
  61. #endif
  62. #define GEMM_PQ MAX(GEMM_P, GEMM_Q)
  63. //leave some space for GEMM_ALIGN in sb2
  64. #define REAL_GEMM_R (GEMM_R - 2*GEMM_PQ)
  65. #if 0
  66. #define SHARED_ARRAY
  67. #define SA aa
  68. #else
  69. #undef SHARED_ARRAY
  70. #define SA sa
  71. #endif
  72. blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG myid) {
  73. BLASLONG n, lda;
  74. FLOAT *a;
  75. BLASLONG info;
  76. BLASLONG bk, j, blocking;
  77. BLASLONG is, min_i;
  78. BLASLONG js, min_j;
  79. BLASLONG range_N[2];
  80. FLOAT *sb2 = (FLOAT *)((((BLASLONG)sb
  81. + GEMM_PQ * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)
  82. + GEMM_OFFSET_B);
  83. #ifdef SHARED_ARRAY
  84. FLOAT *aa;
  85. #endif
  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_L(args, NULL, range_n, sa, sb, 0);
  95. return info;
  96. }
  97. blocking = GEMM_Q;
  98. if (n <= 4 * GEMM_Q) blocking = n / 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_OLTCOPY(bk, bk, a + (j + j * lda) * COMPSIZE, lda, 0, sb);
  113. /* First tile */
  114. min_j = n - j - bk;
  115. if (min_j > REAL_GEMM_R) min_j = REAL_GEMM_R;
  116. for (is = j + bk; is < n; is += GEMM_P) {
  117. min_i = n - is;
  118. if (min_i > GEMM_P) min_i = GEMM_P;
  119. #ifdef SHARED_ARRAY
  120. if (is < j + bk + min_j) {
  121. aa = sb2 + bk * (is - j - bk) * COMPSIZE;
  122. } else {
  123. aa = sa;
  124. }
  125. GEMM_ITCOPY(bk, min_i, a + (is + j * lda) * COMPSIZE, lda, aa);
  126. TRSM_KERNEL(min_i, bk, bk, dm1,
  127. #ifdef COMPLEX
  128. ZERO,
  129. #endif
  130. aa,
  131. sb,
  132. a + (is + j * lda) * COMPSIZE, lda, 0);
  133. SYRK_KERNEL_L(min_i, min_j, bk, dm1,
  134. aa,
  135. sb2,
  136. a + (is + (j + bk) * lda) * COMPSIZE, lda,
  137. is - j - bk);
  138. #else
  139. GEMM_ITCOPY(bk, min_i, a + (is + j * lda) * COMPSIZE, lda, sa);
  140. TRSM_KERNEL(min_i, bk, bk, dm1,
  141. #ifdef COMPLEX
  142. ZERO,
  143. #endif
  144. sa,
  145. sb,
  146. a + (is + j * lda) * COMPSIZE, lda, 0);
  147. if (is < j + bk + min_j) {
  148. GEMM_OTCOPY(bk, min_i, a + (is + j * lda) * COMPSIZE, lda, sb2 + bk * (is - j - bk) * COMPSIZE);
  149. }
  150. SYRK_KERNEL_L(min_i, min_j, bk, dm1,
  151. sa,
  152. sb2,
  153. a + (is + (j + bk) * lda) * COMPSIZE, lda,
  154. is - j - bk);
  155. #endif
  156. }
  157. for(js = j + bk + min_j; js < n; js += REAL_GEMM_R){
  158. min_j = n - js;
  159. if (min_j > REAL_GEMM_R) min_j = REAL_GEMM_R;
  160. GEMM_OTCOPY(bk, min_j, a + (js + j * lda) * COMPSIZE, lda, sb2);
  161. for (is = js; is < n; is += GEMM_P) {
  162. min_i = n - is;
  163. if (min_i > GEMM_P) min_i = GEMM_P;
  164. #ifdef SHARED_ARRAY
  165. if (is + min_i < js + min_j) {
  166. aa = sb2 + bk * (is - js) * COMPSIZE;
  167. } else {
  168. GEMM_ITCOPY(bk, min_i, a + (is + j * lda) * COMPSIZE, lda, sa);
  169. aa = sa;
  170. }
  171. SYRK_KERNEL_L(min_i, min_j, bk, dm1,
  172. aa,
  173. sb2,
  174. a + (is + js * lda) * COMPSIZE, lda,
  175. is - js);
  176. #else
  177. GEMM_ITCOPY(bk, min_i, a + (is + j * lda) * COMPSIZE, lda, sa);
  178. SYRK_KERNEL_L(min_i, min_j, bk, dm1,
  179. sa,
  180. sb2,
  181. a + (is + js * lda) * COMPSIZE, lda,
  182. is - js);
  183. #endif
  184. }
  185. }
  186. }
  187. }
  188. return 0;
  189. }