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_parallel.c 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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. #ifndef USE_SIMPLE_THREADED_LEVEL3
  41. static FLOAT dm1 = -1.;
  42. #ifndef KERNEL_FUNC
  43. #ifndef LOWER
  44. #define KERNEL_FUNC SYRK_KERNEL_U
  45. #else
  46. #define KERNEL_FUNC SYRK_KERNEL_L
  47. #endif
  48. #endif
  49. #ifndef LOWER
  50. #ifndef COMPLEX
  51. #define TRSM_KERNEL TRSM_KERNEL_LT
  52. #else
  53. #define TRSM_KERNEL TRSM_KERNEL_LC
  54. #endif
  55. #else
  56. #ifndef COMPLEX
  57. #define TRSM_KERNEL TRSM_KERNEL_RN
  58. #else
  59. #define TRSM_KERNEL TRSM_KERNEL_RR
  60. #endif
  61. #endif
  62. #ifndef CACHE_LINE_SIZE
  63. #define CACHE_LINE_SIZE 8
  64. #endif
  65. #ifndef DIVIDE_RATE
  66. #define DIVIDE_RATE 2
  67. #endif
  68. #ifndef SWITCH_RATIO
  69. #define SWITCH_RATIO 2
  70. #endif
  71. #ifndef LOWER
  72. #define TRANS
  73. #endif
  74. #ifndef SYRK_LOCAL
  75. #if !defined(LOWER) && !defined(TRANS)
  76. #define SYRK_LOCAL SYRK_UN
  77. #elif !defined(LOWER) && defined(TRANS)
  78. #define SYRK_LOCAL SYRK_UT
  79. #elif defined(LOWER) && !defined(TRANS)
  80. #define SYRK_LOCAL SYRK_LN
  81. #else
  82. #define SYRK_LOCAL SYRK_LT
  83. #endif
  84. #endif
  85. typedef struct {
  86. volatile BLASLONG working[MAX_CPU_NUMBER][CACHE_LINE_SIZE * DIVIDE_RATE];
  87. } job_t;
  88. #ifndef KERNEL_OPERATION
  89. #ifndef COMPLEX
  90. #define KERNEL_OPERATION(M, N, K, ALPHA, SA, SB, C, LDC, X, Y) \
  91. KERNEL_FUNC(M, N, K, ALPHA[0], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y))
  92. #else
  93. #define KERNEL_OPERATION(M, N, K, ALPHA, SA, SB, C, LDC, X, Y) \
  94. KERNEL_FUNC(M, N, K, ALPHA[0], ALPHA[1], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y))
  95. #endif
  96. #endif
  97. #ifndef ICOPY_OPERATION
  98. #ifndef TRANS
  99. #define ICOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_ITCOPY(M, N, (FLOAT *)(A) + ((Y) + (X) * (LDA)) * COMPSIZE, LDA, BUFFER);
  100. #else
  101. #define ICOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_INCOPY(M, N, (FLOAT *)(A) + ((X) + (Y) * (LDA)) * COMPSIZE, LDA, BUFFER);
  102. #endif
  103. #endif
  104. #ifndef OCOPY_OPERATION
  105. #ifdef TRANS
  106. #define OCOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_ONCOPY(M, N, (FLOAT *)(A) + ((X) + (Y) * (LDA)) * COMPSIZE, LDA, BUFFER);
  107. #else
  108. #define OCOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_OTCOPY(M, N, (FLOAT *)(A) + ((Y) + (X) * (LDA)) * COMPSIZE, LDA, BUFFER);
  109. #endif
  110. #endif
  111. #ifndef S
  112. #define S args -> a
  113. #endif
  114. #ifndef A
  115. #define A args -> b
  116. #endif
  117. #ifndef C
  118. #define C args -> c
  119. #endif
  120. #ifndef LDA
  121. #define LDA args -> lda
  122. #endif
  123. #ifndef N
  124. #define N args -> m
  125. #endif
  126. #ifndef K
  127. #define K args -> k
  128. #endif
  129. static int inner_thread(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG mypos){
  130. FLOAT *buffer[DIVIDE_RATE];
  131. BLASLONG k, lda;
  132. BLASLONG m_from, m_to;
  133. FLOAT *alpha;
  134. FLOAT *a, *c;
  135. job_t *job = (job_t *)args -> common;
  136. BLASLONG xxx, bufferside;
  137. BLASLONG jjs, min_jj;
  138. BLASLONG is, min_i, div_n;
  139. BLASLONG i, current;
  140. k = K;
  141. a = (FLOAT *)A;
  142. c = (FLOAT *)C;
  143. lda = LDA;
  144. alpha = (FLOAT *)args -> alpha;
  145. m_from = range_n[mypos + 0];
  146. m_to = range_n[mypos + 1];
  147. #if 0
  148. fprintf(stderr, "Thread[%ld] m_from : %ld m_to : %ld\n", mypos, m_from, m_to);
  149. #endif
  150. div_n = ((m_to - m_from + DIVIDE_RATE - 1) / DIVIDE_RATE + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
  151. buffer[0] = (FLOAT *)((((long)(sb + k * k * COMPSIZE) + GEMM_ALIGN) & ~GEMM_ALIGN) + GEMM_OFFSET_B);
  152. for (i = 1; i < DIVIDE_RATE; i++) {
  153. buffer[i] = buffer[i - 1] + GEMM_Q * div_n * COMPSIZE;
  154. }
  155. #ifndef LOWER
  156. TRSM_IUNCOPY(k, k, (FLOAT *)S, lda, 0, sb);
  157. #else
  158. TRSM_OLTCOPY(k, k, (FLOAT *)S, lda, 0, sb);
  159. #endif
  160. for (xxx = m_from, bufferside = 0; xxx < m_to; xxx += div_n, bufferside ++) {
  161. for(jjs = xxx; jjs < MIN(m_to, xxx + div_n); jjs += min_jj){
  162. min_jj = MIN(m_to, xxx + div_n) - jjs;
  163. #ifndef LOWER
  164. if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
  165. #else
  166. if (min_jj > GEMM_P) min_jj = GEMM_P;
  167. #endif
  168. #ifndef LOWER
  169. OCOPY_OPERATION (k, min_jj, a, lda, 0, jjs, buffer[bufferside] + k * (jjs - xxx) * COMPSIZE);
  170. TRSM_KERNEL (k, min_jj, k, dm1,
  171. #ifdef COMPLEX
  172. ZERO,
  173. #endif
  174. sb,
  175. buffer[bufferside] + k * (jjs - xxx) * COMPSIZE,
  176. a + jjs * lda * COMPSIZE, lda, 0);
  177. #else
  178. ICOPY_OPERATION (k, min_jj, a, lda, 0, jjs, buffer[bufferside] + k * (jjs - xxx) * COMPSIZE);
  179. TRSM_KERNEL (min_jj, k, k, dm1,
  180. #ifdef COMPLEX
  181. ZERO,
  182. #endif
  183. buffer[bufferside] + k * (jjs - xxx) * COMPSIZE,
  184. sb,
  185. a + jjs * COMPSIZE, lda, 0);
  186. #endif
  187. }
  188. #ifndef LOWER
  189. for (i = 0; i <= mypos; i++)
  190. job[mypos].working[i][CACHE_LINE_SIZE * bufferside] = (BLASLONG)buffer[bufferside];
  191. #else
  192. for (i = mypos; i < args -> nthreads; i++)
  193. job[mypos].working[i][CACHE_LINE_SIZE * bufferside] = (BLASLONG)buffer[bufferside];
  194. #endif
  195. WMB;
  196. }
  197. min_i = m_to - m_from;
  198. if (min_i >= GEMM_P * 2) {
  199. min_i = GEMM_P;
  200. } else
  201. if (min_i > GEMM_P) {
  202. min_i = ((min_i + 1) / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
  203. }
  204. #ifndef LOWER
  205. ICOPY_OPERATION(k, min_i, a, lda, 0, m_from, sa);
  206. #else
  207. OCOPY_OPERATION(k, min_i, a, lda, 0, m_from, sa);
  208. #endif
  209. current = mypos;
  210. #ifndef LOWER
  211. while (current < args -> nthreads)
  212. #else
  213. while (current >= 0)
  214. #endif
  215. {
  216. div_n = ((range_n[current + 1] - range_n[current] + DIVIDE_RATE - 1) / DIVIDE_RATE + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
  217. for (xxx = range_n[current], bufferside = 0; xxx < range_n[current + 1]; xxx += div_n, bufferside ++) {
  218. /* thread has to wait */
  219. if (current != mypos) while(job[current].working[mypos][CACHE_LINE_SIZE * bufferside] == 0) {YIELDING;};
  220. KERNEL_OPERATION(min_i, MIN(range_n[current + 1] - xxx, div_n), k, alpha,
  221. sa, (FLOAT *)job[current].working[mypos][CACHE_LINE_SIZE * bufferside],
  222. c, lda, m_from, xxx);
  223. if (m_from + min_i >= m_to) {
  224. job[current].working[mypos][CACHE_LINE_SIZE * bufferside] &= 0;
  225. WMB;
  226. }
  227. }
  228. #ifndef LOWER
  229. current ++;
  230. #else
  231. current --;
  232. #endif
  233. }
  234. for(is = m_from + min_i; is < m_to; is += min_i){
  235. min_i = m_to - is;
  236. if (min_i >= GEMM_P * 2) {
  237. min_i = GEMM_P;
  238. } else
  239. if (min_i > GEMM_P) {
  240. min_i = ((min_i + 1) / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
  241. }
  242. #ifndef LOWER
  243. ICOPY_OPERATION(k, min_i, a, lda, 0, is, sa);
  244. #else
  245. OCOPY_OPERATION(k, min_i, a, lda, 0, is, sa);
  246. #endif
  247. current = mypos;
  248. #ifndef LOWER
  249. while (current < args -> nthreads)
  250. #else
  251. while (current >= 0)
  252. #endif
  253. {
  254. div_n = ((range_n[current + 1] - range_n[current] + DIVIDE_RATE - 1) / DIVIDE_RATE + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
  255. for (xxx = range_n[current], bufferside = 0; xxx < range_n[current + 1]; xxx += div_n, bufferside ++) {
  256. KERNEL_OPERATION(min_i, MIN(range_n[current + 1] - xxx, div_n), k, alpha,
  257. sa, (FLOAT *)job[current].working[mypos][CACHE_LINE_SIZE * bufferside],
  258. c, lda, is, xxx);
  259. if (is + min_i >= m_to) {
  260. job[current].working[mypos][CACHE_LINE_SIZE * bufferside] &= 0;
  261. WMB;
  262. }
  263. }
  264. #ifndef LOWER
  265. current ++;
  266. #else
  267. current --;
  268. #endif
  269. }
  270. }
  271. for (i = 0; i < args -> nthreads; i++) {
  272. if (i != mypos) {
  273. for (xxx = 0; xxx < DIVIDE_RATE; xxx++) {
  274. while (job[mypos].working[i][CACHE_LINE_SIZE * xxx] ) {YIELDING;};
  275. }
  276. }
  277. }
  278. return 0;
  279. }
  280. static int thread_driver(blas_arg_t *args, FLOAT *sa, FLOAT *sb){
  281. blas_arg_t newarg;
  282. job_t job[MAX_CPU_NUMBER];
  283. blas_queue_t queue[MAX_CPU_NUMBER];
  284. BLASLONG range[MAX_CPU_NUMBER + 100];
  285. BLASLONG num_cpu;
  286. BLASLONG nthreads = args -> nthreads;
  287. BLASLONG width, i, j, k;
  288. BLASLONG n, n_from, n_to;
  289. int mode, mask;
  290. double dnum;
  291. #ifndef COMPLEX
  292. #ifdef XDOUBLE
  293. mode = BLAS_XDOUBLE | BLAS_REAL;
  294. mask = MAX(QGEMM_UNROLL_M, QGEMM_UNROLL_N) - 1;
  295. #elif defined(DOUBLE)
  296. mode = BLAS_DOUBLE | BLAS_REAL;
  297. mask = MAX(DGEMM_UNROLL_M, DGEMM_UNROLL_N) - 1;
  298. #else
  299. mode = BLAS_SINGLE | BLAS_REAL;
  300. mask = MAX(SGEMM_UNROLL_M, SGEMM_UNROLL_N) - 1;
  301. #endif
  302. #else
  303. #ifdef XDOUBLE
  304. mode = BLAS_XDOUBLE | BLAS_COMPLEX;
  305. mask = MAX(XGEMM_UNROLL_M, XGEMM_UNROLL_N) - 1;
  306. #elif defined(DOUBLE)
  307. mode = BLAS_DOUBLE | BLAS_COMPLEX;
  308. mask = MAX(ZGEMM_UNROLL_M, ZGEMM_UNROLL_N) - 1;
  309. #else
  310. mode = BLAS_SINGLE | BLAS_COMPLEX;
  311. mask = MAX(CGEMM_UNROLL_M, CGEMM_UNROLL_N) - 1;
  312. #endif
  313. #endif
  314. newarg.m = args -> m;
  315. newarg.k = args -> k;
  316. newarg.a = args -> a;
  317. newarg.b = args -> b;
  318. newarg.c = args -> c;
  319. newarg.lda = args -> lda;
  320. newarg.alpha = args -> alpha;
  321. newarg.common = (void *)job;
  322. n_from = 0;
  323. n_to = args -> m;
  324. #ifndef LOWER
  325. range[MAX_CPU_NUMBER] = n_to - n_from;
  326. range[0] = 0;
  327. num_cpu = 0;
  328. i = 0;
  329. n = n_to - n_from;
  330. dnum = (double)n * (double)n /(double)nthreads;
  331. while (i < n){
  332. if (nthreads - num_cpu > 1) {
  333. double di = (double)i;
  334. width = (((BLASLONG)(sqrt(di * di + dnum) - di) + mask) & ~mask);
  335. if (num_cpu == 0) width = n - ((n - width) & ~mask);
  336. if ((width > n - i) || (width < mask)) width = n - i;
  337. } else {
  338. width = n - i;
  339. }
  340. range[MAX_CPU_NUMBER - num_cpu - 1] = range[MAX_CPU_NUMBER - num_cpu] - width;
  341. queue[num_cpu].mode = mode;
  342. queue[num_cpu].routine = inner_thread;
  343. queue[num_cpu].args = &newarg;
  344. queue[num_cpu].range_m = NULL;
  345. queue[num_cpu].sa = NULL;
  346. queue[num_cpu].sb = NULL;
  347. queue[num_cpu].next = &queue[num_cpu + 1];
  348. num_cpu ++;
  349. i += width;
  350. }
  351. for (i = 0; i < num_cpu; i ++) queue[i].range_n = &range[MAX_CPU_NUMBER - num_cpu];
  352. #else
  353. range[0] = 0;
  354. num_cpu = 0;
  355. i = 0;
  356. n = n_to - n_from;
  357. dnum = (double)n * (double)n /(double)nthreads;
  358. while (i < n){
  359. if (nthreads - num_cpu > 1) {
  360. double di = (double)i;
  361. width = (((BLASLONG)(sqrt(di * di + dnum) - di) + mask) & ~mask);
  362. if ((width > n - i) || (width < mask)) width = n - i;
  363. } else {
  364. width = n - i;
  365. }
  366. range[num_cpu + 1] = range[num_cpu] + width;
  367. queue[num_cpu].mode = mode;
  368. queue[num_cpu].routine = inner_thread;
  369. queue[num_cpu].args = &newarg;
  370. queue[num_cpu].range_m = NULL;
  371. queue[num_cpu].range_n = range;
  372. queue[num_cpu].sa = NULL;
  373. queue[num_cpu].sb = NULL;
  374. queue[num_cpu].next = &queue[num_cpu + 1];
  375. num_cpu ++;
  376. i += width;
  377. }
  378. #endif
  379. newarg.nthreads = num_cpu;
  380. if (num_cpu) {
  381. for (j = 0; j < num_cpu; j++) {
  382. for (i = 0; i < num_cpu; i++) {
  383. for (k = 0; k < DIVIDE_RATE; k++) {
  384. job[j].working[i][CACHE_LINE_SIZE * k] = 0;
  385. }
  386. }
  387. }
  388. queue[0].sa = sa;
  389. queue[0].sb = sb;
  390. queue[num_cpu - 1].next = NULL;
  391. exec_blas(num_cpu, queue);
  392. }
  393. return 0;
  394. }
  395. #endif
  396. blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG myid) {
  397. BLASLONG n, bk, i, blocking, lda;
  398. BLASLONG info;
  399. int mode;
  400. blas_arg_t newarg;
  401. FLOAT *a;
  402. FLOAT alpha[2] = { -ONE, ZERO};
  403. #ifndef COMPLEX
  404. #ifdef XDOUBLE
  405. mode = BLAS_XDOUBLE | BLAS_REAL;
  406. #elif defined(DOUBLE)
  407. mode = BLAS_DOUBLE | BLAS_REAL;
  408. #else
  409. mode = BLAS_SINGLE | BLAS_REAL;
  410. #endif
  411. #else
  412. #ifdef XDOUBLE
  413. mode = BLAS_XDOUBLE | BLAS_COMPLEX;
  414. #elif defined(DOUBLE)
  415. mode = BLAS_DOUBLE | BLAS_COMPLEX;
  416. #else
  417. mode = BLAS_SINGLE | BLAS_COMPLEX;
  418. #endif
  419. #endif
  420. if (args -> nthreads == 1) {
  421. #ifndef LOWER
  422. info = POTRF_U_SINGLE(args, NULL, NULL, sa, sb, 0);
  423. #else
  424. info = POTRF_L_SINGLE(args, NULL, NULL, sa, sb, 0);
  425. #endif
  426. return info;
  427. }
  428. n = args -> n;
  429. a = (FLOAT *)args -> a;
  430. lda = args -> lda;
  431. if (range_n) n = range_n[1] - range_n[0];
  432. if (n <= GEMM_UNROLL_N * 2) {
  433. #ifndef LOWER
  434. info = POTRF_U_SINGLE(args, NULL, range_n, sa, sb, 0);
  435. #else
  436. info = POTRF_L_SINGLE(args, NULL, range_n, sa, sb, 0);
  437. #endif
  438. return info;
  439. }
  440. newarg.lda = lda;
  441. newarg.ldb = lda;
  442. newarg.ldc = lda;
  443. newarg.alpha = alpha;
  444. newarg.beta = NULL;
  445. newarg.nthreads = args -> nthreads;
  446. blocking = (n / 2 + GEMM_UNROLL_N - 1) & ~(GEMM_UNROLL_N - 1);
  447. if (blocking > GEMM_Q) blocking = GEMM_Q;
  448. for (i = 0; i < n; i += blocking) {
  449. bk = n - i;
  450. if (bk > blocking) bk = blocking;
  451. newarg.m = bk;
  452. newarg.n = bk;
  453. newarg.a = a + (i + i * lda) * COMPSIZE;
  454. info = CNAME(&newarg, NULL, NULL, sa, sb, 0);
  455. if (info) return info + i;
  456. if (n - i - bk > 0) {
  457. #ifndef USE_SIMPLE_THREADED_LEVEL3
  458. newarg.m = n - i - bk;
  459. newarg.k = bk;
  460. #ifndef LOWER
  461. newarg.b = a + ( i + (i + bk) * lda) * COMPSIZE;
  462. #else
  463. newarg.b = a + ((i + bk) + i * lda) * COMPSIZE;
  464. #endif
  465. newarg.c = a + ((i + bk) + (i + bk) * lda) * COMPSIZE;
  466. thread_driver(&newarg, sa, sb);
  467. #else
  468. #ifndef LOWER
  469. newarg.m = bk;
  470. newarg.n = n - i - bk;
  471. newarg.a = a + (i + i * lda) * COMPSIZE;
  472. newarg.b = a + (i + (i + bk) * lda) * COMPSIZE;
  473. gemm_thread_n(mode | BLAS_TRANSA_T,
  474. &newarg, NULL, NULL, (void *)TRSM_LCUN, sa, sb, args -> nthreads);
  475. newarg.n = n - i - bk;
  476. newarg.k = bk;
  477. newarg.a = a + ( i + (i + bk) * lda) * COMPSIZE;
  478. newarg.c = a + ((i + bk) + (i + bk) * lda) * COMPSIZE;
  479. #if 0
  480. HERK_THREAD_UC(&newarg, NULL, NULL, sa, sb, 0);
  481. #else
  482. syrk_thread(mode | BLAS_TRANSA_N | BLAS_TRANSB_T,
  483. &newarg, NULL, NULL, (void *)HERK_UC, sa, sb, args -> nthreads);
  484. #endif
  485. #else
  486. newarg.m = n - i - bk;
  487. newarg.n = bk;
  488. newarg.a = a + (i + i * lda) * COMPSIZE;
  489. newarg.b = a + (i + bk + i * lda) * COMPSIZE;
  490. gemm_thread_m(mode | BLAS_RSIDE | BLAS_TRANSA_T | BLAS_UPLO,
  491. &newarg, NULL, NULL, (void *)TRSM_RCLN, sa, sb, args -> nthreads);
  492. newarg.n = n - i - bk;
  493. newarg.k = bk;
  494. newarg.a = a + (i + bk + i * lda) * COMPSIZE;
  495. newarg.c = a + (i + bk + (i + bk) * lda) * COMPSIZE;
  496. #if 0
  497. HERK_THREAD_LN(&newarg, NULL, NULL, sa, sb, 0);
  498. #else
  499. syrk_thread(mode | BLAS_TRANSA_N | BLAS_TRANSB_T | BLAS_UPLO,
  500. &newarg, NULL, NULL, (void *)HERK_LN, sa, sb, args -> nthreads);
  501. #endif
  502. #endif
  503. #endif
  504. }
  505. }
  506. return 0;
  507. }