Debian Codegraph @

3rdparty/dissection/src/Driver/C_Dsub.cpp

raw
1 /*! \file C_Dsub.cpp
2 \brief routines for substiution of off-diagonal matrix with strip
3 \author Atsushi Suzuki, Laboratoire Jacques-Louis Lions
4 \date Jun. 20th 2014
5 \date Jul. 12th 2015
6 \date Nov. 30th 2016
7 */
8
9 // This file is part of Dissection
10 //
11 // Dissection is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // Linking Dissection statically or dynamically with other modules is making
17 // a combined work based on Disssection. Thus, the terms and conditions of
18 // the GNU General Public License cover the whole combination.
19 //
20 // As a special exception, the copyright holders of Dissection give you
21 // permission to combine Dissection program with free software programs or
22 // libraries that are released under the GNU LGPL and with independent modules
23 // that communicate with Dissection solely through the Dissection-fortran
24 // interface. You may copy and distribute such a system following the terms of
25 // the GNU GPL for Dissection and the licenses of the other code concerned,
26 // provided that you include the source code of that other code when and as
27 // the GNU GPL requires distribution of source code and provided that you do
28 // not modify the Dissection-fortran interface.
29 //
30 // Note that people who make modified versions of Dissection are not obligated
31 // to grant this special exception for their modified versions; it is their
32 // choice whether to do so. The GNU General Public License gives permission to
33 // release a modified version without this exception; this exception also makes
34 // it possible to release a modified version which carries forward this
35 // exception. If you modify the Dissection-fortran interface, this exception
36 // does not apply to your modified version of Dissection, and you must remove
37 // this exception when you distribute your modified version.
38 //
39 // This exception is an additional permission under section 7 of the GNU
40 // General Public License, version 3 ("GPLv3")
41 //
42 // Dissection is distributed in the hope that it will be useful,
43 // but WITHOUT ANY WARRANTY; without even the implied warranty of
44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 // GNU General Public License for more details.
46 //
47 // You should have received a copy of the GNU General Public License
48 // along with Dissection. If not, see <http://www.gnu.org/licenses/>.
49 //
50
51 #include "Compiler/OptionLibrary.hpp"
52 #include <string>
53 #include "Compiler/blas.hpp"
54 #include "Driver/C_threads_tasks.hpp"
55 #include "Driver/C_Dsub.hpp"
56 #include "Compiler/DissectionIO.hpp"
57
58
59 template<typename T>
60 void C_Dsub_task_exec(void *arg_)
61 {
62 list<C_Dsub_task<T>* >*arg = (list<C_Dsub_task<T>* >*)arg_;
63 int k = 0;
64 for (typename list<C_Dsub_task<T>* >::const_iterator it = arg->begin();
65 it != arg->end(); ++it, k++) {
66 (*it)->func(*it);
67 }
68 }
69 template
70 void C_Dsub_task_exec<double>(void *arg_);
71
72 template
73 void C_Dsub_task_exec<quadruple>(void *arg_);
74
75 template
76 void C_Dsub_task_exec<complex<double> >(void *arg_);
77
78 template
79 void C_Dsub_task_exec<complex<quadruple> >(void *arg_);
80
81 template
82 void C_Dsub_task_exec<float>(void *arg_);
83
84 template
85 void C_Dsub_task_exec<complex<float> >(void *arg_);
86
87 // #define DEBUG_BLOCKSUBT
88
89 template<typename T>
90 void dsub_sym2sym_diag(C_Dsub_task<T> *arg)
91 {
92 const int ir_bgn = arg->ir_bgn;
93 const int ir_end = arg->ir_end;
94 const int ir_bgn_src = arg->ir_bgn_src;
95 T *dst_pt = arg->dst_mtrx->addrCoefBlock(arg->ir_block, arg->jc_block);
96 const int dst_row = arg->dst_mtrx->nrowBlock(arg->ir_block, arg->jc_block);
97 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
98 const int nrow = ir_end - ir_bgn;
99 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
100 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
101 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
102 const T none(-1.0);
103
104 if ((iblock0 + 1) == iblock1) {
105 const int ir_mid_src = src_mtrx->IndexBlock(iblock1); // iblock1 * SIZE_B1;
106 const int nrow0 = ir_mid_src - ir_bgn_src;
107 const int nrow1 = nrow - nrow0;
108 const int ir_mid = ir_bgn + nrow0;
109 {
110 int jj, j0, j1;
111 const int nrow_src = src_mtrx->nrowBlock(iblock0, iblock0);
112 T *src_pt = src_mtrx->addrCoefBlock(iblock0, iblock0);
113 for (j1 = nrow_src_offset * (nrow_src + 1),
114 j0 = ir_bgn * (dst_row + 1), //D(ir_bgn,ir_bgn)-(ir_mid,ir_mid)
115 jj = ir_bgn; jj < ir_mid; jj++, // driving index
116 j0 += dst_row, j1 += nrow_src) {
117 blas_axpy<T>(nrow0, none, src_pt + j1, 1, dst_pt + j0, 1);
118 }
119 }
120 {
121 int jj, j0, j1, j2, j3, j4;
122 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, iblock1);
123 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, iblock1);
124 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, iblock1);
125 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, iblock1);
126 for (j4 = 0, j3 = nrow_src_offset,
127 j0 = ir_bgn + ir_mid * dst_row, // (ir_bgn,ir_mid)-(ir_mid,ir_end)
128 j1 = ir_mid * (dst_row + 1), //D(ir_mid,ir_mid)-(ir_end,ir_end)
129 j2 = ir_mid + ir_bgn * dst_row, //T(ir_bgn,ir_mid)-(ir_mid,ir_end)
130 jj = ir_mid; jj < ir_end; jj++, // driving index
131 j0 += dst_row, j1 += dst_row, j2++,
132 j3 += nrow_src0, j4 += nrow_src1) {
133 blas_axpy<T>(nrow0, none, src_pt0 + j3, 1, dst_pt + j0, 1);
134 blas_axpy<T>(nrow1, none, src_pt1 + j4, 1, dst_pt + j1, 1);
135 // lower part of Schur complement matrix
136 // blas_axpy<T>(nrow0, none, src_pt0 + j3, 1, dst_pt + j2, dst_row);
137 }
138 }
139 }
140 else if (iblock0 == iblock1) {
141 int jj, j0, j1;
142 const int nrow_src = src_mtrx->nrowBlock(iblock0, iblock0);
143 T *src_pt = src_mtrx->addrCoefBlock(iblock0, iblock0);
144 for (j1 = nrow_src_offset * (nrow_src + 1),
145 j0 = ir_bgn * (dst_row + 1), //D(ir_bgn,ir_bgn)-(ir_end,ir_end)
146 jj = ir_bgn; jj < ir_end; jj++, // driving index
147 j0 += dst_row, j1 += nrow_src) {
148 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
149 } // loop : j0, j1
150 }
151 else {
152 diss_printf(arg->verbose, arg->fp,
153 "%s %d : bad block indices in diagonal %d %d\n",
154 __FILE__, __LINE__, iblock0, iblock1);
155 }
156 }
157
158 template
159 void dsub_sym2sym_diag<double>(C_Dsub_task<double> *arg);
160
161 template
162 void dsub_sym2sym_diag<quadruple>(C_Dsub_task<quadruple> *arg);
163
164 template
165 void dsub_sym2sym_diag<complex<double> >(C_Dsub_task<complex<double> > *arg);
166
167 template
168 void dsub_sym2sym_diag<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
169
170 template
171 void dsub_sym2sym_diag<float>(C_Dsub_task<float> *arg);
172
173 template
174 void dsub_sym2sym_diag<complex<float> >(C_Dsub_task<complex<float> > *arg);
175
176 // end of template function dsub_sym2sym_diag<T>
177
178 template<typename T>
179 void dsub_unsym2unsym_diag(C_Dsub_task<T> *arg)
180 {
181 const int ir_bgn = arg->ir_bgn;
182 const int ir_end = arg->ir_end;
183 const int ir_bgn_src = arg->ir_bgn_src;
184 T *dst_pt = arg->dst_mtrx->addrCoefBlock(arg->ir_block, arg->jc_block);
185 const int dst_row = arg->dst_mtrx->nrowBlock(arg->ir_block, arg->jc_block);
186 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
187 const int nrow = ir_end - ir_bgn;
188 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
189 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
190 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
191 // block copy : lower triangle to lower is enough
192 const T none(-1.0);
193
194 if ((iblock0 + 1) == iblock1) {
195 const int ir_mid_src = src_mtrx->IndexBlock(iblock1);
196 const int nrow0 = ir_mid_src - ir_bgn_src;
197 const int nrow1 = nrow - nrow0;
198 const int ir_mid = ir_bgn + nrow0;
199 {
200 int jj, j0, j1;
201 const int nrow_src = src_mtrx->nrowBlock(iblock0, iblock0);
202 T *src_pt = src_mtrx->addrCoefBlock(iblock0, iblock0);
203 for (j1 = nrow_src_offset * (nrow_src + 1),
204 j0 = ir_bgn * (dst_row + 1), //D(ir_bgn,ir_bgn)-(ir_mid,ir_mid)
205 jj = ir_bgn; jj < ir_mid; jj++, // driving index
206 j0 += dst_row, j1 += nrow_src) {
207 blas_axpy<T>(nrow0, none, src_pt + j1, 1, dst_pt + j0, 1);
208 }
209 }
210 {
211 int jj, j0, j1, j2, j3, j4;
212 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, iblock1);
213 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, iblock1);
214 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, iblock1);
215 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, iblock1);
216 // lower part of Schur complement matrix
217 T *src_pt2 = src_mtrx->addrCoefBlock(iblock1, iblock0);
218 for (j4 = 0, j3 = nrow_src_offset,
219 j0 = ir_bgn + ir_mid * dst_row, // (ir_bgn,ir_mid)-(ir_mid,ir_end)
220 j1 = ir_mid * (dst_row + 1), //D(ir_mid,ir_mid)-(ir_end,ir_end)
221 j2 = ir_mid + ir_bgn * dst_row, //T(ir_bgn,ir_mid)-(ir_mid,ir_end)
222 jj = ir_mid; jj < ir_end; jj++, // driving index
223 j0 += dst_row, j1 += dst_row, j2++,
224 j3 += nrow_src0, j4 += nrow_src1) {
225 blas_axpy<T>(nrow0, none, src_pt0 + j3, 1, dst_pt + j0, 1);
226 blas_axpy<T>(nrow1, none, src_pt1 + j4, 1, dst_pt + j1, 1);
227 // lower part of Schur complement matrix
228 blas_axpy<T>(nrow0, none, src_pt2 + j3, 1, dst_pt + j2, dst_row);
229 }
230 }
231 }
232 else if (iblock0 == iblock1) {
233 int jj, j0, j1;
234 const int nrow_src = src_mtrx->nrowBlock(iblock0, iblock0);
235 T *src_pt = src_mtrx->addrCoefBlock(iblock0, iblock0);
236 for (j1 = nrow_src_offset * (nrow_src + 1),
237 j0 = ir_bgn * (dst_row + 1), //D(ir_bgn,ir_bgn)-(ir_end,ir_end)
238 jj = ir_bgn; jj < ir_end; jj++, // driving index
239 j0 += dst_row, j1 += nrow_src) {
240 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
241 } // loop : j0, j1
242 }
243 else {
244 diss_printf(arg->verbose, arg->fp,
245 "%s %d : bad block indices in diagonal %d %d\n",
246 __FILE__, __LINE__, iblock0, iblock1);
247 }
248 }
249
250 template
251 void dsub_unsym2unsym_diag<double>(C_Dsub_task<double> *arg);
252
253 template
254 void dsub_unsym2unsym_diag<quadruple>(C_Dsub_task<quadruple> *arg);
255
256 template
257 void dsub_unsym2unsym_diag<complex<double> >(C_Dsub_task<complex<double> >*arg);
258
259 template
260 void dsub_unsym2unsym_diag<complex<quadruple> >(C_Dsub_task<complex<quadruple> >*arg);
261
262 template
263 void dsub_unsym2unsym_diag<float>(C_Dsub_task<float> *arg);
264
265 template
266 void dsub_unsym2unsym_diag<complex<float> >(C_Dsub_task<complex<float> >*arg);
267
268 // end of template function dsub_unsym2unsym_diag<T>
269
270 template<typename T>
271 void dsub_sym2sym(C_Dsub_task<T> *arg)
272 {
273 const int ir_bgn = arg->ir_bgn;
274 const int ir_end = arg->ir_end;
275 const int jc_bgn = arg->jc_bgn;
276 const int jc_end = arg->jc_end;
277 const int ir_bgn_src = arg->ir_bgn_src;
278 const int jc_bgn_src = arg->jc_bgn_src;
279 T *dst_pt = arg->dst_mtrx->addrCoefBlock(arg->ir_block, arg->jc_block);
280 const int dst_row = arg->dst_mtrx->nrowBlock(arg->ir_block, arg->jc_block);
281 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
282 const int nrow = ir_end - ir_bgn;
283 const int ncol = jc_end - jc_bgn;
284 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
285 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
286 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
287 const int jblock0 = src_mtrx->BlockIndex(jc_bgn_src);
288 const int jblock1 = src_mtrx->BlockIndex(jc_bgn_src + ncol - 1);
289 const int ncol_src_offset = src_mtrx->BlockOffset(jc_bgn_src);
290 const T none(-1.0);
291
292 if ((iblock0 + 1) == iblock1) {
293 // decomposition is defined by src block with SIZE_B1
294 const int ir_mid_src = src_mtrx->IndexBlock(iblock1); // * SIZE_B1;
295 const int nrow0 = ir_mid_src - ir_bgn_src;
296 const int nrow1 = nrow - nrow0;
297 const int ir_mid = ir_bgn + nrow0;
298 if ((jblock0 + 1) == jblock1) {
299 const int jc_mid_src = src_mtrx->IndexBlock(jblock1); // * SIZE_B1;
300 const int ncol0 = jc_mid_src - jc_bgn_src;
301 const int jc_mid = jc_bgn + ncol0;
302 {
303 int jj, j0, j1, j2, j3;
304 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
305 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
306 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
307 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
308 // distnation : transpose of
309 // distnation : transpose of
310 for (j3 = ncol_src_offset * nrow_src1,
311 j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
312 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_mid,jc_mid)
313 j1 = ir_mid + jc_bgn * dst_row, // (ir_mid,jc_bgn)-(ir_end,jc_mid)
314 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
315 j0 += dst_row, j1 += dst_row, j2 += nrow_src0, j3 += nrow_src1) {
316 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
317 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
318 }
319 }
320 {
321 int jj, j0, j1, j2, j3;
322 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock1);
323 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock1);
324 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock1);
325 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock1);
326 // distnation : transpose of
327 // distnation : transpose of
328 for (j3 = 0, j2 = nrow_src_offset,
329 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_mid,jc_end)
330 j1 = ir_mid + jc_mid * dst_row, // (ir_mid,jc_mid)-(ir_end,jc_end)
331 jj = jc_mid; jj < jc_end; jj++, // driving index
332 j0 += dst_row, j1 += dst_row, j2 += nrow_src0, j3 += nrow_src1) {
333 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
334 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
335 }
336 }
337 } // if ((jblock0 + 1) == jblock1) {
338 else if (jblock0 == jblock1) {
339 int jj, j0, j1, j2, j3;
340 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
341 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
342 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
343 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
344 // distnation : transpose of
345 // distnation : transpose of
346 for (j3 = ncol_src_offset * nrow_src1,
347 j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
348 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_mid,jc_end)
349 j1 = ir_mid + jc_bgn * dst_row, // (ir_mid,jc_bgn)-(ir_end,jc_end)
350 jj = jc_bgn; jj < jc_end; jj++, // driving index
351 j0 += dst_row, j1 += dst_row, j2 += nrow_src0, j3 += nrow_src1) {
352 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
353 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
354 }
355 }
356 else {
357 diss_printf(arg->verbose, arg->fp,
358 "%s %d : bad block indices in column : %d %d\n",
359 __FILE__, __LINE__, jblock0, jblock1);
360 }
361 }
362 else if (iblock0 == iblock1) {
363 if ((jblock0 + 1) == jblock1) {
364 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);// * SIZE_B1;
365 const int ncol0 = jc_mid_src - jc_bgn_src;
366 const int jc_mid = jc_bgn + ncol0;
367 {
368 int jj, j0, j1;
369 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
370 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
371 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
372 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_mid)
373 jj = jc_bgn; jj < jc_mid; jj++, // driving index
374 j0 += dst_row, j1 += nrow_src) {
375 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
376 }
377 }
378 {
379 int jj, j0, j1;
380 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
381 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock1);
382 // distnation : transpose of
383 for (j1 = nrow_src_offset,
384 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_end,jc_end)
385 jj = jc_mid; jj < jc_end; jj++, // driving index
386 j0 += dst_row, j1 += nrow_src) {
387 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
388 }
389 }
390 }
391 else {
392 int jj, j0, j1;
393 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
394 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
395 // distnation : transpose of
396 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
397 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
398 jj = jc_bgn; jj < jc_end; jj++, // driving index
399 j0 += dst_row, j1 += nrow_src) {
400 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
401 }
402 }
403 } // if ((jblock0 + 1) == jblock1)
404 else {
405 diss_printf(arg->verbose, arg->fp,
406 "%s %d : bad block indices in row : %d %d\n",
407 __FILE__, __LINE__, iblock0, iblock1);
408 }
409 }
410 template
411 void dsub_sym2sym<double>(C_Dsub_task<double> *arg);
412
413 template
414 void dsub_sym2sym<quadruple>(C_Dsub_task<quadruple> *arg);
415
416 template
417 void dsub_sym2sym<complex<double> >(C_Dsub_task<complex<double> > *arg);
418
419 template
420 void dsub_sym2sym<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
421
422 template
423 void dsub_sym2sym<float>(C_Dsub_task<float> *arg);
424
425 template
426 void dsub_sym2sym<complex<float> >(C_Dsub_task<complex<float> > *arg);
427
428 // end of template function dsub_sym2sym<T>
429
430 template<typename T>
431 void dsub_unsym2unsym(C_Dsub_task<T> *arg)
432 {
433 const int ir_bgn = arg->ir_bgn;
434 const int ir_end = arg->ir_end;
435 const int jc_bgn = arg->jc_bgn;
436 const int jc_end = arg->jc_end;
437 const int ir_bgn_src = arg->ir_bgn_src;
438 const int jc_bgn_src = arg->jc_bgn_src;
439 T *dst_pt = arg->dst_mtrx->addrCoefBlock(arg->ir_block, arg->jc_block);
440 const int dst_row = arg->dst_mtrx->nrowBlock(arg->ir_block, arg->jc_block);
441 T *dst_pt2 = arg->dst_mtrx->addrCoefBlock(arg->jc_block, arg->ir_block);
442 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
443 const int nrow = ir_end - ir_bgn;
444 const int ncol = jc_end - jc_bgn;
445 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
446 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
447 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
448 const int jblock0 = src_mtrx->BlockIndex(jc_bgn_src);
449 const int jblock1 = src_mtrx->BlockIndex(jc_bgn_src + ncol - 1);
450 const int ncol_src_offset = src_mtrx->BlockOffset(jc_bgn_src);
451 const T none(-1.0);
452
453 if ((iblock0 + 1) == iblock1) {
454 // decomposition is defined by src block with SIZE_B1
455 const int ir_mid_src = src_mtrx->IndexBlock(iblock1);// * SIZE_B1;
456 const int nrow0 = ir_mid_src - ir_bgn_src;
457 const int nrow1 = nrow - nrow0;
458 const int ir_mid = ir_bgn + nrow0;
459 if ((jblock0 + 1) == jblock1) {
460 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);// * SIZE_B1;
461 const int ncol0 = jc_mid_src - jc_bgn_src;
462 const int jc_mid = jc_bgn + ncol0;
463 {
464 int jj, j0, j1, j2, j3;
465 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
466 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
467 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
468 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
469 for (j3 = ncol_src_offset * nrow_src1,
470 j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
471 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_mid,jc_mid)
472 j1 = ir_mid + jc_bgn * dst_row, //(ir_mid,jc_bgn)-(ir_end,jc_mid)
473 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
474 j0 += dst_row, j1 += dst_row,
475 j2 += nrow_src0, j3 += nrow_src1) {
476 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
477 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
478 }
479 }
480 // lower part of Schur complement matrix
481 {
482 int jj, j0, j2;
483 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
484 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
485 {
486 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
487 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_mid,jc_mid)
488 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
489 j0 += dst_row,
490 j2 += nrow_src0) {
491 blas_axpy<T>(nrow0, none, src_pt2 + j2, 1, dst_pt2 + j0, 1);
492 }
493 }
494 }
495 {
496 int jj, j1, j3;
497 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
498 T *src_pt3 = src_mtrx->addrCoefBlock(jblock0, iblock1);
499 if (iblock1 == jblock0) {
500 for (j3 = ncol_src_offset,
501 j1 = ir_mid + jc_bgn * dst_row, //(ir_mid,jc_bgn)-(ir_end,jc_mid)
502 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
503 j1 += dst_row,
504 j3++) {
505 blas_axpy<T>(nrow1, none, src_pt3 + j3, nrow_src1, dst_pt2 + j1, 1);
506 }
507 }
508 else {
509 for (j3 = ncol_src_offset * nrow_src1,
510 j1 = ir_mid + jc_bgn * dst_row, //(ir_mid,jc_bgn)-(ir_end,jc_mid)
511 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
512 j1 += dst_row,
513 j3 += nrow_src1) {
514 blas_axpy<T>(nrow1, none, src_pt3 + j3, 1, dst_pt2 + j1, 1);
515 }
516 }
517 }
518 {
519 int jj, j0, j1, j2, j3;
520 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock1);
521 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock1);
522 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock1);
523 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock1);
524 for (j3 = 0, j2 = nrow_src_offset,
525 j0 = ir_bgn + jc_mid * dst_row, //(ir_bgn,jc_mid)-(ir_mid,jc_end)
526 j1 = ir_mid + jc_mid * dst_row, //(ir_mid,jc_mid)-(ir_end,jc_end)
527 jj = jc_mid; jj < jc_end; jj++, //driving index
528 j0 += dst_row, j1 += dst_row,
529 j2 += nrow_src0, j3 += nrow_src1) {
530 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
531 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
532 }
533 }
534 {
535 int jj, j0, j2;
536 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock1);
537 T *src_pt2 = src_mtrx->addrCoefBlock(jblock1, iblock0);
538 {
539 for (j2 = nrow_src_offset,
540 j0 = ir_bgn + jc_mid * dst_row, //(ir_bgn,jc_mid)-(ir_mid,jc_end)
541 jj = jc_mid; jj < jc_end; jj++, //driving index
542 j0 += dst_row,
543 j2 += nrow_src0) {
544 blas_axpy<T>(nrow0, none, src_pt2 + j2, 1, dst_pt2 + j0, 1);
545 }
546 }
547 }
548 {
549 int jj, j1, j3;
550 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock1);
551 T *src_pt3 = src_mtrx->addrCoefBlock(jblock1, iblock1);
552 {
553 for (j3 = 0,
554 j1 = ir_mid + jc_mid * dst_row, //(ir_mid,jc_mid)-(ir_end,jc_end)
555 jj = jc_mid; jj < jc_end; jj++, //driving index
556 j1 += dst_row,
557 j3 += nrow_src1) {
558 blas_axpy<T>(nrow1, none, src_pt3 + j3, 1, dst_pt2 + j1, 1);
559 }
560 }
561 }
562 } // if ((jblock0 + 1) == jblock1) {
563 else if (jblock0 == jblock1) {
564 {
565 int jj, j0, j1, j2, j3;
566 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
567 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
568 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
569 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
570 for (j3 = ncol_src_offset * nrow_src1,
571 j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
572 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_mid,jc_end)
573 j1 = ir_mid + jc_bgn * dst_row, // (ir_mid,jc_bgn)-(ir_end,jc_end)
574 jj = jc_bgn; jj < jc_end; jj++, // driving index
575 j0 += dst_row, j1 += dst_row,
576 j2 += nrow_src0, j3 += nrow_src1) {
577 blas_axpy<T>(nrow0, none, src_pt0 + j2, 1, dst_pt + j0, 1);
578 blas_axpy<T>(nrow1, none, src_pt1 + j3, 1, dst_pt + j1, 1);
579 }
580 }
581 {
582 int jj, j0, j2;
583 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
584 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
585 {
586 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src0,
587 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_mid,jc_end)
588 jj = jc_bgn; jj < jc_end; jj++, // driving index
589 j0 += dst_row,
590 j2 += nrow_src0) {
591 blas_axpy<T>(nrow0, none, src_pt2 + j2, 1, dst_pt2 + j0, 1);
592 }
593 }
594 }
595 {
596 int jj, j1, j3;
597 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
598 T *src_pt3 = src_mtrx->addrCoefBlock(jblock0, iblock1);
599 if (iblock1 == jblock0) {
600 for (j3 = ncol_src_offset, // transposed
601 j1 = ir_mid + jc_bgn * dst_row, //(ir_mid,jc_bgn)-(ir_end,jc_end)
602 jj = jc_bgn; jj < jc_end; jj++, // driving index
603 j1 += dst_row,
604 j3++) {
605 blas_axpy<T>(nrow1, none, src_pt3 + j3, nrow_src1, dst_pt2 + j1, 1);
606 }
607 }
608 else {
609 for (j3 = ncol_src_offset * nrow_src1,
610 j1 = ir_mid + jc_bgn * dst_row, //(ir_mid,jc_bgn)-(ir_end,jc_end)
611 jj = jc_bgn; jj < jc_end; jj++, // driving index
612 j1 += dst_row,
613 j3 += nrow_src1) {
614 blas_axpy<T>(nrow1, none, src_pt3 + j3, 1, dst_pt2 + j1, 1);
615 }
616 }
617 }
618 }
619 else {
620 diss_printf(arg->verbose, arg->fp,
621 "%s %d : bad block indices in column : %d %d\n",
622 __FILE__, __LINE__, jblock0, jblock1);
623 }
624 }
625 else if (iblock0 == iblock1) {
626 if ((jblock0 + 1) == jblock1) {
627 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);// * SIZE_B1;
628 const int ncol0 = jc_mid_src - jc_bgn_src;
629 const int jc_mid = jc_bgn + ncol0;
630 {
631 int jj, j0, j1;
632 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
633 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
634 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
635 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_mid)
636 jj = jc_bgn; jj < jc_mid; jj++, // driving index
637 j0 += dst_row, j1 += nrow_src) {
638 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
639 }
640 }
641 {
642 int jj, j0, j1;
643 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
644 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
645 if (iblock0 == jblock0) {
646 for (j1 = ncol_src_offset + nrow_src_offset * nrow_src, // transposed
647 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_mid)
648 jj = jc_bgn; jj < jc_mid; jj++, // driving index
649 j0 += dst_row, j1++) {
650 blas_axpy<T>(nrow, none, src_pt2 + j1, nrow_src, dst_pt2 + j0, 1);
651 }
652 }
653 else {
654 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
655 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_mid)
656 jj = jc_bgn; jj < jc_mid; jj++, // driving index
657 j0 += dst_row, j1 += nrow_src) {
658 blas_axpy<T>(nrow, none, src_pt2 + j1, 1, dst_pt2 + j0, 1);
659 }
660 }
661 }
662 {
663 int jj, j0, j1;
664 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
665 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock1);
666 for (j1 = nrow_src_offset,
667 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_end,jc_end)
668 jj = jc_mid; jj < jc_end; jj++, // driving index
669 j0 += dst_row, j1 += nrow_src) {
670 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
671 }
672 }
673 {
674 int jj, j0, j1;
675 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
676 T *src_pt2 = src_mtrx->addrCoefBlock(jblock1, iblock0);
677 {
678 for (j1 = nrow_src_offset,
679 j0 = ir_bgn + jc_mid * dst_row, //(ir_bgn,jc_mid)-(ir_end,jc_end)
680 jj = jc_mid; jj < jc_end; jj++, // driving index
681 j0 += dst_row, j1 += nrow_src) {
682 blas_axpy<T>(nrow, none, src_pt2 + j1, 1, dst_pt2 + j0, 1);
683 }
684 }
685 }
686 }
687 else {
688 {
689 int jj, j0, j1;
690 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
691 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
692 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
693 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
694 jj = jc_bgn; jj < jc_end; jj++, // driving index
695 j0 += dst_row, j1 += nrow_src) {
696 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
697 }
698 }
699 {
700 int jj, j0, j1;
701 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
702 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
703 if (iblock0 == jblock0) {
704 for (j1 = ncol_src_offset + nrow_src_offset * nrow_src, // transposed
705 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_end)
706 jj = jc_bgn; jj < jc_end; jj++, // driving index
707 j0 += dst_row, j1++) {
708 blas_axpy<T>(nrow, none, src_pt2 + j1, nrow_src, dst_pt2 + j0, 1);
709 }
710 }
711 else {
712 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
713 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_end)
714 jj = jc_bgn; jj < jc_end; jj++, // driving index
715 j0 += dst_row, j1 += nrow_src) {
716 blas_axpy<T>(nrow, none, src_pt2 + j1, 1, dst_pt2 + j0, 1);
717 }
718 }
719 }
720 }
721 } // if ((jblock0 + 1) == jblock1)
722 else {
723 diss_printf(arg->verbose, arg->fp,
724 "%s %d : bad block indices in row : %d %d\n",
725 __FILE__, __LINE__, iblock0, iblock1);
726 }
727 }
728 template
729 void dsub_unsym2unsym<double>(C_Dsub_task<double> *arg);
730
731 template
732 void dsub_unsym2unsym<quadruple>(C_Dsub_task<quadruple> *arg);
733
734 template
735 void dsub_unsym2unsym<complex<double> >(C_Dsub_task<complex<double> > *arg);
736
737 template
738 void dsub_unsym2unsym<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
739
740 template
741 void dsub_unsym2unsym<float>(C_Dsub_task<float> *arg);
742
743 template
744 void dsub_unsym2unsym<complex<float> >(C_Dsub_task<complex<float> > *arg);
745
746 // end of template function dsub_unsym2unsym<T>
747
748 template<typename T>
749 void dsub_unsym2diag(C_Dsub_task<T> *arg)
750 {
751 // destination is inside of a diagonal block : ir_block == jc_block
752 const int ir_bgn = arg->ir_bgn;
753 const int ir_end = arg->ir_end;
754 const int jc_bgn = arg->jc_bgn;
755 const int jc_end = arg->jc_end;
756 const int ir_bgn_src = arg->ir_bgn_src;
757 const int jc_bgn_src = arg->jc_bgn_src;
758 T *dst_pt = arg->dst_mtrx->addrCoefBlock(arg->ir_block, arg->jc_block);
759 const int dst_row = arg->dst_mtrx->nrowBlock(arg->ir_block, arg->jc_block);
760 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
761 const int nrow = ir_end - ir_bgn;
762 const int ncol = jc_end - jc_bgn;
763 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
764 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
765 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
766 const int jblock0 = src_mtrx->BlockIndex(jc_bgn_src);
767 const int jblock1 = src_mtrx->BlockIndex(jc_bgn_src + ncol - 1);
768 const int ncol_src_offset = src_mtrx->BlockOffset(jc_bgn_src);
769 const T none(-1.0);
770
771 if ((iblock0 + 1) == iblock1) {
772 // decomposition is defined by src block with SIZE_B1
773 const int ir_mid_src = src_mtrx->IndexBlock(iblock1);
774 const int nrow0 = ir_mid_src - ir_bgn_src;
775 const int nrow1 = nrow - nrow0;
776 const int ir_mid = ir_bgn + nrow0;
777 if ((jblock0 + 1) == jblock1) {
778 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);
779 const int ncol0 = jc_mid_src - jc_bgn_src;
780 const int jc_mid = jc_bgn + ncol0;
781 {
782 int jj, j0, j1, j2, j3, j4, j5;
783 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
784 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
785 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
786 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
787 // lower part of Schur complement matrix
788 for (j5 = ncol_src_offset * nrow_src1,
789 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
790 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_mid,jc_mid)
791 j1 = ir_mid + jc_bgn * dst_row, // (ir_mid,jc_bgn)-(ir_end,jc_mid)
792 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
793 j0 += dst_row, j1 += dst_row,
794 j4 += nrow_src0, j5 += nrow_src1) {
795 blas_axpy<T>(nrow0, none, src_pt0 + j4, 1, dst_pt + j0, 1);
796 blas_axpy<T>(nrow1, none, src_pt1 + j5, 1, dst_pt + j1, 1);
797 }
798 // lower part of Schur complement matrix
799 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
800 T *src_pt3 = src_mtrx->addrCoefBlock(jblock0, iblock1);
801 if (iblock1 == jblock0) {
802 for (j5 = ncol_src_offset, // transposted
803 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
804 j2 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_mid,jc_mid)
805 j3 = jc_bgn + ir_mid * dst_row,//(ir_mid,jc_bgn)-(ir_end,jc_mid)
806 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
807 j2++, j3++,
808 j4 += nrow_src0, j5++) {
809 blas_axpy<T>(nrow0, none, src_pt2 + j4, 1, // transposed
810 dst_pt + j2, dst_row);
811 blas_axpy<T>(nrow1, none, src_pt3 + j5, nrow_src1, // both in the
812 dst_pt + j3, dst_row); // diagonal
813 }
814 }
815 else {
816 for (j5 = ncol_src_offset * nrow_src1,
817 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
818 j2 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_mid,jc_mid)
819 j3 = jc_bgn + ir_mid * dst_row,//(ir_mid,jc_bgn)-(ir_end,jc_mid)
820 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
821 j2++, j3++,
822 j4 += nrow_src0, j5 += nrow_src1) {
823 blas_axpy<T>(nrow0, none, src_pt2 + j4, 1, // transposed
824 dst_pt + j2, dst_row);
825 blas_axpy<T>(nrow1, none, src_pt3 + j5, 1, // transposed
826 dst_pt + j3, dst_row);
827 }
828 }
829 }
830 {
831 int jj, j0, j1, j2, j3, j4, j5;
832 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock1);
833 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock1);
834 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock1);
835 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock1);
836 for (j5 = 0, j4 = nrow_src_offset,
837 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_mid,jc_end)
838 j1 = ir_mid + jc_mid * dst_row, // (ir_mid,jc_mid)-(ir_end,jc_end)
839 jj = jc_mid; jj < jc_end; jj++, // driving index
840 j0 += dst_row, j1 += dst_row ,
841 j4 += nrow_src0, j5 += nrow_src1) {
842 blas_axpy<T>(nrow0, none, src_pt0 + j4, 1, dst_pt + j0, 1);
843 blas_axpy<T>(nrow1, none, src_pt1 + j5, 1, dst_pt + j1, 1);
844 }
845 // lower part of Schur complement matrix
846 T *src_pt2 = src_mtrx->addrCoefBlock(jblock1, iblock0);
847 T *src_pt3 = src_mtrx->addrCoefBlock(jblock1, iblock1);
848 {
849 for (j5 = 0, j4 = nrow_src_offset,
850 j2 = jc_mid + ir_bgn * dst_row,//(ir_bgn,jc_mid)-(ir_mid,jc_end)
851 j3 = jc_mid + ir_mid * dst_row,//(ir_mid,jc_mid)-(ir_end,jc_end)
852 jj = jc_mid; jj < jc_end; jj++, // driving index
853 j2++, j3++,
854 j4 += nrow_src0, j5 += nrow_src1) {
855 blas_axpy<T>(nrow0, none, src_pt2 + j4, 1, dst_pt + j2, dst_row);
856 blas_axpy<T>(nrow1, none, src_pt3 + j5, 1, dst_pt + j3, dst_row);
857 }
858 }
859 }
860 } // if ((jblock0 + 1) == jblock1) {
861 else if (jblock0 == jblock1) {
862 int jj, j0, j1, j2, j3, j4, j5;
863 const int nrow_src0 = src_mtrx->nrowBlock(iblock0, jblock0);
864 const int nrow_src1 = src_mtrx->nrowBlock(iblock1, jblock0);
865 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
866 T *src_pt1 = src_mtrx->addrCoefBlock(iblock1, jblock0);
867 for (j5 = ncol_src_offset * nrow_src1,
868 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
869 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_mid,jc_end)
870 j1 = ir_mid + jc_bgn * dst_row, // (ir_mid,jc_bgn)-(ir_end,jc_end)
871 jj = jc_bgn; jj < jc_end; jj++, // driving index
872 j0 += dst_row, j1 += dst_row,
873 j4 += nrow_src0, j5 += nrow_src1) {
874 blas_axpy<T>(nrow0, none, src_pt0 + j4, 1, dst_pt + j0, 1);
875 blas_axpy<T>(nrow1, none, src_pt1 + j5, 1, dst_pt + j1, 1);
876 }
877 // lower part of Schur complement matrix
878 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
879 T *src_pt3 = src_mtrx->addrCoefBlock(jblock0, iblock1);
880 if (iblock1 == jblock0) {
881 for (j5 = ncol_src_offset,
882 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
883 j2 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_mid,jc_end)
884 j3 = jc_bgn + ir_mid * dst_row,//(ir_mid,jc_bgn)-(ir_end,jc_end)
885 jj = jc_bgn; jj < jc_end; jj++, // driving index
886 j2++, j3++,
887 j4 += nrow_src0, j5++) {
888 blas_axpy<T>(nrow0, none, src_pt2 + j4, 1, // transposed
889 dst_pt + j2, dst_row);
890 blas_axpy<T>(nrow1, none, src_pt3 + j5, nrow_src1, // both in the
891 dst_pt + j3, dst_row); // diagonal
892 }
893 }
894 else {
895 for (j5 = ncol_src_offset * nrow_src1,
896 j4 = nrow_src_offset + ncol_src_offset * nrow_src0,
897 j2 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_mid,jc_end)
898 j3 = jc_bgn + ir_mid * dst_row,//(ir_mid,jc_bgn)-(ir_end,jc_end)
899 jj = jc_bgn; jj < jc_end; jj++, // driving index
900 j2++, j3++,
901 j4 += nrow_src0, j5 += nrow_src1) {
902 blas_axpy<T>(nrow0, none, src_pt2 + j4, 1, dst_pt + j2, dst_row);
903 blas_axpy<T>(nrow1, none, src_pt3 + j5, 1, dst_pt + j3, dst_row);
904 }
905 }
906 }
907 else {
908 diss_printf(arg->verbose, arg->fp,
909 "%s %d : bad block indices in column : %d %d\n",
910 __FILE__, __LINE__, jblock0, jblock1);
911 }
912 }
913 else if (iblock0 == iblock1) {
914 if ((jblock0 + 1) == jblock1) {
915 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);
916 const int ncol0 = jc_mid_src - jc_bgn_src;
917 const int jc_mid = jc_bgn + ncol0;
918 {
919 int jj, j0, j1, j2;
920 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
921 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
922 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src,
923 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_mid)
924 jj = jc_bgn; jj < jc_mid; jj++, // driving index
925 j0 += dst_row, j2 += nrow_src) {
926 blas_axpy<T>(nrow, none, src_pt + j2, 1, dst_pt + j0, 1);
927 }
928 // lower part of Schur complement matrix
929 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
930 if (iblock0 == jblock0) {
931 for (j2 = ncol_src_offset + nrow_src_offset * nrow_src,
932 j1 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_end,jc_mid)
933 jj = jc_bgn; jj < jc_mid; jj++, // driving index
934 j1++, j2++) {
935 blas_axpy<T>(nrow, none, src_pt2 + j2, nrow_src,
936 dst_pt + j1, dst_row);
937 }
938 }
939 else {
940 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src,
941 j1 = jc_bgn + ir_bgn * dst_row,//(ir_bgn,jc_bgn)-(ir_end,jc_mid)
942 jj = jc_bgn; jj < jc_mid; jj++, // driving index
943 j1++, j2 += nrow_src) {
944 blas_axpy<T>(nrow, none, src_pt2 + j2, 1,
945 dst_pt + j1, dst_row);
946 }
947 }
948 }
949 {
950 int jj, j0, j1, j2;
951 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
952 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock1);
953 T *src_pt2 = src_mtrx->addrCoefBlock(jblock1, iblock0);
954 for (j2 = nrow_src_offset,
955 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_end,jc_end)
956 j1 = jc_mid + ir_bgn * dst_row,//T(ir_bgn,jc_mid)-(ir_end,jc_end)
957 jj = jc_mid; jj < jc_end; jj++, // driving index
958 j0 += dst_row, j1++, j2 += nrow_src) {
959 blas_axpy<T>(nrow, none, src_pt + j2, 1, dst_pt + j0, 1);
960 // lower part of Schur complement matrix
961 blas_axpy<T>(nrow, none, src_pt2 + j2, 1, dst_pt + j1, dst_row);
962 }
963 }
964 }
965 else {
966 int jj, j0, j1, j2;
967 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
968 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
969 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src,
970 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
971 jj = jc_bgn; jj < jc_end; jj++, // driving index
972 j0 += dst_row, j2 += nrow_src) {
973 blas_axpy<T>(nrow, none, src_pt + j2, 1, dst_pt + j0, 1);
974 }
975 T *src_pt2 = src_mtrx->addrCoefBlock(jblock0, iblock0);
976 if (iblock0 == jblock0) {
977 for (j2 = ncol_src_offset + nrow_src_offset * nrow_src, //trans
978 j1 = jc_bgn + ir_bgn * dst_row, //T(ir_bgn,jc_bgn)-(ir_end,jc_end)
979 jj = jc_bgn; jj < jc_end; jj++, // driving index
980 j1++, j2++) {
981 blas_axpy<T>(nrow, none, src_pt2 + j2, nrow_src,
982 dst_pt + j1, dst_row);
983 }
984 }
985 else {
986 for (j2 = nrow_src_offset + ncol_src_offset * nrow_src,
987 j1 = jc_bgn + ir_bgn * dst_row, //T(ir_bgn,jc_bgn)-(ir_end,jc_end)
988 jj = jc_bgn; jj < jc_end; jj++, // driving index
989 j1++, j2 += nrow_src) {
990 blas_axpy<T>(nrow, none, src_pt2 + j2, 1, dst_pt + j1, dst_row);
991 }
992 }
993 }
994 } // if ((jblock0 + 1) == jblock1)
995 else {
996 diss_printf(arg->verbose, arg->fp,
997 "%s %d : bad block indices in row : %d %d\n",
998 __FILE__, __LINE__, iblock0, iblock1);
999 }
1000 }
1001
1002 template
1003 void dsub_unsym2diag<double>(C_Dsub_task<double> *arg);
1004
1005 template
1006 void dsub_unsym2diag<quadruple>(C_Dsub_task<quadruple> *arg);
1007
1008 template
1009 void dsub_unsym2diag<complex<double> >(C_Dsub_task<complex<double> > *arg);
1010
1011 template
1012 void dsub_unsym2diag<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1013
1014 template
1015 void dsub_unsym2diag<float>(C_Dsub_task<float> *arg);
1016
1017 template
1018 void dsub_unsym2diag<complex<float> >(C_Dsub_task<complex<float> > *arg);
1019
1020 // end of template function dsub_unsym2diag<T>
1021
1022 template<typename T>
1023 void dsub_sym2rct(C_Dsub_task<T> *arg)
1024 {
1025 const int ir_bgn = arg->ir_bgn;
1026 const int ir_end = arg->ir_end;
1027 const int jc_bgn = arg->jc_bgn;
1028 const int jc_end = arg->jc_end;
1029 const int ir_bgn_src = arg->ir_bgn_src;
1030 const int jc_bgn_src = arg->jc_bgn_src;
1031 // const int dst_row = arg->dst_row;
1032 T *dst_pt = arg->dst_pt->addrCoefBlock(arg->ir_block, arg->jc_block);
1033 const int dst_row = arg->dst_pt->nrowBlock(arg->ir_block);
1034 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
1035 const int nrow = ir_end - ir_bgn;
1036 const int ncol = jc_end - jc_bgn;
1037 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
1038 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
1039 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
1040 const int jblock0 = src_mtrx->BlockIndex(jc_bgn_src);
1041 const int jblock1 = src_mtrx->BlockIndex(jc_bgn_src + ncol - 1);
1042 const int ncol_src_offset = src_mtrx->BlockOffset(jc_bgn_src);
1043 const T none(-1.0);
1044 if (iblock0 < iblock1) {
1045 // decomposition is defined by src block with SIZE_B1
1046 if ((jblock0 + 1) == jblock1) {
1047 const int jc_mid = jc_bgn + (src_mtrx->IndexBlock(jblock1) - jc_bgn_src);
1048 int ir_start = ir_bgn;
1049 {
1050 int jj, j0, j1;
1051 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0); // SIZE_B1?
1052 const int nnrow = nrow_src - nrow_src_offset;
1053 T *src_pt;
1054 src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
1055 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1056 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1057 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1058 j0 += dst_row, j1 += nrow_src) {
1059 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1060 }
1061 src_pt = src_mtrx->addrCoefBlock(iblock0, jblock1);
1062 for (j1 = nrow_src_offset,
1063 j0 = ir_start + jc_mid * dst_row, // ( ,jc_mid)-( +nnrow,jc_end)
1064 jj = jc_mid; jj < jc_end; jj++, // drinving index
1065 j0 += dst_row, j1 += nrow_src) {
1066 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1067 }
1068 ir_start += nnrow;
1069 }
1070 for (int iblock = iblock0 + 1; iblock < iblock1; iblock++) {
1071 int jj, j0, j1;
1072 const int nrow_src = src_mtrx->nrowBlock(iblock, jblock0); // SIZE_B1?
1073 T *src_pt;
1074 src_pt = src_mtrx->addrCoefBlock(iblock, jblock0);
1075 for (j1 = ncol_src_offset * nrow_src,
1076 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +SIZE_B1,jc_mid)
1077 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1078 j0 += dst_row, j1 += nrow_src) {
1079 blas_axpy<T>(nrow_src, none, src_pt + j1, 1, dst_pt + j0, 1);
1080 }
1081 src_pt = src_mtrx->addrCoefBlock(iblock, jblock1);
1082 for (j1 = 0,
1083 j0 = ir_start + jc_mid * dst_row, // ( ,jc_mid)-( +SIZE_B1,jc_end)
1084 jj = jc_mid; jj < jc_end; jj++, // drinving index
1085 j0 += dst_row, j1 += nrow_src) {
1086 blas_axpy<T>(nrow_src, none, src_pt + j1, 1, dst_pt + j0, 1);
1087 }
1088 ir_start += nrow_src;
1089 }
1090 {
1091 int jj, j0, j1;
1092 const int nrow_src = src_mtrx->nrowBlock(iblock1, jblock0);
1093 const int nnrow = ir_bgn_src + nrow - src_mtrx->IndexBlock(iblock1);
1094 T *src_pt;
1095 src_pt = src_mtrx->addrCoefBlock(iblock1, jblock0);
1096 for (j1 = ncol_src_offset * nrow_src,
1097 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1098 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1099 j0 += dst_row, j1 += nrow_src) {
1100 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1101 }
1102 src_pt = src_mtrx->addrCoefBlock(iblock1, jblock1);
1103 for (j1 = 0,
1104 j0 = ir_start + jc_mid * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1105 jj = jc_mid; jj < jc_end; jj++, // drinving index
1106 j0 += dst_row, j1 += nrow_src) {
1107 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1108 }
1109 }
1110 }
1111 else if (jblock0 == jblock1) {
1112 int ir_start = ir_bgn;
1113 {
1114 int jj, j0, j1;
1115 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1116 const int nnrow = nrow_src - nrow_src_offset;
1117 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
1118 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1119 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1120 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1121 j0 += dst_row, j1 += nrow_src) {
1122 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1123 }
1124 ir_start += nnrow;
1125 }
1126 for (int iblock = iblock0 + 1; iblock < iblock1; iblock++) {
1127 int jj, j0, j1;
1128 const int nrow_src = src_mtrx->nrowBlock(iblock, jblock0);
1129 T *src_pt = src_mtrx->addrCoefBlock(iblock, jblock0);
1130 for (j1 = ncol_src_offset * nrow_src,
1131 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +SIZE_B1,jc_end)
1132 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1133 j0 += dst_row, j1 += nrow_src) {
1134 blas_axpy<T>(nrow_src, none, src_pt + j1, 1, dst_pt + j0, 1);
1135 }
1136 ir_start += nrow_src;
1137 }
1138 {
1139 int jj, j0, j1;
1140 const int nrow_src = src_mtrx->nrowBlock(iblock1, jblock0);
1141 // const int itmp = (ir_bgn_src + nrow) % SIZE_B1;
1142 // const int nnrow = (itmp == 0) ? SIZE_B1 : itmp;
1143 const int nnrow = ir_bgn_src + nrow - src_mtrx->IndexBlock(iblock1);
1144 T *src_pt = src_mtrx->addrCoefBlock(iblock1, jblock0);
1145 for (j1 = ncol_src_offset * nrow_src,
1146 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1147 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1148 j0 += dst_row, j1 += nrow_src) {
1149 blas_axpy<T>(nnrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1150 }
1151 }
1152 }
1153 else {
1154 diss_printf(arg->verbose, arg->fp,
1155 "%s %d : bad block indices in column : %d %d\n",
1156 __FILE__, __LINE__, jblock0, jblock1);
1157 }
1158 } // if (iblock0 < iblock1)
1159 else {
1160 if ((jblock0 + 1) == jblock1) {
1161 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);
1162 const int ncol0 = jc_mid_src - jc_bgn_src;
1163 const int jc_mid = jc_bgn + ncol0;
1164 {
1165 int jj, j0, j1;
1166 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1167 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
1168 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1169 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_mid)
1170 jj = jc_bgn; jj < jc_mid; jj++, // driving index
1171 j0 += dst_row, j1 += nrow_src) {
1172 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1173 }
1174 }
1175 {
1176 int jj, j0, j1;
1177 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
1178 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock1);
1179 for (j1 = nrow_src_offset,
1180 j0 = ir_bgn + jc_mid * dst_row, // (ir_bgn,jc_mid)-(ir_end,jc_end)
1181 jj = jc_mid; jj < jc_end; jj++, // driving index
1182 j0 += dst_row, j1 += nrow_src) {
1183 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1184 }
1185 }
1186 }
1187 else if (jblock0 == jblock1) {
1188 int jj, j0, j1;
1189 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1190 T *src_pt = src_mtrx->addrCoefBlock(iblock0, jblock0);
1191 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1192 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
1193 jj = jc_bgn; jj < jc_end; jj++, // driving index
1194 j0 += dst_row, j1 += nrow_src) {
1195 blas_axpy<T>(nrow, none, src_pt + j1, 1, dst_pt + j0, 1);
1196 }
1197 }
1198 else {
1199 diss_printf(arg->verbose, arg->fp,
1200 "%s %d : bad block indices in column : %d %d\n",
1201 __FILE__, __LINE__, jblock0, jblock1);
1202 }
1203 } // if (iblock0 < iblock1)
1204 }
1205
1206 template
1207 void dsub_sym2rct<double>(C_Dsub_task<double> *arg);
1208
1209 template
1210 void dsub_sym2rct<quadruple>(C_Dsub_task<quadruple> *arg);
1211
1212 template
1213 void dsub_sym2rct<complex<double> >(C_Dsub_task<complex<double> > *arg);
1214
1215 template
1216 void dsub_sym2rct<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1217
1218 template
1219 void dsub_sym2rct<float>(C_Dsub_task<float> *arg);
1220
1221 template
1222 void dsub_sym2rct<complex<float> >(C_Dsub_task<complex<float> > *arg);
1223
1224
1225 // end of template function dsub_sym2rct<T>
1226
1227 template<typename T>
1228 void dsub_unsym2rct(C_Dsub_task<T> *arg)
1229 {
1230 const int ir_bgn = arg->ir_bgn;
1231 const int ir_end = arg->ir_end;
1232 const int jc_bgn = arg->jc_bgn;
1233 const int jc_end = arg->jc_end;
1234 const int ir_bgn_src = arg->ir_bgn_src;
1235 const int jc_bgn_src = arg->jc_bgn_src;
1236 // const int dst_row = arg->dst_row;
1237 T *dst_pt = arg->dst_pt->addrCoefBlock(arg->ir_block, arg->jc_block);
1238 T *dst_pt2 = arg->dst_pt2->addrCoefBlock(arg->ir_block, arg->jc_block);
1239 const int dst_row = arg->dst_pt->nrowBlock(arg->ir_block);
1240 SquareBlockMatrix<T> *src_mtrx = arg->src_pt;
1241 const int nrow = ir_end - ir_bgn;
1242 const int ncol = jc_end - jc_bgn;
1243 const int iblock0 = src_mtrx->BlockIndex(ir_bgn_src);
1244 const int iblock1 = src_mtrx->BlockIndex(ir_bgn_src + nrow - 1);
1245 const int nrow_src_offset = src_mtrx->BlockOffset(ir_bgn_src);
1246 const int jblock0 = src_mtrx->BlockIndex(jc_bgn_src);
1247 const int jblock1 = src_mtrx->BlockIndex(jc_bgn_src + ncol - 1);
1248 const int ncol_src_offset = src_mtrx->BlockOffset(jc_bgn_src);
1249 const T none(-1.0);
1250
1251 if (iblock0 < iblock1) {
1252 // decomposition is defined by src block with SIZE_B1
1253 if ((jblock0 + 1) == jblock1) {
1254 const int jc_mid = jc_bgn + (src_mtrx->IndexBlock(jblock1) - jc_bgn_src);
1255 int ir_start = ir_bgn;
1256 {
1257 int jj, j0, j1, j2;
1258 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0); // SIZE_B1?
1259 const int nnrow = nrow_src - nrow_src_offset;
1260 T *src_pt0, *src_pt1;
1261 src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
1262 src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock0);
1263 if (jblock0 == iblock0) {
1264 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1265 j2 = ncol_src_offset + nrow_src_offset * nrow_src, // transposed
1266 j0 = ir_start + jc_bgn * dst_row,//( ,jc_bgn)-( +nnrow,jc_mid)
1267 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1268 j0 += dst_row, j1 += nrow_src, j2++) {
1269 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1270 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1271 }
1272 }
1273 else {
1274 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1275 j0 = ir_start + jc_bgn * dst_row,//( ,jc_bgn)-( +nnrow,jc_mid)
1276 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1277 j0 += dst_row, j1 += nrow_src) {
1278 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1279 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1280 }
1281 }
1282 src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock1);
1283 src_pt1 = src_mtrx->addrCoefBlock(jblock1, iblock0);
1284 if (jblock1 == iblock0) {
1285 for (j1 = nrow_src_offset,
1286 j2 = nrow_src_offset * nrow_src, // transposed
1287 j0 = ir_start + jc_mid * dst_row,//( ,jc_mid)-( +nnrow,jc_end)
1288 jj = jc_mid; jj < jc_end; jj++, // drinving index
1289 j0 += dst_row, j1 += nrow_src, j2++) {
1290 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1291 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1292 }
1293 }
1294 else {
1295 for (j1 = nrow_src_offset,
1296 j0 = ir_start + jc_mid * dst_row,//( ,jc_mid)-( +nnrow,jc_end)
1297 jj = jc_mid; jj < jc_end; jj++, // drinving index
1298 j0 += dst_row, j1 += nrow_src) {
1299 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1300 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1301 }
1302 }
1303 ir_start += nnrow;
1304 }
1305 for (int iblock = iblock0 + 1; iblock < iblock1; iblock++) {
1306 int jj, j0, j1, j2;
1307 const int nrow_src = src_mtrx->nrowBlock(iblock, jblock0); // SIZE_B1?
1308 T *src_pt0, *src_pt1;
1309 src_pt0 = src_mtrx->addrCoefBlock(iblock, jblock0);
1310 src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock);
1311 if (jblock0 == iblock) {
1312 for (j1 = ncol_src_offset * nrow_src,
1313 j2 = ncol_src_offset, // transposed
1314 j0 = ir_start + jc_bgn * dst_row,//( ,jc_bgn)-( +SIZE_B1,jc_mid)
1315 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1316 j0 += dst_row, j1 += nrow_src, j2++) {
1317 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1,
1318 dst_pt + j0, 1);
1319 blas_axpy<T>(nrow_src, none, src_pt1 + j2, nrow_src,
1320 dst_pt2 + j0, 1);
1321 }
1322 }
1323 else {
1324 for (j1 = ncol_src_offset * nrow_src,
1325 j0 = ir_start + jc_bgn * dst_row,//( ,jc_bgn)-( +SIZE_B1,jc_mid)
1326 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1327 j0 += dst_row, j1 += nrow_src) {
1328 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1329 blas_axpy<T>(nrow_src, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1330 }
1331 }
1332 src_pt0 = src_mtrx->addrCoefBlock(iblock, jblock1);
1333 src_pt1 = src_mtrx->addrCoefBlock(jblock1, iblock);
1334 if (jblock1 == iblock) {
1335 for (j1 = 0,
1336 j2 = 0,
1337 j0 = ir_start + jc_mid * dst_row,//( ,jc_mid)-( +SIZE_B1,jc_end)
1338 jj = jc_mid; jj < jc_end; jj++, // drinving index
1339 j0 += dst_row, j1 += nrow_src, j2++) {
1340 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1,
1341 dst_pt + j0, 1);
1342 blas_axpy<T>(nrow_src, none, src_pt1 + j2, nrow_src,
1343 dst_pt2 + j0, 1);
1344 }
1345 }
1346 else {
1347 for (j1 = 0,
1348 j0 = ir_start + jc_mid * dst_row,//( ,jc_mid)-( +SIZE_B1,jc_end)
1349 jj = jc_mid; jj < jc_end; jj++, // drinving index
1350 j0 += dst_row, j1 += nrow_src) {
1351 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1352 blas_axpy<T>(nrow_src, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1353 }
1354 }
1355 ir_start += nrow_src;
1356 }
1357 {
1358 int jj, j0, j1, j2;
1359 const int nrow_src = src_mtrx->nrowBlock(iblock1, jblock0);
1360 // const int itmp = (ir_bgn_src + nrow) % SIZE_B1;
1361 // const int nnrow = (itmp == 0) ? SIZE_B1 : itmp;
1362 const int nnrow = ir_bgn_src + nrow - src_mtrx->IndexBlock(iblock1);
1363 T *src_pt0, *src_pt1;
1364 src_pt0 = src_mtrx->addrCoefBlock(iblock1, jblock0);
1365 src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock1);
1366 if (jblock0 == iblock1) {
1367 for (j1 = ncol_src_offset * nrow_src,
1368 j2 = ncol_src_offset, // transposed
1369 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1370 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1371 j0 += dst_row, j1 += nrow_src, j2++) {
1372 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1373 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1374 }
1375 }
1376 else {
1377 for (j1 = ncol_src_offset * nrow_src,
1378 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1379 jj = jc_bgn; jj < jc_mid; jj++, // drinving index
1380 j0 += dst_row, j1 += nrow_src) {
1381 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1382 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1383 }
1384 }
1385 src_pt0 = src_mtrx->addrCoefBlock(iblock1, jblock1);
1386 src_pt1 = src_mtrx->addrCoefBlock(jblock1, iblock1);
1387 if (jblock1 == iblock1) {
1388 for (j2 = 0,
1389 j1 = 0, //
1390 j0 = ir_start + jc_mid * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1391 jj = jc_mid; jj < jc_end; jj++, // drinving index
1392 j0 += dst_row, j1 += nrow_src, j2++) {
1393 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1394 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1395 }
1396 }
1397 else {
1398 for (j1 = 0,
1399 j0 = ir_start + jc_mid * dst_row, // ( ,jc_bgn)-( +nnrow,jc_mid)
1400 jj = jc_mid; jj < jc_end; jj++, // drinving index
1401 j0 += dst_row, j1 += nrow_src) {
1402 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1403 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1404 }
1405 }
1406 }
1407 }
1408 else if (jblock0 == jblock1) {
1409 int ir_start = ir_bgn;
1410 {
1411 int jj, j0, j1, j2;
1412 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1413 const int nnrow = nrow_src - nrow_src_offset;
1414 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
1415 T *src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock0);
1416 if (jblock0 == iblock0) {
1417 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1418 j2 = ncol_src_offset + nrow_src_offset * nrow_src, // transpopsed
1419 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1420 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1421 j0 += dst_row, j1 += nrow_src, j2++) {
1422 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1423 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1424 }
1425 }
1426 else {
1427 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1428 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1429 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1430 j0 += dst_row, j1 += nrow_src) {
1431 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1432 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1433 }
1434 }
1435 ir_start += nnrow;
1436 }
1437 for (int iblock = iblock0 + 1; iblock < iblock1; iblock++) {
1438 int jj, j0, j1, j2;
1439 const int nrow_src = src_mtrx->nrowBlock(iblock, jblock0);
1440 T *src_pt0 = src_mtrx->addrCoefBlock(iblock, jblock0);
1441 T *src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock);
1442 if (jblock0 == iblock) {
1443 for (j1 = ncol_src_offset * nrow_src,
1444 j2 = ncol_src_offset, // transposed
1445 j0 = ir_start + jc_bgn * dst_row,//( ,jc_bgn)-( +SIZE_B1,jc_end)
1446 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1447 j0 += dst_row, j1 += nrow_src, j2++) {
1448 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1449 blas_axpy<T>(nrow_src, none, src_pt1 + j2, nrow_src,
1450 dst_pt2 + j0, 1);
1451 }
1452 }
1453 else {
1454 for (j1 = ncol_src_offset * nrow_src,
1455 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +SIZE_B1,jc_end)
1456 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1457 j0 += dst_row, j1 += nrow_src) {
1458 blas_axpy<T>(nrow_src, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1459 blas_axpy<T>(nrow_src, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1460 }
1461 }
1462 ir_start += nrow_src;
1463 }
1464 {
1465 int jj, j0, j1, j2;
1466 const int nrow_src = src_mtrx->nrowBlock(iblock1, jblock0);
1467 // const int itmp = (ir_bgn_src + nrow) % SIZE_B1;
1468 // const int nnrow = (itmp == 0) ? SIZE_B1 : itmp;
1469 const int nnrow = ir_bgn_src + nrow - src_mtrx->IndexBlock(iblock1);
1470 T *src_pt0 = src_mtrx->addrCoefBlock(iblock1, jblock0);
1471 T *src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock1);
1472 if (jblock0 == iblock1) {
1473 for (j1 = ncol_src_offset * nrow_src,
1474 j2 = ncol_src_offset, // transposed
1475 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1476 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1477 j0 += dst_row, j1 += nrow_src, j2++) {
1478 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1479 blas_axpy<T>(nnrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1480 }
1481 }
1482 else {
1483 for (j1 = ncol_src_offset * nrow_src,
1484 j0 = ir_start + jc_bgn * dst_row, // ( ,jc_bgn)-( +nnrow,jc_end)
1485 jj = jc_bgn; jj < jc_end; jj++, // drinving index
1486 j0 += dst_row, j1 += nrow_src) {
1487 blas_axpy<T>(nnrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1488 blas_axpy<T>(nnrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1489 }
1490 }
1491 }
1492 }
1493 else {
1494 diss_printf(arg->verbose, arg->fp,
1495 "%s %d : bad block indices in column : %d %d\n",
1496 __FILE__, __LINE__, jblock0, jblock1);
1497 }
1498 }
1499 else {
1500 if ((jblock0 + 1) == jblock1) {
1501 const int jc_mid_src = src_mtrx->IndexBlock(jblock1);
1502 const int ncol0 = jc_mid_src - jc_bgn_src;
1503 const int jc_mid = jc_bgn + ncol0;
1504 {
1505 int jj, j0, j1, j2;
1506 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1507 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
1508 T *src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock0);
1509 if (jblock0 == iblock0) {
1510 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1511 j2 = ncol_src_offset + nrow_src_offset * nrow_src, //transposed
1512 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_mid)
1513 jj = jc_bgn; jj < jc_mid; jj++, // driving index
1514 j0 += dst_row, j1 += nrow_src, j2++) {
1515 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1516 blas_axpy<T>(nrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1517 }
1518 }
1519 else {
1520 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1521 j0 = ir_bgn + jc_bgn * dst_row, //(ir_bgn,jc_bgn)-(ir_end,jc_mid)
1522 jj = jc_bgn; jj < jc_mid; jj++, // driving index
1523 j0 += dst_row, j1 += nrow_src) {
1524 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1525 blas_axpy<T>(nrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1526 }
1527 }
1528 }
1529 {
1530 int jj, j0, j1, j2;
1531 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock1);
1532 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock1);
1533 T *src_pt1 = src_mtrx->addrCoefBlock(jblock1, iblock0);
1534 if (jblock1 == iblock0) {
1535 for (j1 = nrow_src_offset,
1536 j2 = nrow_src_offset * nrow_src, //
1537 j0 = ir_bgn + jc_mid * dst_row, //(ir_bgn,jc_mid)-(ir_end,jc_end)
1538 jj = jc_mid; jj < jc_end; jj++, // driving index
1539 j0 += dst_row, j1 += nrow_src, j2++) {
1540 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1541 blas_axpy<T>(nrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1542 }
1543 }
1544 else {
1545 // distnation :
1546 for (j1 = nrow_src_offset,
1547 j0 = ir_bgn + jc_mid * dst_row, //(ir_bgn,jc_mid)-(ir_end,jc_end)
1548 jj = jc_mid; jj < jc_end; jj++, // driving index
1549 j0 += dst_row, j1 += nrow_src) {
1550 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1551 blas_axpy<T>(nrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1552 }
1553 }
1554 }
1555 }
1556 else if (jblock0 == jblock1) {
1557 int jj, j0, j1, j2;
1558 const int nrow_src = src_mtrx->nrowBlock(iblock0, jblock0);
1559 T *src_pt0 = src_mtrx->addrCoefBlock(iblock0, jblock0);
1560 T *src_pt1 = src_mtrx->addrCoefBlock(jblock0, iblock0);
1561 if (jblock0 == iblock0) {
1562 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1563 j2 = ncol_src_offset + nrow_src_offset * nrow_src,
1564 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
1565 jj = jc_bgn; jj < jc_end; jj++, // driving index
1566 j0 += dst_row, j1 += nrow_src, j2++) {
1567 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1568 blas_axpy<T>(nrow, none, src_pt1 + j2, nrow_src, dst_pt2 + j0, 1);
1569 }
1570 }
1571 else {
1572 for (j1 = nrow_src_offset + ncol_src_offset * nrow_src,
1573 j0 = ir_bgn + jc_bgn * dst_row, // (ir_bgn,jc_bgn)-(ir_end,jc_end)
1574 jj = jc_bgn; jj < jc_end; jj++, // driving index
1575 j0 += dst_row, j1 += nrow_src) {
1576 blas_axpy<T>(nrow, none, src_pt0 + j1, 1, dst_pt + j0, 1);
1577 blas_axpy<T>(nrow, none, src_pt1 + j1, 1, dst_pt2 + j0, 1);
1578 }
1579 }
1580 }
1581 else {
1582 diss_printf(arg->verbose, arg->fp,
1583 "%s %d : bad block indices in column : %d %d\n",
1584 __FILE__, __LINE__, jblock0, jblock1);
1585 }
1586 } // if (iblock0 < iblock1)
1587 }
1588
1589 template
1590 void dsub_unsym2rct<double>(C_Dsub_task<double> *arg);
1591
1592 template
1593 void dsub_unsym2rct<quadruple>(C_Dsub_task<quadruple> *arg);
1594
1595 template
1596 void dsub_unsym2rct<complex<double> >(C_Dsub_task<complex<double> > *arg);
1597
1598 template
1599 void dsub_unsym2rct<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1600 // end of template function dsub_unsym2rct<T>
1601
1602 template
1603 void dsub_unsym2rct<float>(C_Dsub_task<float> *arg);
1604
1605 template
1606 void dsub_unsym2rct<complex<float> >(C_Dsub_task<complex<float> > *arg);
1607
1608
1609 template<typename T>
1610 void dsub_sym2sym_diag_two(C_Dsub_task<T> *arg)
1611 {
1612 if (arg->isSkip) {
1613 return;
1614 }
1615 C_Dsub_task<T> *tmp;
1616 tmp = new C_Dsub_task<T>(arg->atomic_size,
1617 arg->atomic_id,
1618 arg->ir_bgn,
1619 arg->ir_end,
1620 (-1), // jc_bgn
1621 (-1), // jc_end
1622 arg->ir_bgn_src,
1623 (-1), // ir_bgn_src2
1624 (-1), // jc_bgn_src
1625 (-1), // jc_bgn_src2
1626 arg->dst_row,
1627 arg->dst_mtrx,
1628 (RectBlockMatrix<T> *)NULL, // dst_pt
1629 arg->ir_block,
1630 arg->jc_block,
1631 (RectBlockMatrix<T> *)NULL, // dst_pt2
1632 (-1),
1633 (-1),
1634 arg->src_pt,
1635 (SquareBlockMatrix<T>*)NULL, // src_pt2
1636 dsub_sym2sym_diag,
1637 false, // dummy
1638 *(arg->ops_complexity),
1639 arg->father_id,
1640 arg->level,
1641 arg->verbose,
1642 arg->fp);
1643 dsub_sym2sym_diag<T>(tmp);
1644 delete tmp;
1645 tmp = new C_Dsub_task<T>(arg->atomic_size,
1646 arg->atomic_id,
1647 arg->ir_bgn,
1648 arg->ir_end,
1649 (-1), // jc_bgn
1650 (-1), // jc_end
1651 arg->ir_bgn_src2,
1652 (-1), // ir_bgn_src2
1653 (-1), // jc_bgn_src
1654 (-1), // jc_bgn_src2
1655 arg->dst_row,
1656 arg->dst_mtrx,
1657 (RectBlockMatrix<T> *)NULL, // dst_pt2
1658 arg->ir_block,
1659 arg->jc_block,
1660 (RectBlockMatrix<T> *)NULL, // dst_pt2
1661 (-1),
1662 (-1),
1663 arg->src_pt2,
1664 (SquareBlockMatrix<T>*)NULL, // src_pt2
1665 dsub_sym2sym_diag,
1666 false, // dummy
1667 *(arg->ops_complexity),
1668 arg->father_id,
1669 arg->level,
1670 arg->verbose,
1671 arg->fp);
1672 dsub_sym2sym_diag<T>(tmp);
1673 delete tmp;
1674 }
1675
1676 template
1677 void dsub_sym2sym_diag_two<double>(C_Dsub_task<double> *arg);
1678
1679 template
1680 void dsub_sym2sym_diag_two<quadruple>(C_Dsub_task<quadruple> *arg);
1681
1682 template
1683 void dsub_sym2sym_diag_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
1684
1685 template
1686 void dsub_sym2sym_diag_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1687
1688 template
1689 void dsub_sym2sym_diag_two<float>(C_Dsub_task<float> *arg);
1690
1691 template
1692 void dsub_sym2sym_diag_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
1693
1694
1695 // end of template function dsub_sym2sym_diag_two<T>
1696
1697 template<typename T>
1698 void dsub_unsym2unsym_diag_two(C_Dsub_task<T> *arg)
1699 {
1700 if (arg->isSkip) {
1701 return;
1702 }
1703 C_Dsub_task<T> *tmp;
1704
1705 tmp = new C_Dsub_task<T>(arg->atomic_size,
1706 arg->atomic_id,
1707 arg->ir_bgn,
1708 arg->ir_end,
1709 (-1), // jc_bgn
1710 (-1), // jc_end
1711 arg->ir_bgn_src,
1712 (-1), // ir_bgn_src2
1713 (-1), // jc_bgn_src
1714 (-1), // jc_bgn_src2
1715 arg->dst_row,
1716 arg->dst_mtrx,
1717 (RectBlockMatrix<T> *)NULL, // dst_pt2
1718 arg->ir_block,
1719 arg->jc_block,
1720 (RectBlockMatrix<T> *)NULL, // dst_pt2
1721 (-1),
1722 (-1),
1723 arg->src_pt,
1724 (SquareBlockMatrix<T>*)NULL, // src_pt2
1725 dsub_unsym2unsym_diag,
1726 false, // dummy
1727 *(arg->ops_complexity),
1728 arg->father_id,
1729 arg->level,
1730 arg->verbose,
1731 arg->fp);
1732 dsub_unsym2unsym_diag<T>(tmp);
1733 delete tmp;
1734 tmp = new C_Dsub_task<T>(arg->atomic_size,
1735 arg->atomic_id,
1736 arg->ir_bgn,
1737 arg->ir_end,
1738 (-1), // jc_bgn
1739 (-1), // jc_end
1740 arg->ir_bgn_src2,
1741 (-1), // ir_bgn_src2
1742 (-1), // jc_bgn_src
1743 (-1), // jc_bgn_src2
1744 arg->dst_row,
1745 arg->dst_mtrx,
1746 (RectBlockMatrix<T> *)NULL, // dst_pt2
1747 arg->ir_block,
1748 arg->jc_block,
1749 (RectBlockMatrix<T> *)NULL, // dst_pt2
1750 (-1),
1751 (-1),
1752 arg->src_pt2,
1753 (SquareBlockMatrix<T>*)NULL, // src_pt2
1754 dsub_unsym2unsym_diag,
1755 false, // dummy
1756 *(arg->ops_complexity),
1757 arg->father_id,
1758 arg->level,
1759 arg->verbose,
1760 arg->fp);
1761 dsub_unsym2unsym_diag<T>(tmp);
1762 delete tmp;
1763 }
1764
1765 template
1766 void dsub_unsym2unsym_diag_two<double>(C_Dsub_task<double> *arg);
1767
1768 template
1769 void dsub_unsym2unsym_diag_two<quadruple>(C_Dsub_task<quadruple> *arg);
1770
1771 template
1772 void dsub_unsym2unsym_diag_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
1773
1774 template
1775 void dsub_unsym2unsym_diag_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1776
1777 template
1778 void dsub_unsym2unsym_diag_two<float>(C_Dsub_task<float> *arg);
1779
1780 template
1781 void dsub_unsym2unsym_diag_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
1782
1783 // end of template function dsub_unsym2unsym_diag_two<T>
1784
1785 template<typename T>
1786 void dsub_sym2sym_two(C_Dsub_task<T> *arg)
1787 {
1788 if (arg->isSkip) {
1789 return;
1790 }
1791 C_Dsub_task<T> *tmp;
1792 tmp = new C_Dsub_task<T>(arg->atomic_size,
1793 arg->atomic_id,
1794 arg->ir_bgn,
1795 arg->ir_end,
1796 arg->jc_bgn,
1797 arg->jc_end,
1798 arg->ir_bgn_src,
1799 (-1), // ir_bgn_src2
1800 arg->jc_bgn_src,
1801 (-1), // jc_bgn_src2
1802 arg->dst_row,
1803 arg->dst_mtrx,
1804 (RectBlockMatrix<T> *)NULL, // dst_pt2
1805 arg->ir_block,
1806 arg->jc_block,
1807 (RectBlockMatrix<T> *)NULL, // dst_pt2
1808 (-1),
1809 (-1),
1810 arg->src_pt,
1811 (SquareBlockMatrix<T>*)NULL, // src_pt2
1812 dsub_sym2sym,
1813 false, // dummy
1814 *(arg->ops_complexity),
1815 arg->father_id,
1816 arg->level,
1817 arg->verbose,
1818 arg->fp);
1819 dsub_sym2sym<T>(tmp);
1820 delete tmp;
1821 tmp = new C_Dsub_task<T>(arg->atomic_size,
1822 arg->atomic_id,
1823 arg->ir_bgn,
1824 arg->ir_end,
1825 arg->jc_bgn,
1826 arg->jc_end,
1827 arg->ir_bgn_src2,
1828 (-1), // ir_bgn_src2
1829 arg->jc_bgn_src2,
1830 (-1), // jc_bgn_src2
1831 arg->dst_row,
1832 arg->dst_mtrx,
1833 (RectBlockMatrix<T> *)NULL, // dst_pt2
1834 arg->ir_block,
1835 arg->jc_block,
1836 (RectBlockMatrix<T> *)NULL, // dst_pt2
1837 (-1),
1838 (-1),
1839 arg->src_pt2,
1840 (SquareBlockMatrix<T>*)NULL, // src_pt2
1841 dsub_sym2sym,
1842 false, // dummy
1843 *(arg->ops_complexity),
1844 arg->father_id,
1845 arg->level,
1846 arg->verbose,
1847 arg->fp);
1848 dsub_sym2sym<T>(tmp);
1849 delete tmp;
1850 }
1851
1852 template
1853 void dsub_sym2sym_two<double>(C_Dsub_task<double> *arg);
1854
1855 template
1856 void dsub_sym2sym_two<quadruple>(C_Dsub_task<quadruple> *arg);
1857
1858 template
1859 void dsub_sym2sym_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
1860
1861 template
1862 void dsub_sym2sym_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1863
1864 template
1865 void dsub_sym2sym_two<float>(C_Dsub_task<float> *arg);
1866
1867 template
1868 void dsub_sym2sym_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
1869 // end of template function dsub_sym2sym_two<T>
1870
1871
1872 template<typename T>
1873 void dsub_unsym2unsym_two(C_Dsub_task<T> *arg)
1874 {
1875 if (arg->isSkip) {
1876 return;
1877 }
1878 C_Dsub_task<T> *tmp;
1879 tmp = new C_Dsub_task<T>(arg->atomic_size,
1880 arg->atomic_id,
1881 arg->ir_bgn,
1882 arg->ir_end,
1883 arg->jc_bgn,
1884 arg->jc_end,
1885 arg->ir_bgn_src,
1886 (-1), // ir_bgn_src2
1887 arg->jc_bgn_src,
1888 (-1), // jc_bgn_src2
1889 arg->dst_row,
1890 arg->dst_mtrx,
1891 (RectBlockMatrix<T> *)NULL, // dst_pt2
1892 arg->ir_block,
1893 arg->jc_block,
1894 (RectBlockMatrix<T> *)NULL, // dst_pt2
1895 (-1),
1896 (-1),
1897 arg->src_pt,
1898 (SquareBlockMatrix<T>*)NULL, // src_pt2
1899 dsub_unsym2unsym,
1900 false, // dummy
1901 *(arg->ops_complexity),
1902 arg->father_id,
1903 arg->level,
1904 arg->verbose,
1905 arg->fp);
1906 dsub_unsym2unsym<T>(tmp);
1907 delete tmp;
1908 tmp = new C_Dsub_task<T>(arg->atomic_size,
1909 arg->atomic_id,
1910 arg->ir_bgn,
1911 arg->ir_end,
1912 arg->jc_bgn,
1913 arg->jc_end,
1914 arg->ir_bgn_src2,
1915 (-1), // ir_bgn_src2
1916 arg->jc_bgn_src2,
1917 (-1), // jc_bgn_src2
1918 arg->dst_row,
1919 arg->dst_mtrx,
1920 (RectBlockMatrix<T> *)NULL, // dst_pt2
1921 arg->ir_block,
1922 arg->jc_block,
1923 (RectBlockMatrix<T> *)NULL, // dst_pt2
1924 (-1),
1925 (-1),
1926 arg->src_pt2,
1927 (SquareBlockMatrix<T>*)NULL, // src_pt2
1928 dsub_unsym2unsym,
1929 false, // dummy
1930 *(arg->ops_complexity),
1931 arg->father_id,
1932 arg->level,
1933 arg->verbose,
1934 arg->fp);
1935 dsub_unsym2unsym<T>(tmp);
1936 delete tmp;
1937 }
1938 template
1939 void dsub_unsym2unsym_two<double>(C_Dsub_task<double> *arg);
1940
1941 template
1942 void dsub_unsym2unsym_two<quadruple>(C_Dsub_task<quadruple> *arg);
1943
1944 template
1945 void dsub_unsym2unsym_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
1946
1947 template
1948 void dsub_unsym2unsym_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
1949
1950 template
1951 void dsub_unsym2unsym_two<float>(C_Dsub_task<float> *arg);
1952
1953 template
1954 void dsub_unsym2unsym_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
1955
1956 // end of template function dsub_unsym2unsym_two<T>
1957
1958 template<typename T>
1959 void dsub_unsym2diag_two(C_Dsub_task<T> *arg)
1960 {
1961 if (arg->isSkip) {
1962 return;
1963 }
1964 C_Dsub_task<T> *tmp;
1965 tmp = new C_Dsub_task<T>(arg->atomic_size,
1966 arg->atomic_id,
1967 arg->ir_bgn,
1968 arg->ir_end,
1969 arg->jc_bgn,
1970 arg->jc_end,
1971 arg->ir_bgn_src,
1972 (-1), // ir_bgn_src2
1973 arg->jc_bgn_src,
1974 (-1), // jc_bgn_src2
1975 arg->dst_row,
1976 arg->dst_mtrx,
1977 (RectBlockMatrix<T> *)NULL, // dst_pt2
1978 arg->ir_block,
1979 arg->jc_block,
1980 (RectBlockMatrix<T> *)NULL, // dst_pt2
1981 (-1),
1982 (-1),
1983 arg->src_pt,
1984 (SquareBlockMatrix<T>*)NULL, // src_pt2
1985 dsub_unsym2unsym,
1986 false, // dummy
1987 *(arg->ops_complexity),
1988 arg->father_id,
1989 arg->level,
1990 arg->verbose,
1991 arg->fp);
1992 dsub_unsym2diag<T>(tmp);
1993 delete tmp;
1994 tmp = new C_Dsub_task<T>(arg->atomic_size,
1995 arg->atomic_id,
1996 arg->ir_bgn,
1997 arg->ir_end,
1998 arg->jc_bgn,
1999 arg->jc_end,
2000 arg->ir_bgn_src2,
2001 (-1), // ir_bgn_src2
2002 arg->jc_bgn_src2,
2003 (-1), // jc_bgn_src2
2004 arg->dst_row,
2005 arg->dst_mtrx,
2006 (RectBlockMatrix<T> *)NULL, // dst_pt2
2007 arg->ir_block,
2008 arg->jc_block,
2009 (RectBlockMatrix<T> *)NULL, // dst_pt2
2010 (-1),
2011 (-1),
2012 arg->src_pt2,
2013 (SquareBlockMatrix<T>*)NULL, // src_pt2
2014 dsub_unsym2unsym,
2015 false, // dummy
2016 *(arg->ops_complexity),
2017 arg->father_id,
2018 arg->level,
2019 arg->verbose,
2020 arg->fp);
2021 dsub_unsym2diag<T>(tmp);
2022 delete tmp;
2023 }
2024
2025 template
2026 void dsub_unsym2diag_two<double>(C_Dsub_task<double> *arg);
2027
2028 template
2029 void dsub_unsym2diag_two<quadruple>(C_Dsub_task<quadruple> *arg);
2030
2031 template
2032 void dsub_unsym2diag_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
2033
2034 template
2035 void dsub_unsym2diag_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
2036
2037 template
2038 void dsub_unsym2diag_two<float>(C_Dsub_task<float> *arg);
2039
2040 template
2041 void dsub_unsym2diag_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
2042
2043 // end of template function dsub_unsym2diag_two<T>
2044
2045 template<typename T>
2046 void dsub_sym2rct_two(C_Dsub_task<T> *arg)
2047 {
2048 C_Dsub_task<T> *tmp;
2049 tmp = new C_Dsub_task<T>(arg->atomic_size,
2050 arg->atomic_id,
2051 arg->ir_bgn,
2052 arg->ir_end,
2053 arg->jc_bgn,
2054 arg->jc_end,
2055 arg->ir_bgn_src,
2056 (-1), // ir_bgn_src2
2057 arg->jc_bgn_src,
2058 (-1), // jc_bgn_src2
2059 arg->dst_row,
2060 (SquareBlockMatrix<T>*)NULL, // src_pt2
2061 arg->dst_pt,
2062 arg->ir_block, // 0,
2063 arg->jc_block, // 0,
2064 (RectBlockMatrix<T> *)NULL, // dst_pt2
2065 (-1),
2066 (-1),
2067 arg->src_pt,
2068 (SquareBlockMatrix<T>*)NULL, // src_pt2
2069 dsub_sym2rct,
2070 false, // dummy
2071 *(arg->ops_complexity),
2072 arg->father_id,
2073 arg->level,
2074 arg->verbose,
2075 arg->fp);
2076 // tmp->verbose = false;
2077 dsub_sym2rct<T>(tmp);
2078 delete tmp;
2079 tmp = new C_Dsub_task<T>(arg->atomic_size,
2080 arg->atomic_id,
2081 arg->ir_bgn,
2082 arg->ir_end,
2083 arg->jc_bgn,
2084 arg->jc_end,
2085 arg->ir_bgn_src2,
2086 (-1), // ir_bgn_src2
2087 arg->jc_bgn_src2,
2088 (-1), // jc_bgn_src2
2089 arg->dst_row,
2090 (SquareBlockMatrix<T>*)NULL, // src_pt2
2091 arg->dst_pt,
2092 arg->ir_block, //0,
2093 arg->jc_block, //0,
2094 (RectBlockMatrix<T> *)NULL, // dst_pt2
2095 (-1),
2096 (-1),
2097 arg->src_pt2,
2098 (SquareBlockMatrix<T>*)NULL, // src_pt2
2099 dsub_sym2rct,
2100 false, // dummy
2101 *(arg->ops_complexity),
2102 arg->father_id,
2103 arg->level,
2104 arg->verbose,
2105 arg->fp);
2106 // tmp->verbose = false;
2107 dsub_sym2rct<T>(tmp);
2108 delete tmp;
2109 }
2110
2111 template
2112 void dsub_sym2rct_two<double>(C_Dsub_task<double> *arg);
2113
2114 template
2115 void dsub_sym2rct_two<quadruple>(C_Dsub_task<quadruple> *arg);
2116
2117 template
2118 void dsub_sym2rct_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
2119
2120 template
2121 void dsub_sym2rct_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
2122
2123 template
2124 void dsub_sym2rct_two<float>(C_Dsub_task<float> *arg);
2125
2126 template
2127 void dsub_sym2rct_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
2128
2129 // end of template function dsub_sym2rct_two<T>
2130
2131 template<typename T>
2132 void dsub_unsym2rct_two(C_Dsub_task<T> *arg)
2133 {
2134 C_Dsub_task<T> *tmp;
2135 tmp = new C_Dsub_task<T>(arg->atomic_size,
2136 arg->atomic_id,
2137 arg->ir_bgn,
2138 arg->ir_end,
2139 arg->jc_bgn,
2140 arg->jc_end,
2141 arg->ir_bgn_src,
2142 (-1), // ir_bgn_src2
2143 arg->jc_bgn_src,
2144 (-1), // jc_bgn_src2
2145 arg->dst_row,
2146 (SquareBlockMatrix<T>*)NULL, // src_pt2
2147 arg->dst_pt,
2148 arg->ir_block,//0,
2149 arg->jc_block, //0,
2150 arg->dst_pt2,
2151 0,
2152 0,
2153 arg->src_pt,
2154 (SquareBlockMatrix<T>*)NULL, // src_pt2
2155 dsub_unsym2rct,
2156 false, // dummy
2157 *(arg->ops_complexity),
2158 arg->father_id,
2159 arg->level,
2160 arg->verbose,
2161 arg->fp);
2162 dsub_unsym2rct<T>(tmp);
2163 delete tmp;
2164 tmp = new C_Dsub_task<T>(arg->atomic_size,
2165 arg->atomic_id,
2166 arg->ir_bgn,
2167 arg->ir_end,
2168 arg->jc_bgn,
2169 arg->jc_end,
2170 arg->ir_bgn_src2,
2171 (-1), // ir_bgn_src2
2172 arg->jc_bgn_src2,
2173 (-1), // jc_bgn_src2
2174 arg->dst_row,
2175 (SquareBlockMatrix<T>*)NULL, // src_pt2
2176 arg->dst_pt,
2177 arg->ir_block, //0,
2178 arg->jc_block,//0,
2179 arg->dst_pt2,
2180 0,
2181 0,
2182 arg->src_pt2,
2183 (SquareBlockMatrix<T>*)NULL, // src_pt2
2184 dsub_unsym2rct,
2185 false, // dummy
2186 *(arg->ops_complexity),
2187 arg->father_id,
2188 arg->level,
2189 arg->verbose,
2190 arg->fp);
2191 dsub_unsym2rct<T>(tmp);
2192 delete tmp;
2193 }
2194
2195 template
2196 void dsub_unsym2rct_two<double>(C_Dsub_task<double> *arg);
2197
2198 template
2199 void dsub_unsym2rct_two<quadruple>(C_Dsub_task<quadruple> *arg);
2200
2201 template
2202 void dsub_unsym2rct_two<complex<double> >(C_Dsub_task<complex<double> > *arg);
2203
2204 template
2205 void dsub_unsym2rct_two<complex<quadruple> >(C_Dsub_task<complex<quadruple> > *arg);
2206
2207 template
2208 void dsub_unsym2rct_two<float>(C_Dsub_task<float> *arg);
2209
2210 template
2211 void dsub_unsym2rct_two<complex<float> >(C_Dsub_task<complex<float> > *arg);
2212
2213
2214 // end of template function dsub_unsym2rct_two<T>
2215
2216 //#define DEBUG_QUEUE_GENERATION2
2217 //#define DEBUG_QUEUE_GENERATION
2218
2219 //#define DEBUG_PREPARE_THREAD
2220 //#define DEBUG_PREPARE_THREAD_DEBUG
2221
2222 template<typename T>
2223 void C_Dsub_queue(bool isSym,
2224 int father_id,
2225 bool skip_flag,
2226 vector<C_task *>& queue,
2227 list <child_contribution<T> > &child_contrib,
2228 vector<C_task *>* tasks_p, // _tasks_DSymmGEMM
2229 vector<int>* tasks_p_indcol,
2230 const bool tasks_p_flag,
2231 vector<C_task *>& tasks_q, // _tasks_DfillSymm
2232 vector<C_task *>* tasks_r, // _tasks_SparseLocalSchur
2233 vector<C_task *>& tasks_s, // _tasks_DSub[level + 1][(*it)]
2234 vector<C_task *>* tasks_d, // _tasks_deallocateLocalSchur
2235 vector<int>* tasks_d_indcol,
2236 int level,
2237 const bool direct_flag,
2238 const bool verbose,
2239 FILE *fp)
2240 {
2241 // list <child_contribution>& child_contrib = child_contribs[*it];
2242 const int diag_size = child_contrib.front().diag_size;
2243 const int father_row = child_contrib.front().father_row;
2244
2245 const int size_res = diag_size % SIZE_B1;
2246 // const int size_res2 = offdiag_size % SIZE_B1;
2247 int num_block;
2248 num_block = diag_size / SIZE_B1 + (size_res != 0);
2249 // const int num_block2 = (offdiag_size / SIZE_B1 + (size_res2 != 0));
2250 const int num_block2 = child_contrib.front().father_offdiag_pt->num_blocks_c();
2251 const int block_diag_size = (num_block * (num_block + 1)) / 2;
2252 const int block_offdiag_size = num_block * num_block2;
2253
2254 // vector<C_task *>* tasks_p = ((tasks_p_ == NULL) ? NULL :
2255 // (tasks_p_->size() > 0 ? tasks_p_ : NULL));
2256 if (diag_size == 0) {
2257 queue.resize(1);
2258 int nb = father_id + 1;
2259 string task_name = ("i dummy : " +
2260 to_string(level) + " : " +to_string(nb));
2261 C_dummy_arg *arg = new C_dummy_arg(verbose, &fp, nb);
2262 // *(arg->ops_complexity) = (-1L);
2263 queue[0] = new C_task(C_DUMMY,
2264 task_name,
2265 (void *)arg,
2266 C_dummy,
2267 1, // atomic_size,
2268 0, // atomic_id,
2269 arg->ops_complexity);
2270 queue[0]->parents->clear();
2271 diss_printf(verbose, fp, "%s %d : %s\n",
2272 __FILE__, __LINE__, task_name.c_str());
2273 return;
2274 }
2275 #ifdef DEBUG_PREPARE_THREAD
2276 cout << "father = " << (father_id + 1) // selfIndex^-1
2277 << " # of child = " << child_contrib.size() << " [ ";
2278 #endif
2279 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
2280 jt != child_contrib.end(); ++jt) {
2281 #ifdef DEBUG_PREPARE_THREAD
2282 cout << (*jt).child_id << " ";
2283 #endif
2284 }
2285 #ifdef DEBUG_PREPARE_THREAD
2286 cout << "]" << endl;
2287 #endif
2288 #ifdef DEBUG_STRIPES
2289 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
2290 jt != child_contrib.end(); ++jt) {
2291 cout << "child = " << (*jt).child_id << endl;
2292 cout << "diag = ";
2293 for (list <index_strip>::const_iterator kt = (*jt).diag_strip.begin();
2294 kt != (*jt).diag_strip.end();
2295 ++kt) {
2296 cout << "[ " << (*kt).begin_dst << " , "
2297 << (*kt).begin_src << " , "
2298 << (*kt).width << " ] ";
2299 }
2300 cout << endl;
2301 cout << "offdiag = ";
2302 for (list <index_strip>::const_iterator kt = (*jt).offdiag_strip.begin();
2303 kt != (*jt).offdiag_strip.end();
2304 ++kt) {
2305 cout << "[ " << (*kt).begin_dst << " , "
2306 << (*kt).begin_src << " , "
2307 << (*kt).width << " ] ";
2308 }
2309 cout << endl;
2310 } // loop: jt
2311 #endif
2312 //
2313 if (child_contrib.size() == 2 && direct_flag) {
2314 // vector<C_task *>&queue = tasks_C_DSUB[*it];
2315 // queue.resize(block_diag_size + num_block2);
2316 // vector<list<C_Dsub_task *>*>&C_task_arg = lists_C_DSUB[*it];
2317 // C_task_arg.resize(block_diag_size + num_block2);
2318 #ifdef DEBUG_PREPARE_THREAD_DEBUG
2319 cout << "2 children resize = " << block_diag_size + num_block2 << " ";
2320 #endif
2321 child_contribution<T> child0 = child_contrib.front();
2322 child_contribution<T> child1 = child_contrib.back();
2323 if ((child0.child_pt->dimension() == 0) ||
2324 (child1.child_pt->dimension() == 0)) {
2325 diss_printf(verbose, fp ,
2326 "%s %d : %d %d %d : %d %d %d\n", __FILE__, __LINE__,
2327 child0.child_id,
2328 (int)child0.diag_strip.size(),
2329 (int)child0.offdiag_strip.size(),
2330 child1.child_id,
2331 (int)child1.diag_strip.size(),
2332 (int)child1.offdiag_strip.size());
2333 }
2334
2335 list <index_strip> *strips_r, *strips_c;
2336 strips_r = new list <index_strip>[2];
2337 strips_c = new list <index_strip>[2];
2338 list <index_strip2> strips_r01, strips_c01;
2339 int *child_id = new int[2];
2340 child_id[0] = child0.child_id;
2341 child_id[1] = child1.child_id;
2342 // double ***child_pt = new double**[2];
2343 SquareBlockMatrix<T>** child_pt = new SquareBlockMatrix<T>*[2];
2344 child_pt[0] = child0.child_pt;
2345 child_pt[1] = child1.child_pt;
2346 SquareBlockMatrix<T> *father_diag_pt = child0.father_diag_pt;
2347 RectBlockMatrix<T> *father_offdiag_pt = child0.father_offdiag_pt;
2348 RectBlockMatrix<T> *father_offdia2_pt = child0.father_offdiag_unsym_pt;
2349
2350 diss_printf(verbose, fp, "%s %d : father id = %d\n",
2351 __FILE__, __LINE__, (father_id + 1));
2352 if (child0.diag_strip.size() > 1 || child1.diag_strip.size() > 1) {
2353 #ifdef DEBUG_PREPARE_THREAD
2354 diss_printf(verbose, fp, "%s %d : row block is not continous\n",
2355 __FILE__, __LINE__);
2356 #endif
2357 combine_two_strips(strips_r[0], strips_r[1], strips_r01,
2358 child0.diag_strip,
2359 child1.diag_strip,
2360 child0.diag_size);
2361 }
2362 else {
2363 if ((child0.diag_strip.size() == 0) &&
2364 (child1.diag_strip.size() == 0)) {
2365 diss_printf(verbose, fp, "%s %d : both rows are null : father = %d\n",
2366 __FILE__, __LINE__, (father_id + 1));
2367 strips_r[0].clear();
2368 strips_r[1].clear();
2369 strips_r01.clear();
2370 }
2371 if ((child0.diag_strip.size() == 0) ||
2372 (child1.diag_strip.size() == 0)) {
2373 diss_printf(verbose, fp, "%s %d : one of rows is null / ",
2374 __FILE__, __LINE__);
2375 if (child0.diag_strip.size() == 0) {
2376 diss_printf(verbose, fp, " r0 null / ");
2377 strips_r[0].clear();
2378 strips_r[1] = child1.diag_strip;
2379 }
2380 else {
2381 diss_printf(verbose, fp, "%d : %d / ",
2382 child0.diag_strip.front().begin_dst,
2383 child0.diag_strip.front().width);
2384 }
2385 if (child1.diag_strip.size() == 0) {
2386 diss_printf(verbose, fp, " r1 null\n");
2387 strips_r[0] = child0.diag_strip;
2388 strips_r[1].clear();
2389 }
2390 else {
2391 diss_printf(verbose, fp, "%d : %d\n",
2392 child1.diag_strip.front().begin_dst,
2393 child1.diag_strip.front().width);
2394 }
2395 strips_r01.clear();
2396 } // (child0.diag_strip.size() == 0) || (child1.diag_strip.size() == 0)
2397 else {
2398 if ((child0.diag_strip.front().begin_dst !=
2399 child1.diag_strip.front().begin_dst) ||
2400 (child0.diag_strip.front().width !=
2401 child1.diag_strip.front().width)) {
2402 diss_printf(verbose, fp,
2403 "%s %d : row blocks are not same / ",
2404 __FILE__, __LINE__);
2405 diss_printf(verbose, fp, "%d : %d : %d / %d : %d : %d\n",
2406 (int)child0.diag_strip.size(),
2407 child0.diag_strip.front().begin_dst,
2408 child0.diag_strip.front().width,
2409 (int)child1.diag_strip.size(),
2410 child1.diag_strip.front().begin_dst,
2411 child1.diag_strip.front().width);
2412 split_two_strips(strips_r[0], strips_r[1], strips_r01,
2413 child0.diag_strip.front(),
2414 child1.diag_strip.front());
2415 diss_printf(verbose, fp, "%s %d : split of strips r0 ",
2416 __FILE__, __LINE__);
2417 for (list<index_strip>::const_iterator kt = strips_r[0].begin();
2418 kt != strips_r[0].end(); ++kt) {
2419 diss_printf(verbose, fp, "%d : %d : %d ",
2420 (*kt).begin_dst, (*kt).begin_src, (*kt).width);
2421 }
2422 diss_printf(verbose, fp, " r1 ");
2423 for (list<index_strip>::const_iterator kt = strips_r[1].begin();
2424 kt != strips_r[1].end(); ++kt) {
2425 diss_printf(verbose, fp, "%d : %d : %d ",
2426 (*kt).begin_dst, (*kt).begin_src, (*kt).width);
2427 }
2428 diss_printf(verbose, fp, "r01 ");
2429 for (list<index_strip2>::const_iterator kt = strips_r01.begin();
2430 kt != strips_r01.end(); ++kt) {
2431 diss_printf(verbose, fp, "%d : %d : %d : %d ",
2432 (*kt).begin_dst, (*kt).begin_src0, (*kt).begin_src1,
2433 (*kt).width);
2434 }
2435 diss_printf(verbose, fp, "\n");
2436 }
2437 else {
2438 strips_r[0].clear();
2439 strips_r[1].clear();
2440 copy_two_strips(strips_r01, child0.diag_strip, child1.diag_strip);
2441 diss_printf(verbose, fp, "%s %d : r01 ", __FILE__, __LINE__);
2442 for (list<index_strip2>::const_iterator kt = strips_r01.begin();
2443 kt != strips_r01.end(); ++kt) {
2444 diss_printf(verbose, fp, "%d : %d : %d : %d ",
2445 (*kt).begin_dst, (*kt).begin_src0,
2446 (*kt).begin_src1, (*kt).width);
2447 }
2448 diss_printf(verbose, fp, "\n");
2449 }
2450 }// (child0.diag_strip.size() == 0) || (child1.diag_strip.size() == 0)
2451 } // (child0.diag_strip.size() > 1 || child1.diag_strip.size() > 1)
2452 if ((child0.offdiag_strip.size() > 0) &&
2453 (child1.offdiag_strip.size() > 0)) {
2454 combine_two_strips(strips_c[0], strips_c[1], strips_c01,
2455 child0.offdiag_strip,
2456 child1.offdiag_strip,
2457 child0.offdiag_size);
2458 }
2459 else if (child1.offdiag_strip.size() == 0) {
2460 strips_c[0]= child0.offdiag_strip;
2461 strips_c[1].clear();
2462 strips_c01.clear();
2463 }
2464 else { // (child0.offdiag_strip.size() == 0)
2465 strips_c[1]= child1.offdiag_strip;
2466 strips_c[0].clear();
2467 strips_c01.clear();
2468 }
2469 if ((child0.child_pt->dimension() == 0) ||
2470 (child1.child_pt->dimension() == 0)) {
2471 diss_printf(verbose, fp, "%s %d : %d %d %d\n", __FILE__, __LINE__,
2472 (int)strips_c[0].size(), (int)strips_c[1].size(),
2473 (int)strips_c01.size());
2474 }
2475 queue.resize(block_diag_size + num_block2);
2476 // queue.resize(block_diag_size + block_offdiag_size);
2477 diss_printf(verbose, fp, "%s %d : C_Dsub with father id = %d %d %d ",
2478 __FILE__, __LINE__, (father_id + 1), num_block, num_block2);
2479 if (skip_flag) {
2480 diss_printf(verbose, fp, "skipped\n");
2481 }
2482 else {
2483 diss_printf(verbose, fp, "\n");
2484 }
2485 int kk = 0;
2486 for (int kc0 = 0; kc0 < num_block; kc0++) {
2487 const int kc = kc0 * SIZE_B1;
2488 const int kc_end = (kc0 == num_block - 1) ? diag_size : (kc + SIZE_B1);
2489 for (int kr0 = 0; kr0 <= kc0; kr0++) { // running over upper blocks
2490 const int kr = kr0 * SIZE_B1;
2491 const int kr_end =
2492 (kr0 == num_block - 1) ? diag_size : (kr + SIZE_B1);
2493
2494 list<C_Dsub_task<T> *> *C_task_arg = new list<C_Dsub_task<T> *>;
2495 // C_task_arg[kk] = new list<C_Dsub_task *>;
2496 long *ops_sum = new long;
2497 *ops_sum = 0L;
2498 list<int>* parents_r = new list<int>[2];
2499 list<int>* parents_c = new list<int>[2];
2500
2501 // (child0 + child01 + child1) * (child0 + child01 + child1)
2502 // = child0 * child0 + child0 * child01
2503 // + child01 * child0 + child01 * child01 + child01 * child1
2504 // + child1 * child01 + child1 * child1
2505 //
2506 // diagonal contribution
2507 // tasks are stored in each queue _c_dsub_arg[*it][ ]
2508 // ---- child_ll * (child_ll + child01) ---- ll = 0, 1
2509 for (int ll = 0; ll < 2; ll++) {
2510 for (list <index_strip>::const_iterator mt = strips_r[ll].begin();
2511 mt != strips_r[ll].end(); ++mt) {
2512 const int r_bgn_dst = (*mt).begin_dst;
2513 const int r_end_dst = r_bgn_dst + (*mt).width;
2514 if (r_end_dst < kr) {
2515 continue; // continue loop : mt : strips_r[ll]
2516 }
2517 if (r_bgn_dst >= kr_end) {
2518 break; // break loop : mt : strips_r[ll]
2519 }
2520 const int ir_bgn = imax(kr, r_bgn_dst);
2521 const int ir_end = imin(kr_end, r_end_dst);
2522 const int ic_bgn = imax(kc, r_bgn_dst);
2523 const int ic_end = imin(kc_end, r_end_dst);
2524 // -- child_ll * child_ll
2525 if (kr == kc) {
2526 const long ops = ((long)(ir_end - ir_bgn) *
2527 ((long)(ir_end - ir_bgn) + 1L) / 2L);
2528 // diagonal : half size
2529 const int ir_bgn_src =
2530 ((*mt).begin_src + (ir_bgn - r_bgn_dst));
2531 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
2532 if (ir_bgn < ir_end) {
2533 C_Dsub_task<T> *tmp =
2534 new C_Dsub_task<T>(1,
2535 0,
2536 (ir_bgn - kr),
2537 (ir_end - kr),
2538 (-1), // jc_bgn
2539 (-1), // jc_end
2540 ir_bgn_src,
2541 (-1), // ir_bgn_src2
2542 (-1), // jc_bgn_src
2543 (-1), // jc_bgn_src2
2544 father_row,
2545 father_diag_pt,
2546 (RectBlockMatrix<T> *)NULL, // dst_pt
2547 kr0,
2548 kr0,
2549 (RectBlockMatrix<T> *)NULL, // dist_pt2
2550 (-1),
2551 (-1),
2552 child_pt[ll],
2553 (SquareBlockMatrix<T>*)NULL, // src_pt2
2554 (isSym ? dsub_sym2sym_diag<T> :
2555 dsub_unsym2unsym_diag<T>),
2556 false, // skip_flag
2557 ops,
2558 father_id,
2559 level,
2560 verbose,
2561 fp);
2562 tmp->child0_id = child_id[0];
2563 tmp->child1_id = child_id[1];
2564 C_task_arg->push_back(tmp);
2565 *ops_sum += ops;
2566 update_parents_list(parents_r[ll],
2567 ir_bgn_src, ir_end_src, child_pt[ll]);
2568 } // if (ir_bgn < ir_end)
2569 } // if (kr == kc)
2570 else { // kr < kc
2571 const long ops = ((long)(ir_end - ir_bgn) *
2572 (long)(ic_end - ic_bgn));
2573 const int ir_bgn_src =
2574 ((*mt).begin_src + (ir_bgn - r_bgn_dst));
2575 const int ic_bgn_src =
2576 ((*mt).begin_src + (ic_bgn - r_bgn_dst));
2577 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
2578 const int ic_end_src = ic_bgn_src + (ic_end - ic_bgn);
2579 if ((ir_bgn < ir_end) && (ic_bgn < ic_end)) {
2580 C_Dsub_task<T> *tmp =
2581 new C_Dsub_task<T>(1,
2582 0,
2583 (ir_bgn - kr),
2584 (ir_end - kr),
2585 (ic_bgn - kc),
2586 (ic_end - kc),
2587 ir_bgn_src,
2588 (-1), // ir_bgn_src2
2589 ic_bgn_src,
2590 (-1), // jc_bgn_src2
2591 father_row,
2592 father_diag_pt,
2593 (RectBlockMatrix<T> *)NULL, // dst_pt
2594 kr0,
2595 kc0,
2596 (RectBlockMatrix<T> *)NULL, // dist_pt2
2597 (-1),
2598 (-1),
2599 child_pt[ll],
2600 (SquareBlockMatrix<T>*)NULL, // src_pt2
2601 isSym ? dsub_sym2sym<T> : dsub_unsym2unsym<T>,
2602 false, // skip_flag
2603 ops,
2604 father_id,
2605 level,
2606 verbose,
2607 fp);
2608 C_task_arg->push_back(tmp);
2609 *ops_sum += ops;
2610
2611 update_parents_list(parents_r[ll],
2612 ir_bgn_src, ir_end_src, child_pt[ll]);
2613 update_parents_list(parents_c[ll],
2614 ic_bgn_src, ic_end_src, child_pt[ll]);
2615 //SIZE_B1);
2616 } // if ((ir_bgn < ir_end) && (ic_bgn < ic_end))
2617 } // if (kc == kr)
2618 // off-diagonal blocks
2619 list <index_strip>::const_iterator nt = mt;
2620 ++nt;
2621 for (; nt != strips_r[ll].end(); ++nt) {
2622 const int c_bgn_dst = (*nt).begin_dst;
2623 const int c_end_dst = c_bgn_dst + (*nt).width;
2624 if (c_end_dst < kc) {
2625 continue;
2626 }
2627 if (c_bgn_dst >= kc_end) {
2628 break;
2629 }
2630 const int ir_bgn = imax(kr, r_bgn_dst);
2631 const int ir_end = imin(kr_end, r_end_dst);
2632 const int jc_bgn = imax(kc, c_bgn_dst);
2633 const int jc_end = imin(kc_end, c_end_dst);
2634 const long ops = ((long)(ir_end - ir_bgn) *
2635 (long)(jc_end - jc_bgn));
2636
2637 const int ir_bgn_src = ((*mt).begin_src + (ir_bgn - r_bgn_dst));
2638 const int jc_bgn_src = ((*nt).begin_src + (jc_bgn - c_bgn_dst));
2639 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
2640 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
2641 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
2642 C_Dsub_task<T> *tmp =
2643 new C_Dsub_task<T>(1,
2644 0,
2645 (ir_bgn - kr),
2646 (ir_end - kr),
2647 (jc_bgn - kc),
2648 (jc_end - kc),
2649 ir_bgn_src,
2650 (-1), // ir_bgn_src2
2651 jc_bgn_src,
2652 (-1), // jc_bgn_src2
2653 father_row,
2654 father_diag_pt,
2655 (RectBlockMatrix<T> *)NULL, // dst_pt
2656 kr0,
2657 kc0,
2658 (RectBlockMatrix<T> *)NULL, // dst_pt2
2659 (-1),
2660 (-1),
2661 child_pt[ll],
2662 (SquareBlockMatrix<T>*)NULL, // src_pt2
2663 isSym ? dsub_sym2sym<T> : ((kr0 == kc0) ? dsub_unsym2diag<T> :dsub_unsym2unsym<T>),
2664 false, // skip_flag
2665 ops,
2666 father_id,
2667 level,
2668 verbose,
2669 fp);
2670 C_task_arg->push_back(tmp);
2671 *ops_sum += ops;
2672
2673 update_parents_list(parents_r[ll],
2674 ir_bgn_src, ir_end_src, child_pt[ll]);
2675 update_parents_list(parents_c[ll],
2676 jc_bgn_src, jc_end_src, child_pt[ll]);
2677 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
2678 } // loop : nt
2679 // -- child_ll * child01
2680 for (list <index_strip2>::const_iterator nt = strips_r01.begin();
2681 nt != strips_r01.end(); ++nt) {
2682 const int c_bgn_dst = (*nt).begin_dst;
2683 const int c_end_dst = c_bgn_dst + (*nt).width;
2684 if (c_bgn_dst < r_bgn_dst) {
2685 continue;
2686 }
2687 if (c_end_dst < kc) {
2688 continue;
2689 }
2690 if (c_bgn_dst >= kc_end) {
2691 break;
2692 }
2693 const int ir_bgn = imax(kr, r_bgn_dst);
2694 const int ir_end = imin(kr_end, r_end_dst);
2695 const int jc_bgn = imax(kc, c_bgn_dst);
2696 const int jc_end = imin(kc_end, c_end_dst);
2697 const long ops = ((long)(ir_end - ir_bgn) *
2698 (long)(jc_end - jc_bgn));
2699 const int ir_bgn_src =
2700 ((*mt).begin_src + (ir_bgn - r_bgn_dst));
2701 const int jc_bgn_src =
2702 ((ll == 0 ? (*nt).begin_src0 : (*nt).begin_src1) +
2703 (jc_bgn - c_bgn_dst));
2704 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
2705 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
2706 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
2707 C_Dsub_task<T> *tmp =
2708 new C_Dsub_task<T>(1,
2709 0,
2710 (ir_bgn - kr),
2711 (ir_end - kr),
2712 (jc_bgn - kc),
2713 (jc_end - kc),
2714 ir_bgn_src,
2715 (-1), // ir_bgn_src2
2716 jc_bgn_src, // (*nt).begin_src[ll] + ...
2717 (-1), // jc_bgn_src2
2718 father_row,
2719 father_diag_pt,
2720 (RectBlockMatrix<T> *)NULL, // dst_pt
2721 kr0,
2722 kc0,
2723 (RectBlockMatrix<T> *)NULL, // dst_pt2
2724 (-1),
2725 (-1),
2726 child_pt[ll],
2727 (SquareBlockMatrix<T>*)NULL, // src_pt2
2728 isSym ? dsub_sym2sym<T> : ((kr0 == kc0) ? dsub_unsym2diag<T> :dsub_unsym2unsym<T>),
2729 // dsub_unsym2unsym<T>, bug : 17 Jan.2016 found
2730 false, // skip_flag
2731 ops,
2732 father_id,
2733 level,
2734 verbose,
2735 fp);
2736 C_task_arg->push_back(tmp);
2737 *ops_sum += ops;
2738
2739 update_parents_list(parents_r[ll],
2740 ir_bgn_src, ir_end_src, child_pt[ll]);
2741 update_parents_list(parents_c[ll],
2742 jc_bgn_src, jc_end_src, child_pt[ll]);
2743 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))v
2744 } // loop : nt
2745 } // loop : mt
2746 } // loop : ll
2747 // ---- child01 * (child0 + child01 + child1) ----
2748 // -- child01 * child01
2749 for (list <index_strip2>::const_iterator mt = strips_r01.begin();
2750 mt != strips_r01.end(); ++mt) {
2751 const int r_bgn_dst = (*mt).begin_dst;
2752 const int r_end_dst = r_bgn_dst + (*mt).width;
2753 if (r_end_dst < kr) {
2754 continue;
2755 }
2756 if (r_bgn_dst >= kr_end) {
2757 break;
2758 }
2759 const int ir_bgn = imax(kr, r_bgn_dst);
2760 const int ir_end = imin(kr_end, r_end_dst);
2761 const int ic_bgn = imax(kc, r_bgn_dst);
2762 const int ic_end = imin(kc_end, r_end_dst);
2763 if (kr == kc) {
2764 const long ops = ((long)(ir_end - ir_bgn) *
2765 ((long)(ir_end - ir_bgn) + 1L));
2766 // diagonal : half size
2767 int ir_bgn_srcs[2], ir_end_srcs[2];
2768 ir_bgn_srcs[0] = (*mt).begin_src0 + (ir_bgn - r_bgn_dst);
2769 ir_bgn_srcs[1] = (*mt).begin_src1 + (ir_bgn - r_bgn_dst);
2770 ir_end_srcs[0] = ir_bgn_srcs[0] + (ir_end - ir_bgn);
2771 ir_end_srcs[1] = ir_bgn_srcs[1] + (ir_end - ir_bgn);
2772 if (ir_bgn < ir_end) {
2773 C_Dsub_task<T> *tmp =
2774 new C_Dsub_task<T>(1,
2775 0,
2776 (ir_bgn - kr),
2777 (ir_end - kr),
2778 (-1), // jc_bgn
2779 (-1), // jc_end
2780 ir_bgn_srcs[0],
2781 ir_bgn_srcs[1],
2782 (-1), // jc_bgn_src
2783 (-1), // jc_bgn_src2
2784 father_row,
2785 father_diag_pt,
2786 (RectBlockMatrix<T> *)NULL, // dst_pt
2787 kr0,
2788 kr0,
2789 (RectBlockMatrix<T> *)NULL, // dst_pt2
2790 (-1),
2791 (-1),
2792 child_pt[0],
2793 child_pt[1],
2794 (isSym ? dsub_sym2sym_diag_two<T> :
2795 dsub_unsym2unsym_diag_two<T>),
2796 skip_flag,
2797 ops,
2798 father_id,
2799 level,
2800 verbose,
2801 fp);
2802 C_task_arg->push_back(tmp);
2803 *ops_sum += skip_flag ? 0L : ops;
2804 for (int ll = 0; ll < 2; ll++) {
2805 update_parents_list(parents_r[ll],
2806 ir_bgn_srcs[ll], ir_end_srcs[ll],
2807 child_pt[ll]);
2808 }
2809 } // if (ir_bgn < ir_end)
2810 } // kr != kc
2811 else {
2812 const long ops = ((long)(ir_end - ir_bgn) *
2813 (long)(ic_end - ic_bgn) * 2L);
2814 int ir_bgn_srcs[2], ir_end_srcs[2];
2815 int ic_bgn_srcs[2], ic_end_srcs[2];
2816 ir_bgn_srcs[0] = (*mt).begin_src0 + (ir_bgn - r_bgn_dst);
2817 ir_bgn_srcs[1] = (*mt).begin_src1 + (ir_bgn - r_bgn_dst);
2818 ic_bgn_srcs[0] = (*mt).begin_src0 + (ic_bgn - r_bgn_dst);
2819 ic_bgn_srcs[1] = (*mt).begin_src1 + (ic_bgn - r_bgn_dst);
2820
2821 ir_end_srcs[0] = ir_bgn_srcs[0] + (ir_end - ir_bgn);
2822 ir_end_srcs[1] = ir_bgn_srcs[1] + (ir_end - ir_bgn);
2823 ic_end_srcs[0] = ic_bgn_srcs[0] + (ic_end - ic_bgn);
2824 ic_end_srcs[1] = ic_bgn_srcs[1] + (ic_end - ic_bgn);
2825 if ((ir_bgn < ir_end) && (ic_bgn < ic_end)) {
2826 C_Dsub_task<T> *tmp =
2827 new C_Dsub_task<T>(1,
2828 0,
2829 (ir_bgn - kr),
2830 (ir_end - kr),
2831 (ic_bgn - kc),
2832 (ic_end - kc),
2833 ir_bgn_srcs[0],
2834 ir_bgn_srcs[1],
2835 ic_bgn_srcs[0],
2836 ic_bgn_srcs[1],
2837 father_row,
2838 father_diag_pt,
2839 (RectBlockMatrix<T> *)NULL, // dst_pt
2840 kr0,
2841 kc0,
2842 (RectBlockMatrix<T> *)NULL, // dst_pt2
2843 (-1),
2844 (-1),
2845 child_pt[0],
2846 child_pt[1],
2847 isSym ? dsub_sym2sym_two<T> : dsub_unsym2unsym_two<T>,
2848 skip_flag,
2849 ops,
2850 father_id,
2851 level,
2852 verbose,
2853 fp);
2854 C_task_arg->push_back(tmp);
2855 *ops_sum += skip_flag ? 0L : ops;
2856 for (int ll = 0; ll < 2; ll++) {
2857 update_parents_list(parents_r[ll],
2858 ir_bgn_srcs[ll], ir_end_srcs[ll],
2859 child_pt[ll]);
2860 update_parents_list(parents_c[ll],
2861 ic_bgn_srcs[ll], ic_end_srcs[ll],
2862 child_pt[ll]);
2863 }
2864 } // if ((ir_bgn < ir_end) && (ic_bgn < ic_end))
2865 } // if (kr == kc)
2866 // off-diagonal blocks
2867 list <index_strip2>::const_iterator nt = mt;
2868 ++nt;
2869 for (; nt != strips_r01.end(); ++nt) {
2870 const int c_bgn_dst = (*nt).begin_dst;
2871 const int c_end_dst = c_bgn_dst + (*nt).width;
2872 if (c_end_dst < kc) {
2873 continue;
2874 }
2875 if (c_bgn_dst >= kc_end) {
2876 break;
2877 }
2878
2879 const int ir_bgn = imax(kr, r_bgn_dst);
2880 const int ir_end = imin(kr_end, r_end_dst);
2881 const int jc_bgn = imax(kc, c_bgn_dst);
2882 const int jc_end = imin(kc_end, c_end_dst);
2883 const long ops = ((long)(ir_end - ir_bgn) *
2884 (long)(jc_end - jc_bgn) * 2L);
2885 int ir_bgn_srcs[2], ir_end_srcs[2];
2886 int jc_bgn_srcs[2], jc_end_srcs[2];
2887 ir_bgn_srcs[0] = (*mt).begin_src0 + (ir_bgn - r_bgn_dst);
2888 ir_bgn_srcs[1] = (*mt).begin_src1 + (ir_bgn - r_bgn_dst);
2889 jc_bgn_srcs[0] = (*nt).begin_src0 + (jc_bgn - c_bgn_dst);
2890 jc_bgn_srcs[1] = (*nt).begin_src1 + (jc_bgn - c_bgn_dst);
2891
2892 ir_end_srcs[0] = ir_bgn_srcs[0] + (ir_end - ir_bgn);
2893 ir_end_srcs[1] = ir_bgn_srcs[1] + (ir_end - ir_bgn);
2894 jc_end_srcs[0] = jc_bgn_srcs[0] + (jc_end - jc_bgn);
2895 jc_end_srcs[1] = jc_bgn_srcs[1] + (jc_end - jc_bgn);
2896
2897 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)){
2898 C_Dsub_task<T> *tmp =
2899 new C_Dsub_task<T>(1,
2900 0,
2901 (ir_bgn - kr),
2902 (ir_end - kr),
2903 (jc_bgn - kc),
2904 (jc_end - kc),
2905 ir_bgn_srcs[0],
2906 ir_bgn_srcs[1],
2907 jc_bgn_srcs[0],
2908 jc_bgn_srcs[1],
2909 father_row,
2910 father_diag_pt,
2911 (RectBlockMatrix<T> *)NULL, // dst_pt
2912 kr0,
2913 kc0,
2914 (RectBlockMatrix<T> *)NULL, // dst_pt2
2915 (-1),
2916 (-1),
2917 child_pt[0],
2918 child_pt[1],
2919 isSym ? dsub_sym2sym_two<T> : ((kr0 == kc0) ? dsub_unsym2diag_two<T> : dsub_unsym2unsym_two<T>),
2920 skip_flag,
2921 ops,
2922 father_id,
2923 level,
2924 verbose,
2925 fp);
2926 C_task_arg->push_back(tmp);
2927 *ops_sum += skip_flag ? 0L : ops;
2928
2929 for (int ll = 0; ll < 2; ll++) {
2930 update_parents_list(parents_r[ll],
2931 ir_bgn_srcs[ll], ir_end_srcs[ll],
2932 child_pt[ll]);
2933 update_parents_list(parents_c[ll],
2934 jc_bgn_srcs[ll], jc_end_srcs[ll],
2935 child_pt[ll]);
2936 }
2937 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
2938 } // loop : nt
2939 // -- child01 * child_ll
2940 for (int ll = 0; ll < 2; ll++) {
2941 for (list <index_strip>::const_iterator nt = strips_r[ll].begin();
2942 nt != strips_r[ll].end(); ++nt) {
2943 const int c_bgn_dst = (*nt).begin_dst;
2944 const int c_end_dst = c_bgn_dst + (*nt).width;
2945 if (c_bgn_dst < r_bgn_dst) {
2946 continue;
2947 }
2948 if (c_end_dst < kc) {
2949 continue;
2950 }
2951 if (c_bgn_dst >= kc_end) {
2952 break;
2953 }
2954 const int ir_bgn = imax(kr, r_bgn_dst);
2955 const int ir_end = imin(kr_end, r_end_dst);
2956 const int jc_bgn = imax(kc, c_bgn_dst);
2957 const int jc_end = imin(kc_end, c_end_dst);
2958 const long ops = ((long)(ir_end - ir_bgn) *
2959 (long)(jc_end - jc_bgn));
2960 const int ir_bgn_src =
2961 ((ll == 0 ? (*mt).begin_src0 : (*mt).begin_src1) +
2962 (ir_bgn - r_bgn_dst));
2963 const int jc_bgn_src =
2964 // ((*nt).begin_dst + (jc_bgn - c_bgn_dst));
2965 (*nt).begin_src + (jc_bgn - c_bgn_dst);
2966 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
2967 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
2968
2969 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
2970 C_Dsub_task<T> *tmp =
2971 new C_Dsub_task<T>(1,
2972 0,
2973 (ir_bgn - kr),
2974 (ir_end - kr),
2975 (jc_bgn - kc),
2976 (jc_end - kc),
2977 ir_bgn_src, // ((*mt).begin_dst[ll] + ...
2978 (-1), // ir_bgn_src2
2979 jc_bgn_src,
2980 (-1), // jc_bgn_src2
2981 father_row,
2982 father_diag_pt,
2983 (RectBlockMatrix<T> *)NULL, // dst_pt
2984 kr0,
2985 kc0,
2986 (RectBlockMatrix<T> *)NULL, // dst_pt2
2987 (-1),
2988 (-1),
2989 child_pt[ll],
2990 (SquareBlockMatrix<T>*)NULL, // src_pt2
2991 isSym ? dsub_sym2sym<T> : ((kr0 == kc0) ? dsub_unsym2diag<T> : dsub_unsym2unsym<T>),
2992 false,
2993 ops,
2994 father_id,
2995 level,
2996 verbose,
2997 fp);
2998 C_task_arg->push_back(tmp);
2999 *ops_sum += ops;
3000
3001 update_parents_list(parents_r[ll],
3002 ir_bgn_src, ir_end_src, child_pt[ll]);
3003 update_parents_list(parents_c[ll],
3004 jc_bgn_src, jc_end_src, child_pt[ll]);
3005 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3006 } // loop : nt
3007 } // loop : ll
3008 } // loop : mt
3009 string task_name = ("g " + to_string(kr0) + " " + to_string(kc0)
3010 + " : " + to_string(level) + " : "
3011 + to_string(father_id + 1)); // selfIndex^-1
3012 queue[kk] = new C_task(C_DSUB,
3013 task_name, //task_name.str(),
3014 // task_name_cstr,
3015 (void *)C_task_arg,
3016 C_Dsub_task_exec<T>,
3017 1,
3018 0,
3019 ops_sum);
3020 queue[kk]->parallel_max = block_diag_size;
3021 queue[kk]->parallel_id = kk;
3022 // added to manage parents of tasks_p and tasks_q
3023 if (tasks_r != NULL) {
3024 for (typename list<child_contribution<T> >::const_iterator jt =
3025 child_contrib.begin();
3026 jt != child_contrib.end(); ++jt) {
3027 queue[kk]->parents->push_back(tasks_r[(*jt).child_id][0]);
3028 }
3029 }
3030 if (tasks_q.size() > 0) {
3031 // queue[kk]->parents->push_back(tasks_q[father_id][0]); // diag
3032 queue[kk]->parents->push_back(tasks_q[0]); // diag
3033 }
3034 if (tasks_s.size() > 0) {
3035 const int itmp = (kc0 * (kc0 + 1)) / 2 + kr0;
3036 queue[kk]->parents->push_back(tasks_s[itmp]);
3037 }
3038 // if (tasks_p != NULL) {
3039 #ifdef DEBUG_QUEUE_GENERATION
3040 cout << "++ diag two children " << task_name.str().c_str() << " ";
3041 list<C_Dsub_task<T> *> *task_tmp =
3042 (list<C_Dsub_task<T> *> *)queue[kk]->func_arg;
3043 cout << "task size = " << task_tmp->size() << " : " << endl;
3044 for (list<C_Dsub_task<T> *>::const_iterator jt = task_tmp->begin();
3045 jt != task_tmp->end(); jt++) {
3046 cout << (*jt)->atomic_id << " / " << (*jt)->atomic_size << " : "
3047 << (*jt)->ir_bgn << " / " << (*jt)->ir_end << " : "
3048 << (*jt)->jc_bgn << " / " << (*jt)->jc_end
3049 << endl;
3050 }
3051 #endif
3052 if (!skip_flag) {
3053 for (int ll = 0; ll < 2; ll++) {
3054 for (list<int>::const_iterator mt = parents_r[ll].begin();
3055 mt != parents_r[ll].end(); ++mt) {
3056 for (list<int>::const_iterator nt = mt;
3057 nt != parents_r[ll].end(); ++nt) { // running upper
3058 const int idx = (isSym ?
3059 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
3060 ((*nt) * (*nt) + 2 * (*mt)));
3061 vector<C_task *> &tasks_tmq = tasks_d[child_id[ll]];
3062 vector<int> &indcolq = tasks_d_indcol[child_id[ll]];
3063 if (tasks_p_flag) {
3064 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3065 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3066 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
3067 }
3068 if (tasks_tmq.size() > 0) {
3069 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
3070 }
3071 if (!isSym && ((*nt) > (*mt))) {
3072 if (tasks_p_flag) {
3073 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3074 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3075 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]);
3076 }
3077 if (tasks_tmq.size() > 0) {
3078 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
3079 }
3080 }
3081 }
3082 for (list<int>::const_iterator nt = parents_c[ll].begin();
3083 nt != parents_c[ll].end(); ++nt) {
3084 if ((*nt) > (*mt)) {
3085 const int idx = (isSym ?
3086 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
3087 ((*nt) * (*nt) + 2 * (*mt)));
3088 vector<C_task *> &tasks_tmq = tasks_d[child_id[ll]];
3089 vector<int> &indcolq = tasks_d_indcol[child_id[ll]];
3090 if (tasks_p_flag) {
3091 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3092 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3093 // if (indcolp.size() > idx) {
3094 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
3095 }
3096 if (tasks_tmq.size() > 0) {
3097 // if (indcolq.size() > idx) {
3098 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
3099 if (!isSym) {
3100 if (tasks_p_flag) {
3101 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3102 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3103 // if (indcolp.size() > (idx + 1)) {
3104 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]); }
3105 }
3106 if (tasks_tmq.size() > 0) {
3107 // if (indcolq.size() > (idx + 1)) {
3108 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
3109 }
3110 }
3111 }
3112 } // loop : nt
3113 } // loop :
3114 } // loop : ll
3115 } // if (!skip_flag)
3116 else {
3117 // verify skip
3118 if (verbose) {
3119 for (int ll = 0; ll < 2; ll++) {
3120 for (list<int>::const_iterator mt = parents_r[ll].begin();
3121 mt != parents_r[ll].end(); ++mt) {
3122 if ((*mt) > child_pt[ll]->num_blocks0()) {
3123 diss_printf(verbose, stderr,
3124 "%s %d : %d incorrect skip : %d %d\n",
3125 __FILE__, __LINE__, ll, (*mt),
3126 child_pt[ll]->num_blocks0());
3127 }
3128 }
3129 for (list<int>::const_iterator mt = parents_c[ll].begin();
3130 mt != parents_c[ll].end(); ++mt) {
3131 if ((*mt) > child_pt[ll]->num_blocks0()) {
3132 diss_printf(verbose, stderr,
3133 "%s %d : %d incorrect skip : %d %d\n",
3134 __FILE__, __LINE__, ll, (*mt),
3135 child_pt[ll]->num_blocks0());
3136 }
3137 }
3138 }
3139 } // if (verbose)
3140 }
3141 queue[kk]->parents->sort(compare_task_name);
3142 queue[kk]->parents->unique();
3143 EraseNullParents(queue[kk]);
3144 for (int m = 0; m < 2; m++) {
3145 parents_r[m].clear();
3146 parents_c[m].clear();
3147 }
3148 delete [] parents_r;
3149 delete [] parents_c;
3150 kk++;
3151 } // loop : kr0
3152 } // loop : kc0
3153 // offdiagonal contribution
3154
3155 for (int kc0 = 0; kc0 < num_block2; kc0++) {
3156 // const int kc = kc0 * SIZE_B1;
3157 // const int kc_end = ((kc0 == num_block2 - 1) ? offdiag_size :
3158 // (kc + SIZE_B1));
3159 const int kc = father_offdiag_pt->IndexBlock_c(kc0);
3160 const int kc_end = father_offdiag_pt->IndexBlock_c(kc0 + 1);
3161
3162 list<C_Dsub_task<T> *> *C_task_arg = new list<C_Dsub_task<T> *>;
3163 list<int>* parents_r = new list<int>[2];
3164 list<int>* parents_c = new list<int>[2];
3165 long *ops_sum = new long;
3166 *ops_sum = 0L;
3167
3168 // ---- child_ll * (child_ll + child01) ----
3169 for (int ll = 0; ll < 2; ll++) {
3170 for (int kr0 = 0; kr0 < num_block; kr0++) { // 02 Jul.2014 : Atsushi
3171 const int kr = kr0 * SIZE_B1;
3172 const int kr_end = (kr0 == num_block - 1) ? diag_size : (kr + SIZE_B1);
3173 for (list <index_strip>::const_iterator mt = strips_r[ll].begin();
3174 mt != strips_r[ll].end(); ++mt) {
3175
3176 const int r_bgn_dst = (*mt).begin_dst;
3177 const int r_end_dst = r_bgn_dst + (*mt).width;
3178 if (r_end_dst < kr) {
3179 continue; // of loop mt
3180 }
3181 if (r_bgn_dst >= kr_end ) {
3182 break; // of loop mt
3183 }
3184 const int ir_bgn = imax(kr, r_bgn_dst);
3185 const int ir_end = imin(kr_end, r_end_dst);
3186
3187 // -- child_ll * child_ll
3188 for (list <index_strip>::const_iterator nt = strips_c[ll].begin();
3189 nt != strips_c[ll].end(); ++nt) {
3190 const int c_bgn_dst = (*nt).begin_dst;
3191 const int c_end_dst = c_bgn_dst + (*nt).width;
3192 if (c_end_dst < kc) {
3193 continue;
3194 }
3195 if (c_bgn_dst >= kc_end) {
3196 break;
3197 }
3198 const int jc_bgn = imax(kc, c_bgn_dst);
3199 const int jc_end = imin(kc_end, c_end_dst);
3200 const long ops = ((long)(*mt).width *
3201 (long)(jc_end - jc_bgn));
3202 const int ir_bgn_src = (*mt).begin_src + (ir_bgn - r_bgn_dst);
3203 const int jc_bgn_src = (*nt).begin_src + (jc_bgn - c_bgn_dst);
3204 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3205 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
3206 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3207 C_Dsub_task<T> *tmp =
3208 new C_Dsub_task<T>(1,
3209 0,
3210 (ir_bgn - kr),
3211 (ir_end - kr),
3212 (jc_bgn - kc),
3213 (jc_end - kc),
3214 ir_bgn_src, // (*mt).begin_src,
3215 (-1), // ir_bgn_src2
3216 jc_bgn_src,
3217 (-1), // jc_bgn_src2
3218 father_row,
3219 (SquareBlockMatrix<T>*)NULL, // father_pt
3220 father_offdiag_pt,
3221 kr0, // ir_block
3222 kc0, // jc_block
3223 isSym ? (RectBlockMatrix<T> *)NULL : father_offdia2_pt,
3224 0, // withou block
3225 0, // withou block
3226 child_pt[ll],
3227 (SquareBlockMatrix<T>*)NULL, // src_pt2
3228 isSym ? dsub_sym2rct<T> : dsub_unsym2rct<T>,
3229 false,
3230 ops,
3231 father_id,
3232 level,
3233 verbose,
3234 fp);
3235 C_task_arg->push_back(tmp);
3236 *ops_sum += ops;
3237 update_parents_list(parents_r[ll],
3238 ir_bgn_src, ir_end_src, child_pt[ll]);
3239 update_parents_list(parents_c[ll],
3240 jc_bgn_src, jc_end_src, child_pt[ll]);
3241 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3242 } // loop : nt
3243 // -- child_ll * child01
3244 for (list <index_strip2>::const_iterator nt = strips_c01.begin();
3245 nt != strips_c01.end(); ++nt) {
3246 const int c_bgn_dst= (*nt).begin_dst;
3247 const int c_end_dst = c_bgn_dst + (*nt).width;
3248 if (c_end_dst < kc) {
3249 continue;
3250 }
3251 if (c_bgn_dst >= kc_end) {
3252 break;
3253 }
3254 const int jc_bgn = imax(kc, c_bgn_dst);
3255 const int jc_end = imin(kc_end, c_end_dst);
3256 const long ops = ((long)(*mt).width *
3257 (long)(jc_end - jc_bgn));
3258 const int ir_bgn_src = (*mt).begin_src + (ir_bgn - r_bgn_dst);
3259 const int jc_bgn_src =
3260 ((ll == 0 ? (*nt).begin_src0 : (*nt).begin_src1) +
3261 (jc_bgn - c_bgn_dst));
3262 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3263 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
3264
3265 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3266 C_Dsub_task<T> *tmp =
3267 new C_Dsub_task<T>(1,
3268 0,
3269 (ir_bgn - kr),
3270 (ir_end - kr),
3271 (jc_bgn - kc),
3272 (jc_end - kc),
3273 ir_bgn_src,
3274 (-1), // ir_bgn_src2
3275 jc_bgn_src, // (*nt)->begin_src[ll] + ...
3276 (-1), // jc_bgn_src2
3277 father_row,
3278 (SquareBlockMatrix<T>*)NULL, // father_pt
3279 father_offdiag_pt,
3280 kr0, // ir_block
3281 kc0, // jc_block
3282 isSym ? (RectBlockMatrix<T> *)NULL : father_offdia2_pt,
3283 0, // withou block
3284 0, // withou block
3285 child_pt[ll],
3286 (SquareBlockMatrix<T>*)NULL, // src_pt2
3287 isSym ? dsub_sym2rct<T> : dsub_unsym2rct<T>,
3288 false,
3289 ops,
3290 father_id,
3291 level,
3292 verbose,
3293 fp);
3294 C_task_arg->push_back(tmp);
3295 *ops_sum += ops;
3296
3297 update_parents_list(parents_r[ll],
3298 ir_bgn_src, ir_end_src, child_pt[ll]);
3299 update_parents_list(parents_c[ll],
3300 jc_bgn_src, jc_end_src, child_pt[ll]);
3301 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3302 } // loop : nt
3303 } // loop : mt
3304 } // loop kr0
3305 } // loop : ll
3306 // ---- child01 * (child0 + child01 + child1) ----
3307 for (int kr0 = 0; kr0 < num_block; kr0++) { // 02 Jul.2014 : Atsushi
3308 const int kr = kr0 * SIZE_B1;
3309 const int kr_end = (kr0 == num_block - 1) ? diag_size : (kr + SIZE_B1);
3310
3311 for (list <index_strip2>::const_iterator mt = strips_r01.begin();
3312 mt != strips_r01.end(); ++mt) {
3313
3314 const int r_bgn_dst = (*mt).begin_dst;
3315 const int r_end_dst = r_bgn_dst + (*mt).width;
3316 if (r_end_dst < kr) {
3317 continue;
3318 }
3319 if (r_bgn_dst >= kr_end) {
3320 break;
3321 }
3322 const int ir_bgn = imax(kr, r_bgn_dst);
3323 const int ir_end = imin(kr_end, r_end_dst);
3324
3325 // -- child01 * child_ll
3326 for (int ll = 0; ll < 2; ll++) {
3327 for (list <index_strip>::const_iterator nt = strips_c[ll].begin();
3328 nt != strips_c[ll].end(); ++nt) {
3329 const int c_bgn_dst = (*nt).begin_dst;
3330 const int c_end_dst = c_bgn_dst + (*nt).width;
3331 if (c_end_dst < kc) {
3332 continue;
3333 }
3334 if (c_bgn_dst >= kc_end) {
3335 break;
3336 }
3337 const int jc_bgn = imax(kc, c_bgn_dst);
3338 const int jc_end = imin(kc_end, c_end_dst);
3339 const long ops = ((long)(*mt).width *
3340 (long)(jc_end - jc_bgn));
3341 const int ir_bgn_src =
3342 (ll == 0 ? (*mt).begin_src0 : (*mt).begin_src1) +
3343 (ir_bgn - r_bgn_dst);
3344 const int jc_bgn_src = ((*nt).begin_src + (jc_bgn - c_bgn_dst));
3345 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3346 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
3347 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3348 C_Dsub_task<T> *tmp =
3349 new C_Dsub_task<T>(1,
3350 0,
3351 (ir_bgn - kr),
3352 (ir_end - kr),
3353 (jc_bgn - kc),
3354 (jc_end - kc),
3355 ir_bgn_src, // ((*mt).begin_src[ll] + ...
3356 (-1), // ir_bgn_src2
3357 jc_bgn_src,
3358 (-1), // jc_bgn_src2
3359 father_row,
3360 (SquareBlockMatrix<T>*)NULL, // father_pt
3361 father_offdiag_pt,
3362 kr0, // ir_block
3363 kc0, // jc_block
3364 isSym ? (RectBlockMatrix<T> *)NULL : father_offdia2_pt,
3365 0, // withou block
3366 0, // withou block
3367 child_pt[ll],
3368 (SquareBlockMatrix<T>*)NULL, // src_pt2
3369 isSym ? dsub_sym2rct<T>: dsub_unsym2rct<T>,
3370 false,
3371 ops,
3372 father_id,
3373 level,
3374 verbose,
3375 fp);
3376 C_task_arg->push_back(tmp);
3377 *ops_sum += ops;
3378
3379 update_parents_list(parents_r[ll],
3380 ir_bgn_src, ir_end_src, child_pt[ll]);
3381 update_parents_list(parents_c[ll],
3382 jc_bgn_src, jc_end_src, child_pt[ll]);
3383 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3384 } // loop : nt
3385 } // loop : ll
3386 // -- child01 * child01
3387 for (list <index_strip2>::const_iterator nt = strips_c01.begin();
3388 nt != strips_c01.end(); ++nt) {
3389 const int c_bgn_dst = (*nt).begin_dst;
3390 const int c_end_dst = c_bgn_dst + (*nt).width;
3391 if (c_end_dst < kc) {
3392 continue;
3393 }
3394 if (c_bgn_dst >= kc_end) {
3395 break;
3396 }
3397 const int jc_bgn = imax(kc, c_bgn_dst);
3398 const int jc_end = imin(kc_end, c_end_dst);
3399 const long ops = ((long)(*mt).width *
3400 (long)(jc_end - jc_bgn) * 2L);
3401
3402 int ir_bgn_srcs[2], ir_end_srcs[2];
3403 int jc_bgn_srcs[2], jc_end_srcs[2];
3404 ir_bgn_srcs[0] = (*mt).begin_src0 + (ir_bgn - r_bgn_dst);
3405 ir_bgn_srcs[1] = (*mt).begin_src1 + (ir_bgn - r_bgn_dst);
3406 jc_bgn_srcs[0] = (*nt).begin_src0 + (jc_bgn - c_bgn_dst);
3407 jc_bgn_srcs[1] = (*nt).begin_src1 + (jc_bgn - c_bgn_dst);
3408
3409 ir_end_srcs[0] = ir_bgn_srcs[0] + (ir_end - ir_bgn);
3410 ir_end_srcs[1] = ir_bgn_srcs[1] + (ir_end - ir_bgn);
3411 jc_end_srcs[0] = jc_bgn_srcs[0] + (jc_end - jc_bgn);
3412 jc_end_srcs[1] = jc_bgn_srcs[1] + (jc_end - jc_bgn);
3413
3414 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3415 C_Dsub_task<T> *tmp =
3416 new C_Dsub_task<T>(1,
3417 0,
3418 (ir_bgn - kr),
3419 (ir_end - kr),
3420 (jc_bgn - kc),
3421 (jc_end - kc),
3422 ir_bgn_srcs[0],
3423 ir_bgn_srcs[1],
3424 jc_bgn_srcs[0],
3425 jc_bgn_srcs[1],
3426 father_row,
3427 (SquareBlockMatrix<T>*)NULL, // father_pt
3428 father_offdiag_pt,
3429 kr0, // ir_block
3430 kc0, // jc_block
3431 isSym ? (RectBlockMatrix<T> *)NULL : father_offdia2_pt,
3432 0, // withou block
3433 0, // withou block
3434 child_pt[0],
3435 child_pt[1],
3436 isSym ? dsub_sym2rct_two<T> : dsub_unsym2rct_two<T>,
3437 false,
3438 ops,
3439 father_id,
3440 level,
3441 verbose,
3442 fp);
3443 C_task_arg->push_back(tmp);
3444 *ops_sum += ops;
3445 for (int ll = 0; ll < 2; ll++) {
3446 update_parents_list(parents_r[ll],
3447 ir_bgn_srcs[ll], ir_end_srcs[ll],
3448 child_pt[ll]);
3449 update_parents_list(parents_c[ll],
3450 jc_bgn_srcs[ll], jc_end_srcs[ll],
3451 child_pt[ll]);
3452 } // loop : ll
3453 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3454 } // loop : nt
3455 } // loop : mt
3456 } // loop : kr0
3457 string task_name = ("h " + to_string(kc0) + " : "
3458 + to_string(level) + " : "
3459 + to_string(father_id + 1)); // selfIndex^-1
3460 queue[kk] = new C_task(C_DSUB,
3461 task_name, //task_name.str(),
3462 (void *)C_task_arg,
3463 C_Dsub_task_exec<T>,
3464 1,
3465 0,
3466 ops_sum);
3467 queue[kk]->parallel_max = num_block2;
3468 queue[kk]->parallel_id = kc0;
3469 // added to manage parents of tasks_p and tasks_q
3470 if (tasks_r != NULL) {
3471 for (typename list<child_contribution<T> >::const_iterator jt =
3472 child_contrib.begin();
3473 jt != child_contrib.end(); ++jt) {
3474 queue[kk]->parents->push_back(tasks_r[(*jt).child_id][0]);
3475 }
3476 }
3477 if (tasks_q.size() > 0) {
3478 // queue[kk]->parents->push_back(tasks_q[father_id][1]); // offdiag
3479 queue[kk]->parents->push_back(tasks_q[1]); // offdiag
3480 }
3481 if (tasks_s.size() > 0) { // offiag
3482 for (int i = 0; i < num_block; i++) {
3483 const int itmp = kc0 * num_block + i + tasks_s[0]->parallel_max;
3484 queue[kk]->parents->push_back(tasks_s[itmp]);
3485 }
3486 }
3487 // if (tasks_p != NULL) {
3488 for (int ll = 0; ll < 2; ll++) {
3489 for (list<int>::const_iterator mt = parents_r[ll].begin();
3490 mt != parents_r[ll].end(); ++mt) {
3491 for (list<int>::const_iterator nt = parents_c[ll].begin();
3492 nt != parents_c[ll].end(); ++nt) {
3493 if ((*nt) >= (*mt)) { // upper block
3494 const int idx = (isSym ?
3495 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
3496 ((*nt) * (*nt) + 2 * (*mt)));
3497
3498 vector<C_task *> &tasks_tmq = tasks_d[child_id[ll]];
3499 vector<int> &indcolq = tasks_d_indcol[child_id[ll]];
3500 if (tasks_p_flag) {
3501 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3502 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3503 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
3504 }
3505 if (tasks_tmq.size() > 0) {
3506 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
3507 }
3508 if (!isSym && ((*nt) > (*mt))) {
3509 if (tasks_p_flag) {
3510 vector<C_task *> &tasks_tmp = tasks_p[child_id[ll]];
3511 vector<int> &indcolp = tasks_p_indcol[child_id[ll]];
3512 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]);
3513 }
3514 if (tasks_tmq.size() > 0) {
3515 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
3516 }
3517 }
3518 }
3519 } // loop : nt
3520 } // loop : mt
3521 } // loop : ll
3522 // }// if (tasks_p != NULL) {
3523 queue[kk]->parents->sort(compare_task_name);
3524 queue[kk]->parents->unique();
3525 EraseNullParents(queue[kk]);
3526 for (int m = 0; m < 2; m++) {
3527 parents_r[m].clear();
3528 parents_c[m].clear();
3529 }
3530 delete [] parents_r;
3531 delete [] parents_c;
3532 kk++;
3533 } // loop : kc0
3534 delete [] strips_r;
3535 delete [] strips_c;
3536 delete [] child_pt;
3537 delete [] child_id;
3538 #ifdef DEBUG_QUEUE_GENERATION2
3539 cout << "father = " << (father_id + 1) << " contrib = 2 : queue size = "
3540 << queue.size() << endl;
3541 for (vector<C_task *>::const_iterator kt = queue.begin();
3542 kt != queue.end(); ++kt) {
3543 cout << (*kt)->task_name << " :: " << (*kt)->parents->size() << " : " ;
3544 for (list<C_task *>::const_iterator jt = (*kt)->parents->begin();
3545 jt != (*kt)->parents->end(); ++jt) {
3546 cout << (*jt)->task_name << " / ";
3547 }
3548 cout << endl;
3549 } // loop : kt
3550 #endif
3551 #ifdef DEBUG_PREPARE_THREAD_DEBUG
3552 cout << "kk = " << kk << endl;
3553 #endif
3554 } // if (child_contrib.size() == 2) {
3555 else {
3556 queue.resize(block_diag_size + block_offdiag_size);
3557 #ifdef DEBUG_PREPARE_THREAD_DEBUG
3558 cout << "resize = " << block_diag_size + block_offdiag_size << " ";
3559 #endif
3560 int kk = 0;
3561 // -- diagonal
3562 for (int kc0 = 0; kc0 < num_block; kc0++) {
3563 const int kc = kc0 * SIZE_B1;
3564 const int kc_end = (kc0 == (num_block - 1)) ? diag_size : (kc + SIZE_B1);
3565 for (int kr0 = 0; kr0 <= kc0; kr0++) {
3566 const int kr = kr0 * SIZE_B1;
3567 const int kr_end =
3568 (kr0 == (num_block - 1)) ? diag_size : (kr + SIZE_B1);
3569 list<C_Dsub_task<T> *> *C_task_arg = new list<C_Dsub_task<T> *>;
3570 // C_task_arg[kk] = new list<C_Dsub_task *>;
3571 list<int>* parents_r = new list<int>[child_contrib.size()];
3572 list<int>* parents_c = new list<int>[child_contrib.size()];
3573 long *ops_sum = new long;
3574 *ops_sum = 0L;
3575
3576 int count_atomics = 0;
3577 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3578 jt != child_contrib.end(); ++jt) {
3579 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3580 mt != (*jt).diag_strip.end(); ++mt) {
3581 const int r_bgn_dst = (*mt).begin_dst;
3582 const int r_end_dst = r_bgn_dst + (*mt).width;
3583 if (r_end_dst < kr || r_end_dst < kc) {
3584 continue;
3585 }
3586 if (r_bgn_dst >= kr_end || r_bgn_dst >= kc_end) {
3587 break;
3588 }
3589 count_atomics++;
3590 }
3591 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3592 mt != (*jt).diag_strip.end(); ++mt) {
3593 const int r_bgn_dst = (*mt).begin_dst;
3594 const int r_end_dst = r_bgn_dst + (*mt).width;
3595 if (r_end_dst < kr) {
3596 continue;
3597 }
3598 if (r_bgn_dst >= kr_end ) {
3599 break;
3600 }
3601 list <index_strip>::const_iterator nt = mt;
3602 ++nt;
3603 for (; nt != (*jt).diag_strip.end(); ++nt) {
3604 const int c_bgn_dst = (*nt).begin_dst;
3605 const int c_end_dst = c_bgn_dst + (*nt).width;
3606 if (c_end_dst < kc) {
3607 continue;
3608 }
3609 if (c_bgn_dst >= kc_end) {
3610 break;
3611 }
3612 count_atomics++;
3613 } // loop : nt
3614 } // loop : mt
3615 } // loop : jt
3616
3617 int atomic_id = 0;
3618 int ll = 0;
3619 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3620 jt != child_contrib.end(); ++jt, ll++) {
3621 SquareBlockMatrix<T>* child_pt = (*jt).child_pt;
3622 SquareBlockMatrix<T>* father_diag_pt = (*jt).father_diag_pt;
3623 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3624 mt != (*jt).diag_strip.end(); ++mt) {
3625 const int r_bgn_dst = (*mt).begin_dst;
3626 const int r_end_dst = r_bgn_dst + (*mt).width;
3627 if (r_end_dst < kr) {
3628 continue;
3629 }
3630 if (r_bgn_dst >= kr_end) {
3631 break;
3632 }
3633 const int ir_bgn = imax(kr, r_bgn_dst);
3634 const int ir_end = imin(kr_end, r_end_dst);
3635 const int ic_bgn = imax(kc, r_bgn_dst);
3636 const int ic_end = imin(kc_end, r_end_dst);
3637 if (kr == kc) {
3638 const long ops = ((long)(ir_end - ir_bgn) *
3639 ((long)(ir_end - ir_bgn) + 1L) / 2L);
3640 const int ir_bgn_src =
3641 ((*mt).begin_src + (ir_bgn - r_bgn_dst));
3642 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3643 if (ir_bgn < ir_end) {
3644 C_Dsub_task<T> *tmp =
3645 new C_Dsub_task<T>(count_atomics,
3646 atomic_id++,
3647 (ir_bgn - kr),
3648 (ir_end - kr),
3649 (-1), // jc_bgn
3650 (-1), // jc_end
3651 ir_bgn_src,
3652 (-1), // ir_bgn_src2
3653 (-1), // jc_bgn_src
3654 (-1), // jc_bgn_src2
3655 father_row,
3656 father_diag_pt,
3657 (RectBlockMatrix<T> *)NULL, // dst_pt
3658 kr0,
3659 kr0,
3660 (RectBlockMatrix<T> *)NULL, // dst_pt2
3661 (-1),
3662 (-1),
3663 child_pt,
3664 (SquareBlockMatrix<T>*)NULL, // src_pt2
3665 (isSym ? dsub_sym2sym_diag<T> :
3666 dsub_unsym2unsym_diag<T>),
3667 false,
3668 ops,
3669 father_id,
3670 level,
3671 verbose,
3672 fp);
3673 C_task_arg->push_back(tmp);
3674 *ops_sum += ops;
3675 update_parents_list(parents_r[ll],
3676 ir_bgn_src, ir_end_src, child_pt);
3677 } // if (ir_bgn < ir_end)
3678 }
3679 else { // kc > kr
3680 const long ops = ((long)(ir_end - ir_bgn) *
3681 (long)(ic_end - ic_bgn));
3682 const int ir_bgn_src =
3683 ((*mt).begin_src + (ir_bgn - r_bgn_dst));
3684 const int ic_bgn_src =
3685 ((*mt).begin_src + (ic_bgn - r_bgn_dst));
3686 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3687 const int ic_end_src = ic_bgn_src + (ic_end - ic_bgn);
3688 if ((ir_bgn < ir_end) && (ic_bgn < ic_end)) {
3689 C_Dsub_task<T> *tmp =
3690 new C_Dsub_task<T>(count_atomics,
3691 atomic_id++,
3692 (ir_bgn - kr),
3693 (ir_end - kr),
3694 (ic_bgn - kc),
3695 (ic_end - kc),
3696 ir_bgn_src,
3697 (-1), // ir_bgn_src2
3698 ic_bgn_src,
3699 (-1), // jc_bgn_src2
3700 father_row,
3701 father_diag_pt,
3702 (RectBlockMatrix<T> *)NULL, // dst_pt
3703 kr0,
3704 kc0,
3705 (RectBlockMatrix<T> *)NULL, // dst_pt2
3706 (-1),
3707 (-1),
3708 child_pt,
3709 (SquareBlockMatrix<T>*)NULL, // src_pt2
3710 isSym ? dsub_sym2sym<T> : dsub_unsym2unsym<T>,
3711 false,
3712 ops,
3713 father_id,
3714 level,
3715 verbose,
3716 fp);
3717 C_task_arg->push_back(tmp);
3718 *ops_sum += ops;
3719 update_parents_list(parents_r[ll],
3720 ir_bgn_src, ir_end_src, child_pt);
3721 update_parents_list(parents_c[ll],
3722 ic_bgn_src, ic_end_src, child_pt);
3723 } // if ((ir_bgn < ir_end) && (ic_bgn < ic_end))
3724 } // if (kr == kc)
3725 } // loop mt
3726 //
3727 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3728 mt != (*jt).diag_strip.end(); ++mt) {
3729 const int r_bgn_dst = (*mt).begin_dst;
3730 const int r_end_dst = r_bgn_dst + (*mt).width;
3731 if (r_end_dst < kr) {
3732 continue;
3733 }
3734 if (r_bgn_dst >= kr_end ) {
3735 break;
3736 }
3737 list <index_strip>::const_iterator nt = mt;
3738 ++nt;
3739 for (; nt != (*jt).diag_strip.end(); ++nt) {
3740 const int c_bgn_dst = (*nt).begin_dst;
3741 const int c_end_dst = c_bgn_dst + (*nt).width;
3742 if (c_end_dst < kc) {
3743 continue;
3744 }
3745 if (c_bgn_dst >= kc_end) {
3746 break;
3747 }
3748 const int ir_bgn = imax(kr, r_bgn_dst);
3749 const int ir_end = imin(kr_end, r_end_dst);
3750 const int jc_bgn = imax(kc, c_bgn_dst);
3751 const int jc_end = imin(kc_end, c_end_dst);
3752 // index runs upper diagonal block ( mt < nt ) => (i < j)
3753 const long ops = ((long)(ir_end - ir_bgn) *
3754 (long)(jc_end - jc_bgn));
3755 const int ir_bgn_src = ((*mt).begin_src + (ir_bgn - r_bgn_dst));
3756 const int jc_bgn_src = ((*nt).begin_src + (jc_bgn - c_bgn_dst));
3757 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3758 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
3759 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3760 C_Dsub_task<T> *tmp =
3761 new C_Dsub_task<T>(count_atomics,
3762 atomic_id++,
3763 (ir_bgn - kr),
3764 (ir_end - kr),
3765 (jc_bgn - kc),
3766 (jc_end - kc),
3767 ir_bgn_src,
3768 (-1), // ir_bgn_src2
3769 jc_bgn_src,
3770 (-1), // jc_bgn_src2
3771 father_row,
3772 father_diag_pt,
3773 (RectBlockMatrix<T> *)NULL, // dst_pt
3774 kr0,
3775 kc0,
3776 (RectBlockMatrix<T> *)NULL, // dst_pt2
3777 (-1),
3778 (-1),
3779 child_pt,
3780 (SquareBlockMatrix<T>*)NULL, // src_pt2
3781 isSym ? dsub_sym2sym<T> : ((kr0 == kc0) ? dsub_unsym2diag<T> : dsub_unsym2unsym<T>),
3782 false,
3783 ops,
3784 father_id,
3785 level,
3786 verbose,
3787 fp);
3788 //
3789 C_task_arg->push_back(tmp);
3790 *ops_sum += ops;
3791 update_parents_list(parents_r[ll],
3792 ir_bgn_src, ir_end_src, child_pt);
3793 update_parents_list(parents_c[ll],
3794 jc_bgn_src, jc_end_src, child_pt);
3795 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
3796 } // loop : nt
3797 } // loop : mt
3798 } // loop : jt
3799 string task_name = ("i " + to_string(kr0) + " " + to_string(kc0)
3800 + " : " + to_string(level) + " : "
3801 + to_string(father_id + 1)); // selfIndex^-1
3802 queue[kk] = new C_task(C_DSUB,
3803 task_name,
3804 (void *)C_task_arg,
3805 C_Dsub_task_exec<T>,
3806 1,
3807 0,
3808 ops_sum);
3809 queue[kk]->parallel_max = block_diag_size; // block_total_size;
3810 queue[kk]->parallel_id = kk;
3811 // added to manage parents of tasks_p and tasks_q
3812 if (tasks_r != NULL) {
3813 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3814 jt != child_contrib.end(); ++jt) {
3815 queue[kk]->parents->push_back(tasks_r[(*jt).child_id][0]);
3816 }
3817 }
3818 if (tasks_q.size() > 0) {
3819 // queue[kk]->parents->push_back(tasks_q[father_id][0]); // diag
3820 queue[kk]->parents->push_back(tasks_q[0]); // diag
3821 }
3822 if (tasks_s.size() > 0) {
3823 const int itmp = ((kc0 * (kc0 + 1)) / 2) + kr0; // diag
3824 queue[kk]->parents->push_back(tasks_s[itmp]);
3825 }
3826 // if (tasks_p != NULL) {
3827 ll = 0;
3828 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3829 jt != child_contrib.end(); ++jt, ll++) {
3830 for (list<int>::const_iterator mt = parents_r[ll].begin();
3831 mt != parents_r[ll].end(); ++mt) {
3832 for (list<int>::const_iterator nt = mt;
3833 nt != parents_r[ll].end(); ++nt) {
3834 const int idx = (isSym ?
3835 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
3836 ((*nt) * (*nt) + 2 * (*mt)));
3837
3838 vector<C_task *> &tasks_tmq = tasks_d[(*jt).child_id];
3839 vector<int> &indcolq = tasks_d_indcol[(*jt).child_id];
3840 if (tasks_p_flag) {
3841 vector<C_task *> &tasks_tmp = tasks_p[(*jt).child_id];
3842 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
3843 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
3844 }
3845 if (tasks_tmq.size() > 0) {
3846 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
3847 }
3848 if (!isSym && ((*nt) > (*mt))) {
3849 if (tasks_p_flag) {
3850 vector<C_task *> &tasks_tmp = tasks_p[(*jt).child_id];
3851 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
3852 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]);
3853 }
3854 if (tasks_tmq.size() > 0) {
3855 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
3856 }
3857 }
3858 }
3859 for (list<int>::const_iterator nt = parents_c[ll].begin();
3860 nt != parents_c[ll].end(); ++nt) {
3861 if ((*nt) > (*mt)) { // upper block
3862 const int idx = (isSym ?
3863 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
3864 ((*nt) * (*nt) + 2 * (*mt)));
3865 vector<C_task *> &tasks_tmq = tasks_d[(*jt).child_id];
3866 vector<int> &indcolq = tasks_d_indcol[(*jt).child_id];
3867 if (tasks_p_flag) {
3868 vector<C_task *> &tasks_tmp = tasks_p[(*jt).child_id];
3869 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
3870 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
3871 }
3872 if (tasks_tmq.size() > 0) {
3873 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
3874 }
3875 if (!isSym) {
3876 if (tasks_p_flag) {
3877 vector<C_task *> &tasks_tmp = tasks_p[(*jt).child_id];
3878 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
3879 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]);
3880 }
3881 if (tasks_tmq.size() > 0) {
3882 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
3883 }
3884 }
3885 }
3886 } // loop : nt
3887 } // loop : mt
3888 } // loop : jt
3889 queue[kk]->parents->sort(compare_task_name);
3890 queue[kk]->parents->unique();
3891 EraseNullParents(queue[kk]);
3892 for (int m = 0; m < child_contrib.size(); m++) {
3893 parents_r[m].clear();
3894 parents_c[m].clear();
3895 }
3896 delete [] parents_r;
3897 delete [] parents_c;
3898 kk++;
3899 } // loop : kc
3900 } // loop : kr
3901 // -- offdiagonal
3902 for (int kc0 = 0; kc0 < num_block2; kc0++) {
3903 const int kc = child_contrib.front().father_offdiag_pt->IndexBlock_c(kc0);
3904 const int kc_end = child_contrib.front().father_offdiag_pt->IndexBlock_c(kc0 + 1);
3905
3906 for (int kr0 = 0; kr0 < num_block; kr0++) {
3907 const int kr = kr0 * SIZE_B1;
3908 const int kr_end =
3909 (kr0 == (num_block - 1)) ? diag_size : (kr + SIZE_B1);
3910
3911 list<C_Dsub_task<T> *> *C_task_arg = new list<C_Dsub_task<T> *>;
3912 // C_task_arg[kk] = new list<C_Dsub_task *>;
3913 list<int>* parents_r = new list<int>[child_contrib.size()];
3914 list<int>* parents_c = new list<int>[child_contrib.size()];
3915 long *ops_sum = new long;
3916 *ops_sum = 0L;
3917 int count_atomics = 0;
3918
3919 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3920 jt != child_contrib.end(); ++jt) {
3921
3922 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3923 mt != (*jt).diag_strip.end(); ++mt) {
3924 const int r_bgn_dst = (*mt).begin_dst;
3925 const int r_end_dst = r_bgn_dst + (*mt).width;
3926 if (r_end_dst < kr) {
3927 continue; // of loop mt
3928 }
3929 if (r_bgn_dst >= kr_end ) {
3930 break; // of loop mt
3931 }
3932 for (list <index_strip>::const_iterator nt =
3933 (*jt).offdiag_strip.begin();
3934 nt != (*jt).offdiag_strip.end(); ++nt) {
3935 const int c_bgn_dst = (*nt).begin_dst;
3936 const int c_end_dst = c_bgn_dst + (*nt).width;
3937 if (c_end_dst < kc) {
3938 continue;
3939 }
3940 if (c_bgn_dst >= kc_end) {
3941 break;
3942 }
3943 count_atomics++;
3944 }
3945 }
3946 } // loop : jt
3947
3948 int atomic_id = 0;
3949 int ll = 0;
3950 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
3951 jt != child_contrib.end(); ++jt, ll++) {
3952
3953 const int father_row = (*jt).father_row;
3954 SquareBlockMatrix<T> *child_pt = (*jt).child_pt;
3955 RectBlockMatrix<T> *father_offdiag_pt = (*jt).father_offdiag_pt;
3956 RectBlockMatrix<T> *father_offdia2_pt = (*jt).father_offdiag_unsym_pt;
3957
3958 for (list <index_strip>::const_iterator mt = (*jt).diag_strip.begin();
3959 mt != (*jt).diag_strip.end(); ++mt) {
3960 const int r_bgn_dst = (*mt).begin_dst;
3961 const int r_end_dst = r_bgn_dst + (*mt).width;
3962 if (r_end_dst < kr) {
3963 continue; // of loop mt
3964 }
3965 if (r_bgn_dst >= kr_end ) {
3966 break; // of loop mt
3967 }
3968 const int ir_bgn = imax(kr, r_bgn_dst);
3969 const int ir_end = imin(kr_end, r_end_dst);
3970 for (list <index_strip>::const_iterator nt = (*jt).offdiag_strip.begin();
3971 nt != (*jt).offdiag_strip.end(); ++nt) {
3972 const int c_bgn_dst = (*nt).begin_dst;
3973 const int c_end_dst = c_bgn_dst + (*nt).width;
3974 if (c_end_dst < kc) {
3975 continue;
3976 }
3977 if (c_bgn_dst >= kc_end) {
3978 break;
3979 }
3980 const int jc_bgn = imax(kc, c_bgn_dst);
3981 const int jc_end = imin(kc_end, c_end_dst);
3982 //
3983 // dsub_sym2rct(ir_bgn, ir_end, jc_bgn, jc_end,
3984 // ir_bgn_src, jc_bgn_src,
3985 // src_pt, src_pt)
3986 const long ops = ((long)(ir_end - ir_bgn) *
3987 (long)(jc_end - jc_bgn));
3988 const int ir_bgn_src =(*mt).begin_src + (ir_bgn - r_bgn_dst);
3989 const int jc_bgn_src =(*nt).begin_src + (jc_bgn - c_bgn_dst);
3990 const int ir_end_src = ir_bgn_src + (ir_end - ir_bgn);
3991 const int jc_end_src = jc_bgn_src + (jc_end - jc_bgn);
3992
3993 if ((ir_bgn < ir_end) && (jc_bgn < jc_end)) {
3994 C_Dsub_task<T> *tmp =
3995 new C_Dsub_task<T>(count_atomics,
3996 atomic_id++,
3997 (ir_bgn - kr),
3998 (ir_end - kr),
3999 (jc_bgn - kc),
4000 (jc_end - kc),
4001 ir_bgn_src,
4002 (-1), // ir_bgn_src2
4003 jc_bgn_src,
4004 (-1), // jc_bgn_src2
4005 father_row,
4006 (SquareBlockMatrix<T>*)NULL, // father_pt
4007 father_offdiag_pt,
4008 kr0, // ir_block
4009 kc0, // jc_block
4010 isSym ? (RectBlockMatrix<T> *)NULL : father_offdia2_pt,
4011 0, // without block
4012 0, // without block
4013 child_pt,
4014 (SquareBlockMatrix<T>*)NULL, // src_pt2
4015 isSym ? dsub_sym2rct<T> : dsub_unsym2rct<T>,
4016 false,
4017 ops,
4018 father_id,
4019 level,
4020 verbose,
4021 fp);
4022 C_task_arg->push_back(tmp);
4023 *ops_sum += ops;
4024 update_parents_list(parents_r[ll],
4025 ir_bgn_src, ir_end_src, child_pt);
4026 update_parents_list(parents_c[ll],
4027 jc_bgn_src, jc_end_src, child_pt);
4028 } // if ((ir_bgn < ir_end) && (jc_bgn < jc_end))
4029 } // loop : nt
4030 } // loop : mt
4031 } // loop : jt
4032 string task_name = ("j " + to_string(kr0) + " " + to_string(kc0)
4033 + " : " + to_string(level) + " : " +
4034 to_string(father_id + 1)); // selfIndex^-1
4035 queue[kk] = new C_task(C_DSUB,
4036 task_name, // task_name.str(),
4037 (void *)C_task_arg,
4038 C_Dsub_task_exec<T>,
4039 1,
4040 0,
4041 ops_sum);
4042 queue[kk]->parallel_max = block_offdiag_size; // block_total_size;
4043 queue[kk]->parallel_id = kk - block_diag_size;
4044 // added to manage parents of tasks_p and tasks_q
4045 if (tasks_r != NULL) {
4046 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
4047 jt != child_contrib.end();
4048 ++jt) {
4049 queue[kk]->parents->push_back(tasks_r[(*jt).child_id][0]);
4050 }
4051 }
4052 if (tasks_q.size() > 0) {
4053 // queue[kk]->parents->push_back(tasks_q[father_id][1]); // offdiag
4054 queue[kk]->parents->push_back(tasks_q[1]); // offdiag
4055 }
4056 if (tasks_s.size() > 0) { // offiag
4057 const int itmp = kc0 * num_block + kr0 + tasks_s[0]->parallel_max;
4058 queue[kk]->parents->push_back(tasks_s[itmp]);
4059 }
4060 // if (tasks_p != NULL) {
4061 ll = 0;
4062 for (typename list<child_contribution<T> >::const_iterator jt = child_contrib.begin();
4063 jt != child_contrib.end(); ++jt, ll++) {
4064 for (list<int>::const_iterator mt = parents_r[ll].begin();
4065 mt != parents_r[ll].end(); ++mt) {
4066 for (list<int>::const_iterator nt = parents_c[ll].begin();
4067 nt != parents_c[ll].end(); ++nt) {
4068 // ?? offdiag : to be debugged : 27 Mar.2012 Atsushi
4069 if ((*nt) >= (*mt)) { // upper block
4070 const int idx = (isSym?
4071 (((*nt) * ((*nt) + 1)) / 2 + (*mt)) :
4072 ((*nt) * (*nt) + 2 * (*mt)));
4073 vector<C_task *>&tasks_tmq = tasks_d[(*jt).child_id];
4074 vector<int> &indcolq = tasks_d_indcol[(*jt).child_id];
4075 if (tasks_p_flag) {
4076 vector<C_task *>&tasks_tmp = tasks_p[(*jt).child_id];
4077 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
4078 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx]]);
4079 }
4080 if (tasks_tmq.size() > 0) {
4081 tasks_tmq[indcolq[idx]]->parents->push_back(queue[kk]);
4082 }
4083 if (!isSym && ((*nt) > (*mt))) {
4084 if (tasks_p_flag) {
4085 vector<C_task *>&tasks_tmp = tasks_p[(*jt).child_id];
4086 vector<int> &indcolp = tasks_p_indcol[(*jt).child_id];
4087 queue[kk]->parents->push_back(tasks_tmp[indcolp[idx + 1]]);
4088 }
4089 if (tasks_tmq.size() > 0) {
4090 tasks_tmq[indcolq[idx + 1]]->parents->push_back(queue[kk]);
4091 }
4092 }
4093 }
4094 } // loop : nt
4095 } // loop : mt
4096 } // loop : jt
4097 // } // if (tasks_p != NULL) {
4098 queue[kk]->parents->sort(compare_task_name);
4099 queue[kk]->parents->unique();
4100 EraseNullParents(queue[kk]);
4101 for (int m = 0; m < child_contrib.size(); m++) {
4102 parents_r[m].clear();
4103 parents_c[m].clear();
4104 }
4105 delete [] parents_r;
4106 delete [] parents_c;
4107 kk++;
4108 } // loop : kr0
4109 } // loop : kc0
4110 } // else (child_contrib.size() == 2)
4111 }
4112
4113 template
4114 void C_Dsub_queue<double>(bool isSym,
4115 int father_id,
4116 bool skip_flag,
4117 vector<C_task *>& queue,
4118 list <child_contribution<double> > &child_contrib,
4119 vector<C_task *>* tasks_p,
4120 vector<int>* tasks_p_indcol,
4121 const bool tasks_p_flag,
4122 vector<C_task *>& tasks_q,
4123 vector<C_task *>* tasks_r,
4124 vector<C_task *>& tasks_s,
4125 vector<C_task *>* tasks_d,
4126 vector<int>* tasks_d_indcol,
4127 int level,
4128 const bool direct_flag,
4129 const bool verbose,
4130 FILE *fp);
4131
4132 template
4133 void C_Dsub_queue<quadruple>(bool isSym,
4134 int father_id,
4135 bool skip_flag,
4136 vector<C_task *>& queue,
4137 list <child_contribution<quadruple> > &child_contrib,
4138 vector<C_task *>* tasks_p,
4139 vector<int>* tasks_p_indcol,
4140 const bool tasks_p_flag,
4141 vector<C_task *>& tasks_q,
4142 vector<C_task *>* tasks_r,
4143 vector<C_task *>& tasks_s,
4144 vector<C_task *>* tasks_d,
4145 vector<int>* tasks_d_indcol,
4146 int level,
4147 const bool direct_flag,
4148 const bool verbose,
4149 FILE *fp);
4150
4151 template
4152 void C_Dsub_queue<complex<double> >(bool isSym,
4153 int father_id,
4154 bool skip_flag,
4155 vector<C_task *>& queue,
4156 list <child_contribution<complex<double> > > &child_contrib,
4157 vector<C_task *>* tasks_p,
4158 vector<int>* tasks_p_indcol,
4159 const bool tasks_p_flag,
4160 vector<C_task *>& tasks_q,
4161 vector<C_task *>* tasks_r,
4162 vector<C_task *>& tasks_s,
4163 vector<C_task *>* tasks_d,
4164 vector<int>* tasks_d_indcol,
4165 int level,
4166 const bool direct_flag,
4167 const bool verbose,
4168 FILE *fp);
4169
4170 template
4171 void C_Dsub_queue<complex<quadruple> >(bool isSym,
4172 int father_id,
4173 bool skip_flag,
4174 vector<C_task *>& queue,
4175 list <child_contribution<complex<quadruple> > > &child_contrib,
4176 vector<C_task *>* tasks_p,
4177 vector<int>* tasks_p_indcol,
4178 const bool tasks_p_flag,
4179 vector<C_task *>& tasks_q,
4180 vector<C_task *>* tasks_r,
4181 vector<C_task *>& tasks_s,
4182 vector<C_task *>* tasks_d,
4183 vector<int>* tasks_d_indcol,
4184 int level,
4185 const bool direct_flag,
4186 const bool verbose,
4187 FILE *fp);
4188
4189 template
4190 void C_Dsub_queue<float>(bool isSym,
4191 int father_id,
4192 bool skip_flag,
4193 vector<C_task *>& queue,
4194 list <child_contribution<float> > &child_contrib,
4195 vector<C_task *>* tasks_p,
4196 vector<int>* tasks_p_indcol,
4197 const bool tasks_p_flag,
4198 vector<C_task *>& tasks_q,
4199 vector<C_task *>* tasks_r,
4200 vector<C_task *>& tasks_s,
4201 vector<C_task *>* tasks_d,
4202 vector<int>* tasks_d_indcol,
4203 int level,
4204 const bool direct_flag,
4205 const bool verbose,
4206 FILE *fp);
4207
4208 template
4209 void C_Dsub_queue<complex<float> >(bool isSym,
4210 int father_id,
4211 bool skip_flag,
4212 vector<C_task *>& queue,
4213 list <child_contribution<complex<float> > > &child_contrib,
4214 vector<C_task *>* tasks_p,
4215 vector<int>* tasks_p_indcol,
4216 const bool tasks_p_flag,
4217 vector<C_task *>& tasks_q,
4218 vector<C_task *>* tasks_r,
4219 vector<C_task *>& tasks_s,
4220 vector<C_task *>* tasks_d,
4221 vector<int>* tasks_d_indcol,
4222 int level,
4223 const bool direct_flag,
4224 const bool verbose,
4225 FILE *fp);
4226
4227 //
4228
4229 template<typename T>
4230 void update_parents_list(list <int>& parents,
4231 const int begin, const int end,
4232 SquareBlockMatrix<T>* mtrx)
4233 // const int size_block)
4234 {
4235 const int ibgn = mtrx->BlockIndex(begin);
4236 const int iend = mtrx->BlockIndex(end - 1);
4237 for (int m = ibgn; m <= iend; m++) {
4238 bool flag = true;
4239 for (list<int>::const_iterator it = parents.begin();
4240 it != parents.end(); ++it) {
4241 if (*it == m) {
4242 flag = false;
4243 break;
4244 }
4245 }
4246 if (flag) {
4247 parents.push_back(m);
4248 }
4249 }
4250 }
4251
4252 template
4253 void update_parents_list<double>(list <int>& parents,
4254 const int begin, const int end,
4255 SquareBlockMatrix<double>* mtrx);
4256
4257 template
4258 void update_parents_list<quadruple>(list <int>& parents,
4259 const int begin, const int end,
4260 SquareBlockMatrix<quadruple>* mtrx);
4261 template
4262 void update_parents_list<complex<double> >(list <int>& parents,
4263 const int begin, const int end,
4264 SquareBlockMatrix<complex<double> >* mtrx);
4265
4266 template
4267 void update_parents_list<complex<quadruple> >(list <int>& parents,
4268 const int begin, const int end,
4269 SquareBlockMatrix<complex<quadruple> >* mtrx);
4270
4271 template
4272 void update_parents_list<float>(list <int>& parents,
4273 const int begin, const int end,
4274 SquareBlockMatrix<float>* mtrx);
4275
4276 template
4277 void update_parents_list<complex<float> >(list <int>& parents,
4278 const int begin, const int end,
4279 SquareBlockMatrix<complex<float> >* mtrx);
4280
4281 //