PaStiX Handbook  6.3.2
pastix_task_solve.c
Go to the documentation of this file.
1 /**
2  *
3  * @file pastix_task_solve.c
4  *
5  * PaStiX solve routines
6  *
7  * @copyright 2004-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.3.2
11  * @author Pascal Henon
12  * @author Xavier Lacoste
13  * @author Pierre Ramet
14  * @author Mathieu Faverge
15  * @author Theophile Terraz
16  * @author Alycia Lisito
17  * @author Brieuc Nicolas
18  * @author Tony Delarue
19  * @date 2023-11-10
20  *
21  **/
22 #ifndef DOXYGEN_SHOULD_SKIP_THIS
23 #define _GNU_SOURCE 1
24 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
25 #include "common.h"
26 #include "bcsc/bcsc.h"
27 #include "pastix/order.h"
28 #include "order/order_internal.h"
29 #include "blend/solver.h"
30 #include "sopalin/sopalin_data.h"
31 #include "pastix_papi.h"
32 
33 #include "bcsc/bcsc_z.h"
34 #include "bcsc/bcsc_c.h"
35 #include "bcsc/bcsc_d.h"
36 #include "bcsc/bcsc_s.h"
37 
38 #include <lapacke.h>
39 
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 
42 #if defined(PASTIX_DEBUG_SOLVE)
43 #include <spm/z_spm.h>
44 #include <spm/c_spm.h>
45 #include <spm/d_spm.h>
46 #include <spm/s_spm.h>
47 
48 /**
49  *******************************************************************************
50  *
51  * @brief TODO
52  *
53  *******************************************************************************
54  *
55  * @param[in] pastix_data
56  * The pastix_data structure that describes the solver instance.
57  *
58  * @param[in] name
59  * TODO
60  *
61  * @param[in] B
62  * TODO
63  *
64  *******************************************************************************/
65 static inline void
66 pastix_rhs_dump( pastix_data_t *pastix_data,
67  const char *name,
68  pastix_rhs_t B )
69 {
70  static volatile int32_t step = 0;
71 
72  int32_t lstep = pastix_atomic_inc_32b( &step );
73  char *fullname;
74  FILE *f;
75  int rc;
76 
77  rc = asprintf( &fullname, "%02d_%s.%02d.rhs",
78  lstep, name, pastix_data->solvmatr->clustnum );
79  assert( rc != -1 );
80 
81  f = pastix_fopenw( (pastix_data->dir_local == NULL) ? "." : pastix_data->dir_local,
82  fullname, "w" );
83  free( fullname );
84 
85  switch( B->flttype ) {
86  case SpmComplex64:
87  z_spmDensePrint( f, B->m, B->n, B->b, B->ld );
88  break;
89  case SpmComplex32:
90  c_spmDensePrint( f, B->m, B->n, B->b, B->ld );
91  break;
92  case SpmDouble:
93  d_spmDensePrint( f, B->m, B->n, B->b, B->ld );
94  break;
95  case SpmFloat:
96  s_spmDensePrint( f, B->m, B->n, B->b, B->ld );
97  break;
98  case SpmPattern:
99  ;
100  }
101 
102  fclose(f);
103  (void)rc;
104 }
105 #else
106 static inline void
107 pastix_rhs_dump( pastix_data_t *pastix_data,
108  const char *name,
109  pastix_rhs_t B )
110 {
111  (void)pastix_data;
112  (void)name;
113  (void)B;
114 }
115 #endif
116 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
117 
118 /**
119  *******************************************************************************
120  *
121  * @ingroup pastix_solve
122  *
123  * @brief Apply a permutation on the right-and-side vector before the solve step.
124  *
125  * This routine is affected by the following parameters:
126  * IPARM_VERBOSE, IPARM_FACTORIZATION, IPARM_APPLYPERM_WS.
127  *
128  *******************************************************************************
129  *
130  * @param[inout] pastix_data
131  * The pastix_data structure that describes the solver instance.
132  *
133  * @param[in] dir
134  * Forward or backword application of the permutation.
135  *
136  * @param[in] m
137  * Size of the right-and-side vectors.
138  *
139  * @param[in] n
140  * Number of right-and-side vectors.
141  *
142  * @param[inout] b
143  * The right-and-side vectors of size ldb-by-n.
144  * If dir == PastixDirForward, b is used as input to initialize the
145  * permuted b. If the matrix is replicated on all nodes or in shared
146  * memory, the permuted vector has the same size as b, and b is
147  * modified in-place.
148  * If dir == PastixDirBackward, b must be allocated on entry and is
149  * filled by the reverse permutation of Bp. Note that if the matrix is
150  * replicated on all nodes or in shared memory, b is modified in-place.
151  *
152  * @param[in] ldb
153  * The leading dimension of the right-and-side vectors.
154  *
155  * @param[inout] Bp
156  * The right-and-side vectors of size ldb-by-n. On entry, must be
157  * initialized through pastixRhsInit(). On exit, contains the
158  * information about the permuted vector when dir ==
159  * PastixDirForward. When dir == PastixDirBackward, the data is used as
160  * input to update b.
161  *
162  *******************************************************************************
163  *
164  * @retval PASTIX_SUCCESS on successful exit,
165  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
166  *
167  *******************************************************************************/
168 int
170  pastix_dir_t dir,
171  pastix_int_t m,
172  pastix_int_t n,
173  void *b,
174  pastix_int_t ldb,
175  pastix_rhs_t Bp )
176 {
177  pastix_coeftype_t flttype;
178 
179  /*
180  * Checks parameters.
181  */
182  if (pastix_data == NULL) {
183  pastix_print_error( "pastix_subtask_applyorder: wrong pastix_data parameter" );
185  }
186  if (Bp == NULL) {
187  pastix_print_error( "pastix_subtask_applyorder: wrong Bp parameter" );
189  }
190 
191  /* Makes sure ordering is 0 based. */
192  if ( pastix_data->ordemesh->baseval != 0 ) {
193  pastix_print_error( "pastix_subtask_applyorder: ordermesh must be 0-based" );
195  }
196 
197  flttype = pastix_data->csc->flttype;
198 #if defined(PASTIX_DEBUG_SOLVE)
199  if ( dir == PastixDirForward ) {
200  struct pastix_rhs_s rhsb = {
201  .allocated = 0,
202  .flttype = flttype,
203  .m = m,
204  .n = n,
205  .b = b,
206  .ld = ldb,
207  };
208  pastix_rhs_dump( pastix_data, "applyorder_Forward_input", &rhsb );
209  }
210  else {
211  pastix_rhs_dump( pastix_data, "applyorder_Backward_input", Bp );
212  }
213 #endif
214 
215  /* See also xlapmr and xlapmt */
216  switch( flttype ) {
217  case PastixComplex64:
218  bvec_zlapmr( pastix_data, dir, m, n, b, ldb, Bp );
219  break;
220 
221  case PastixComplex32:
222  bvec_clapmr( pastix_data, dir, m, n, b, ldb, Bp );
223  break;
224 
225  case PastixDouble:
226  bvec_dlapmr( pastix_data, dir, m, n, b, ldb, Bp );
227  break;
228 
229  case PastixFloat:
230  bvec_slapmr( pastix_data, dir, m, n, b, ldb, Bp );
231  break;
232 
233  default:
234  pastix_print_error( "The floating type of the rhs is not defined\n" );
236  }
237 
238 #if defined(PASTIX_DEBUG_SOLVE)
239  if ( dir == PastixDirForward ) {
240  pastix_rhs_dump( pastix_data, "applyorder_Forward_output", Bp );
241  }
242  else {
243  struct pastix_rhs_s rhsb = {
244  .allocated = 0,
245  .flttype = flttype,
246  .m = m,
247  .n = n,
248  .b = b,
249  .ld = ldb,
250  };
251  pastix_rhs_dump( pastix_data, "applyorder_Backward_output", &rhsb );
252  }
253 #endif
254 
255  return PASTIX_SUCCESS;
256 }
257 
258 /**
259  *******************************************************************************
260  *
261  * @ingroup pastix_solve
262  *
263  * @brief Apply a triangular solve on the right-and-side vectors.
264  *
265  * This routine is affected by the following parameters:
266  * IPARM_VERBOSE, IPARM_FACTORIZATION.
267  *
268  *******************************************************************************
269  *
270  * @param[inout] pastix_data
271  * The pastix_data structure that describes the solver instance.
272  *
273  * @param[in] side
274  * Left or right application.
275  *
276  * @param[in] uplo
277  * Upper or Lower part.
278  *
279  * @param[in] trans
280  * With or without transposition (or conjugate transposition).
281  *
282  * @param[in] diag
283  * Diagonal terms are unit or not.
284  *
285  * @param[inout] Bp
286  * The right-and-side vector (can be multiple rhs).
287  * On exit, the solution is stored in place of the right-hand-side vector.
288  *
289  *******************************************************************************
290  *
291  * @retval PASTIX_SUCCESS on successful exit,
292  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
293  *
294  *******************************************************************************/
295 int
297  pastix_side_t side,
298  pastix_uplo_t uplo,
299  pastix_trans_t trans,
300  pastix_diag_t diag,
301  pastix_rhs_t Bp )
302 {
303  SolverMatrix *solvmtx;
304  sopalin_data_t sopalin_data;
306 
307  /*
308  * Check parameters
309  */
310  if (pastix_data == NULL) {
311  pastix_print_error( "pastix_subtask_trsm: wrong pastix_data parameter" );
313  }
314  if (Bp == NULL) {
315  pastix_print_error( "pastix_subtask_trsm: wrong Bp parameter" );
317  }
318  if ( !(pastix_data->steps & STEP_NUMFACT) ) {
319  pastix_print_error( "pastix_subtask_trsm: All steps from pastix_task_init() to pastix_task_numfact() have to be called before calling this function" );
321  }
322 
323  flttype = Bp->flttype;
324  solvmtx = pastix_data->solvmatr;
325 
326  if ( Bp->cblkb == NULL ) {
327  pastix_int_t nbbuffers;
328 
329  nbbuffers = solvmtx->faninnbr + solvmtx->recvnbr;
330  if ( nbbuffers > 0 ) {
331  Bp->cblkb = calloc( nbbuffers, sizeof(void*) );
332  }
333  }
334 
335  /*
336  * Ensure that the scheduler is correct and is in the same
337  * family that the one used for the factorization.
338  */
339  pastix_check_and_correct_scheduler( pastix_data );
340 
341  sopalin_data.solvmtx = solvmtx;
342 
343  switch (flttype) {
344  case PastixComplex64:
345  {
346  sopalin_ztrsm( pastix_data, side, uplo, trans, diag,
347  &sopalin_data, Bp );
348  }
349  break;
350  case PastixComplex32:
351  {
352  sopalin_ctrsm( pastix_data, side, uplo, trans, diag,
353  &sopalin_data, Bp );
354  }
355  break;
356  case PastixDouble:
357  {
358  trans = (trans == PastixConjTrans) ? PastixTrans : trans;
359  sopalin_dtrsm( pastix_data, side, uplo, trans, diag,
360  &sopalin_data, Bp );
361  }
362  break;
363  case PastixFloat:
364  {
365  trans = (trans == PastixConjTrans) ? PastixTrans : trans;
366  sopalin_strsm( pastix_data, side, uplo, trans, diag,
367  &sopalin_data, Bp );
368  }
369  break;
370  default:
371  fprintf(stderr, "Unknown floating point arithmetic\n" );
372  }
373 
374 #if defined(PASTIX_DEBUG_SOLVE)
375  {
376  char *fullname;
377  asprintf( &fullname, "solve_trsm_%c%c%c%c",
378  (side == PastixLeft) ? 'L' : 'R',
379  (uplo == PastixUpper) ? 'U' : 'L',
380  (trans == PastixConjTrans) ? 'C' : (trans == PastixTrans ? 'T' : 'N'),
381  (diag == PastixUnit) ? 'U' : 'N' );
382 
383  pastix_rhs_dump( pastix_data, fullname, Bp );
384  free(fullname);
385  }
386 #endif
387 
388  return PASTIX_SUCCESS;
389 }
390 
391 /**
392  *******************************************************************************
393  *
394  * @ingroup pastix_solve
395  *
396  * @brief Apply a diagonal operation on the right-and-side vectors.
397  *
398  * This routine is affected by the following parameters:
399  * IPARM_VERBOSE, IPARM_FACTORIZATION.
400  *
401  *******************************************************************************
402  *
403  * @param[inout] pastix_data
404  * The pastix_data structure that describes the solver instance.
405  *
406  * @param[inout] Bp
407  * The right-and-side vector (can be multiple rhs).
408  * On exit, the solution is stored in place of the right-hand-side vector.
409  *
410  *******************************************************************************
411  *
412  * @retval PASTIX_SUCCESS on successful exit,
413  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
414  *
415  *******************************************************************************/
416 int
418  pastix_rhs_t Bp )
419 {
420  sopalin_data_t sopalin_data;
422  pastix_int_t nrhs;
423  void *b;
424  pastix_int_t ldb;
425 
426  /*
427  * Check parameters
428  */
429  if (pastix_data == NULL) {
430  pastix_print_error( "pastix_subtask_diag: wrong pastix_data parameter" );
432  }
433  if (Bp == NULL) {
434  pastix_print_error( "pastix_subtask_diag: wrong Bp parameter" );
436  }
437  if ( !(pastix_data->steps & STEP_NUMFACT) ) {
438  pastix_print_error( "pastix_subtask_trsm: All steps from pastix_task_init() to pastix_task_numfact() have to be called before calling this function" );
440  }
441 
442  flttype = Bp->flttype;
443  nrhs = Bp->n;
444  b = Bp->b;
445  ldb = Bp->ld;
446 
447  /*
448  * Ensure that the scheduler is correct and is in the same
449  * family that the one used for the factorization.
450  */
451  pastix_check_and_correct_scheduler( pastix_data );
452 
453  sopalin_data.solvmtx = pastix_data->solvmatr;
454 
455  switch (flttype) {
456  case PastixComplex64:
457  sopalin_zdiag( pastix_data, &sopalin_data, nrhs, (pastix_complex64_t *)b, ldb );
458  break;
459  case PastixComplex32:
460  sopalin_cdiag( pastix_data, &sopalin_data, nrhs, (pastix_complex32_t *)b, ldb );
461  break;
462  case PastixDouble:
463  sopalin_ddiag( pastix_data, &sopalin_data, nrhs, (double *)b, ldb );
464  break;
465  case PastixFloat:
466  sopalin_sdiag( pastix_data, &sopalin_data, nrhs, (float *)b, ldb );
467  break;
468  default:
469  fprintf(stderr, "Unknown floating point arithmetic\n" );
470  }
471 
472  pastix_rhs_dump( pastix_data, "solve_diag", Bp );
473 
474  return PASTIX_SUCCESS;
475 }
476 
477 /**
478  *******************************************************************************
479  *
480  * @ingroup pastix_solve
481  *
482  * @brief Solve the given problem without applying the permutation.
483  *
484  * @warning The input vector is considered already permuted. For a solve step
485  * with permutation, see pastix_task_solve()
486  *
487  * This routine is affected by the following parameters:
488  * IPARM_VERBOSE, IPARM_FACTORIZATION.
489  *
490  *******************************************************************************
491  *
492  * @param[inout] pastix_data
493  * The pastix_data structure that describes the solver instance.
494  *
495  * @param[in] transA
496  * PastixNoTrans: A is not transposed (CSC matrix)
497  * PastixTrans: A is transposed (CSR of symmetric/general matrix)
498  * PastixConjTrans: A is conjugate transposed (CSR of hermitian matrix)
499  *
500  * @param[inout] Bp
501  * The right-and-side vectors (can be multiple rhs).
502  * On exit, the solution is stored in place of the right-hand-side vector.
503  *
504  *******************************************************************************
505  *
506  * @retval PASTIX_SUCCESS on successful exit,
507  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
508  *
509  *******************************************************************************/
510 int
512  pastix_trans_t transA,
513  pastix_rhs_t Bp )
514 {
515  pastix_bcsc_t *bcsc;
516  pastix_factotype_t factotype;
517 
518  pastix_uplo_t uplo;
519  pastix_diag_t diag;
520  pastix_trans_t trans;
521  pastix_trans_t transfact = PastixTrans;
522  pastix_rhs_t sBp;
523  pastix_rhs_t B;
524 
525  /*
526  * Check parameters
527  */
528  if (pastix_data == NULL) {
529  pastix_print_error( "pastix_task_solve: wrong pastix_data parameter" );
531  }
532  if ( !(pastix_data->steps & STEP_NUMFACT) ) {
533  pastix_print_error( "pastix_task_solve: All steps from pastix_task_init() to pastix_task_numfact() have to be called before calling this function" );
535  }
536 
537  bcsc = pastix_data->bcsc;
538  factotype = pastix_data->iparm[IPARM_FACTORIZATION];
539 
540  /**
541  *
542  * Summary of the operations to perform the full solve if the original A was
543  * either transposed or conjugate transposed.
544  *
545  * op(A) | Factorization | Step 1 | Step 2
546  * ----------+---------------------+-----------+-----------
547  * NoTrans | L U | L y = b | U x = y
548  * NoTrans | L L^t | L y = b | L^t x = y
549  * NoTrans | L L^h | L y = b | L^h x = y
550  * Trans |(L U )^t = U^t L^t | U^t y = b | L^t x = y
551  * Trans |(L L^t)^t = L L^t | L y = b | L^t x = y
552  * Trans |(L L^h)^t = c(L) L^t | Not handled (c(L))
553  * ConjTrans |(L U )^h = U^h L^h | Not handled (U^h)
554  * ConjTrans |(L L^t)^h = c(L) L^h | Not handled (c(L))
555  * ConjTrans |(L L^h)^h = L L^h | L y = b | L^h x = y
556  *
557  */
558  /* Value of the transpose case */
559  if ( ((bcsc->flttype == PastixComplex32) || (bcsc->flttype == PastixComplex64)) &&
560  ((factotype == PastixFactLLH ) || ( factotype == PastixFactLDLH )) )
561  {
562  transfact = PastixConjTrans;
563  }
564 
565  if ( (transA != PastixNoTrans) &&
566  (transA != transfact) )
567  {
568  pastix_print_error( "pastix_task_solve: transA incompatible with the factotype used (require extra conj(L) not handled)" );
570  }
571 
572  {
573  double timer, energy;
574 
575  papiEnergyStart();
576  if ( pastix_data->iparm[IPARM_TRACE] & PastixTraceSolve ) {
578  }
579  /* Start timer */
580  clockSyncStart( timer, pastix_data->inter_node_comm );
581 
582  if ( pastix_data->iparm[IPARM_MIXED] &&
583  ( ( Bp->flttype == PastixComplex64 ) || ( Bp->flttype == PastixDouble ) ) )
584  {
585  pastixRhsInit( &sBp );
586  pastixRhsDoubletoSingle( Bp, sBp );
587 
588  B = sBp;
589  }
590  else {
591  B = Bp;
592  }
593 
594  /*
595  * Solve the first step
596  */
597  uplo = PastixLower;
598  trans = PastixNoTrans;
599  diag = PastixNonUnit;
600 
601  if (( transA != PastixNoTrans ) && ( factotype == PastixFactLU )) {
602  uplo = PastixUpper;
603  trans = transA;
604  }
605  if (( transA == PastixNoTrans ) && ( factotype == PastixFactLU )) {
606  diag = PastixUnit;
607  }
608 
609  if (( factotype == PastixFactLDLT ) ||
610  ( factotype == PastixFactLDLH ) )
611  {
612  diag = PastixUnit;
613  }
614 
615  pastix_subtask_trsm( pastix_data, PastixLeft, uplo, trans, diag, B );
616 
617  /*
618  * Solve the diagonal step
619  */
620  if( (factotype == PastixFactLDLT) ||
621  (factotype == PastixFactLDLH) )
622  {
623  /* Solve y = D z with z = ([L^t | L^h] P x) */
624  pastix_subtask_diag( pastix_data, B );
625  }
626 
627  /*
628  * Solve the second step
629  */
630  uplo = PastixLower;
631  trans = transfact;
632  diag = PastixNonUnit;
633 
634  if (( transA == PastixNoTrans ) && ( factotype == PastixFactLU )) {
635  uplo = PastixUpper;
636  trans = PastixNoTrans;
637  }
638  if (( transA != PastixNoTrans ) && ( factotype == PastixFactLU )) {
639  diag = PastixUnit;
640  }
641 
642  if (( factotype == PastixFactLDLT ) ||
643  ( factotype == PastixFactLDLH ) )
644  {
645  diag = PastixUnit;
646  }
647 
648  pastix_subtask_trsm( pastix_data, PastixLeft, uplo, trans, diag, B );
649 
650  if ( pastix_data->iparm[IPARM_MIXED] &&
651  ( ( Bp->flttype == PastixComplex64 ) || ( Bp->flttype == PastixDouble ) ) )
652  {
653  pastixRhsSingleToDouble( sBp, Bp );
654  pastixRhsFinalize( sBp );
655  }
656 
657  /* Stop Timer */
658  clockSyncStop( timer, pastix_data->inter_node_comm );
659  if ( pastix_data->iparm[IPARM_TRACE] & PastixTraceSolve ) {
661  }
662  energy = papiEnergyStop();
663 
664  pastix_data->dparm[DPARM_SOLV_TIME] = clockVal(timer);
665  pastix_data->dparm[DPARM_SOLV_ENERGY] = energy;
666 
667  if ( pastix_data->iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
668  pastix_print( pastix_data->inter_node_procnum, 0, OUT_TIME_SOLV,
669  pastix_data->dparm[DPARM_SOLV_TIME] );
670 #if defined(PASTIX_WITH_PAPI)
671  pastix_print( pastix_data->inter_node_procnum, 0, OUT_SOLVE_ENERGY,
672  pastix_print_value_deci( pastix_data->dparm[DPARM_SOLV_ENERGY] ),
673  pastix_print_unit_deci( pastix_data->dparm[DPARM_SOLV_ENERGY] ),
674  pastix_print_value_deci( pastix_data->dparm[DPARM_SOLV_ENERGY] / pastix_data->dparm[DPARM_SOLV_TIME] ),
675  pastix_print_unit_deci( pastix_data->dparm[DPARM_SOLV_ENERGY] / pastix_data->dparm[DPARM_SOLV_TIME] ) );
676 #endif
677  }
678  }
679 
680  return PASTIX_SUCCESS;
681 }
682 
683 /**
684  *******************************************************************************
685  *
686  * @ingroup pastix_solve
687  *
688  * @brief Solve the given problem without applying the permutation.
689  *
690  * @warning The input vector is considered already permuted. For a solve step
691  * with permutation, see pastix_task_solve()
692  *
693  * This routine is affected by the following parameters:
694  * IPARM_VERBOSE, IPARM_FACTORIZATION, IPARM_TRANSPOSE_SOLVE.
695  *
696  *******************************************************************************
697  *
698  * @param[inout] pastix_data
699  * The pastix_data structure that describes the solver instance.
700  *
701  * @param[inout] Bp
702  * The right-and-side vectors (can be multiple rhs).
703  * On exit, the solution is stored in place of the right-hand-side vector.
704  *
705  *******************************************************************************
706  *
707  * @retval PASTIX_SUCCESS on successful exit,
708  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
709  *
710  *******************************************************************************/
711 int
713  pastix_rhs_t Bp )
714 {
715  return pastix_subtask_solve_adv( pastix_data,
716  pastix_data->iparm[IPARM_TRANSPOSE_SOLVE],
717  Bp );
718 }
719 
720 /**
721  *******************************************************************************
722  *
723  * @ingroup pastix_users
724  *
725  * @brief Solve the given problem.
726  *
727  * This routine is affected by the following parameters:
728  * IPARM_VERBOSE, IPARM_FACTORIZATION, IPARM_TRANSPOSE_SOLVE.
729  *
730  *******************************************************************************
731  *
732  * @param[inout] pastix_data
733  * The pastix_data structure that describes the solver instance.
734  *
735  * @param[in] m
736  * The local number of rows of the right-and-side vectors.
737  * If the spm is centralized or replicated, m must be equal to
738  * spm->gNexp, otherwise m must be equal to spm->nexp.
739  *
740  * @param[in] nrhs
741  * The number of right-and-side vectors.
742  *
743  * @param[inout] b
744  * The right-and-side vectors (can be multiple rhs).
745  * On exit, the solution is stored in place of the right-hand-side vector.
746  *
747  * @param[in] ldb
748  * The leading dimension of the right-and-side vectors.
749  *
750  *******************************************************************************
751  *
752  * @retval PASTIX_SUCCESS on successful exit,
753  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
754  *
755  *******************************************************************************/
756 int
758  pastix_int_t m,
759  pastix_int_t nrhs,
760  void *b,
761  pastix_int_t ldb )
762 {
763  pastix_rhs_t Bp;
764  pastix_int_t rc;
765 
766  /*
767  * Check parameters
768  */
769  if (pastix_data == NULL) {
770  pastix_print_error( "pastix_task_solve: wrong pastix_data parameter" );
772  }
773 
774  if ( !(pastix_data->steps & STEP_NUMFACT) ) {
775  pastix_print_error( "pastix_task_solve: Numerical factorization hasn't been done." );
777  }
778 
779  /* Compute P * b */
780  rc = pastixRhsInit( &Bp );
781  if( rc != PASTIX_SUCCESS ) {
782  return rc;
783  }
784 
785  rc = pastix_subtask_applyorder( pastix_data, PastixDirForward, m, nrhs, b, ldb, Bp );
786  if( rc != PASTIX_SUCCESS ) {
787  return rc;
788  }
789 
790  /* Solve A x = b */
791  rc = pastix_subtask_solve( pastix_data, Bp );
792  if( rc != PASTIX_SUCCESS ) {
793  return rc;
794  }
795 
796  /* Compute P^t * b */
797  rc = pastix_subtask_applyorder( pastix_data, PastixDirBackward, m, nrhs, b, ldb, Bp );
798  if( rc != PASTIX_SUCCESS ) {
799  return rc;
800  }
801 
802  rc = pastixRhsFinalize( Bp );
803  if( rc != PASTIX_SUCCESS ) {
804  return rc;
805  }
806 
807  return rc;
808 }
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
float _Complex pastix_complex32_t
Definition: datatypes.h:76
int bvec_slapmr(pastix_data_t *pastix_data, pastix_dir_t dir, pastix_int_t m, pastix_int_t n, float *A, pastix_int_t lda, pastix_rhs_t PA)
Apply a row permutation to a right hand side A (LAPACK xlatmr)
Definition: bvec_slapmr.c:816
int pastixRhsInit(pastix_rhs_t *rhs)
Initialize an RHS data structure.
Definition: pastix_rhs.c:41
int pastixRhsFinalize(pastix_rhs_t rhs)
Cleanup an RHS data structure.
Definition: pastix_rhs.c:86
int bvec_dlapmr(pastix_data_t *pastix_data, pastix_dir_t dir, pastix_int_t m, pastix_int_t n, double *A, pastix_int_t lda, pastix_rhs_t PA)
Apply a row permutation to a right hand side A (LAPACK xlatmr)
Definition: bvec_dlapmr.c:816
int bvec_zlapmr(pastix_data_t *pastix_data, pastix_dir_t dir, pastix_int_t m, pastix_int_t n, pastix_complex64_t *A, pastix_int_t lda, pastix_rhs_t PA)
Apply a row permutation to a right hand side A (LAPACK xlatmr)
Definition: bvec_zlapmr.c:816
int bvec_clapmr(pastix_data_t *pastix_data, pastix_dir_t dir, pastix_int_t m, pastix_int_t n, pastix_complex32_t *A, pastix_int_t lda, pastix_rhs_t PA)
Apply a row permutation to a right hand side A (LAPACK xlatmr)
Definition: bvec_clapmr.c:816
void kernelsTraceStop()
Pauses the trace module.
void kernelsTraceStart()
Resumes the trace module.
Definition: kernels_trace.c:90
spm_coeftype_t pastix_coeftype_t
Arithmetic types.
Definition: api.h:294
enum pastix_diag_e pastix_diag_t
Diagonal.
enum pastix_dir_e pastix_dir_t
Direction.
FILE * pastix_fopenw(const char *dirname, const char *filename, const char *mode)
Open a file in the unique directory of the pastix instance.
Definition: api.c:242
enum pastix_uplo_e pastix_uplo_t
Upper/Lower part.
enum pastix_side_e pastix_side_t
Side of the operation.
enum pastix_factotype_e pastix_factotype_t
Factorization algorithms available for IPARM_FACTORIZATION parameter.
enum pastix_trans_e pastix_trans_t
Transpostion.
@ PastixDirForward
Definition: api.h:513
@ PastixDirBackward
Definition: api.h:514
@ PastixFactLDLH
Definition: api.h:319
@ PastixFactLDLT
Definition: api.h:316
@ PastixFactLLH
Definition: api.h:315
@ PastixFactLU
Definition: api.h:317
@ DPARM_SOLV_TIME
Definition: api.h:177
@ DPARM_SOLV_ENERGY
Definition: api.h:181
@ IPARM_FACTORIZATION
Definition: api.h:99
@ IPARM_MIXED
Definition: api.h:139
@ IPARM_VERBOSE
Definition: api.h:36
@ IPARM_TRACE
Definition: api.h:44
@ IPARM_TRANSPOSE_SOLVE
Definition: api.h:106
@ PastixUpper
Definition: api.h:466
@ PastixLower
Definition: api.h:467
@ PastixLeft
Definition: api.h:495
@ PastixUnit
Definition: api.h:488
@ PastixNonUnit
Definition: api.h:487
@ PastixConjTrans
Definition: api.h:447
@ PastixNoTrans
Definition: api.h:445
@ PastixTrans
Definition: api.h:446
@ PastixVerboseNot
Definition: api.h:220
@ PASTIX_SUCCESS
Definition: api.h:367
@ PASTIX_ERR_BADPARAMETER
Definition: api.h:374
@ PastixTraceSolve
Definition: api.h:212
pastix_int_t baseval
Definition: order.h:48
int pastix_subtask_solve_adv(pastix_data_t *pastix_data, pastix_trans_t transA, pastix_rhs_t Bp)
Solve the given problem without applying the permutation.
int pastixRhsDoubletoSingle(const pastix_rhs_t dB, pastix_rhs_t sB)
Reduces the precision of an RHS.
Definition: pastix_rhs.c:146
int pastix_subtask_applyorder(pastix_data_t *pastix_data, pastix_dir_t dir, pastix_int_t m, pastix_int_t n, void *b, pastix_int_t ldb, pastix_rhs_t Bp)
Apply a permutation on the right-and-side vector before the solve step.
int pastix_subtask_diag(pastix_data_t *pastix_data, pastix_rhs_t Bp)
Apply a diagonal operation on the right-and-side vectors.
int pastix_subtask_solve(pastix_data_t *pastix_data, pastix_rhs_t Bp)
Solve the given problem without applying the permutation.
int pastix_subtask_trsm(pastix_data_t *pastix_data, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, pastix_rhs_t Bp)
Apply a triangular solve on the right-and-side vectors.
int pastixRhsSingleToDouble(const pastix_rhs_t sB, pastix_rhs_t dB)
Increases the precision of an RHS.
Definition: pastix_rhs.c:226
int inter_node_procnum
Definition: pastixdata.h:83
void ** cblkb
Definition: pastixdata.h:157
SolverMatrix * solvmatr
Definition: pastixdata.h:102
pastix_order_t * ordemesh
Definition: pastixdata.h:97
pastix_int_t * iparm
Definition: pastixdata.h:69
pastix_int_t ld
Definition: pastixdata.h:155
char * dir_local
Definition: pastixdata.h:110
double * dparm
Definition: pastixdata.h:70
const spmatrix_t * csc
Definition: pastixdata.h:89
pastix_coeftype_t flttype
Definition: pastixdata.h:152
PASTIX_Comm inter_node_comm
Definition: pastixdata.h:77
pastix_int_t m
Definition: pastixdata.h:153
pastix_bcsc_t * bcsc
Definition: pastixdata.h:101
pastix_int_t steps
Definition: pastixdata.h:72
pastix_int_t n
Definition: pastixdata.h:154
int8_t allocated
Definition: pastixdata.h:151
int pastix_task_solve(pastix_data_t *pastix_data, pastix_int_t m, pastix_int_t nrhs, void *b, pastix_int_t ldb)
Solve the given problem.
Main PaStiX data structure.
Definition: pastixdata.h:67
Main PaStiX RHS structure.
Definition: pastixdata.h:150
-by-step
void sopalin_cdiag(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data, int nrhs, pastix_complex32_t *b, int ldb)
TODO.
void sopalin_ctrsm(pastix_data_t *pastix_data, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, sopalin_data_t *sopalin_data, pastix_rhs_t rhsb)
Calls the sequential, static, dynamic or runtime solve according to scheduler.
void sopalin_ddiag(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data, int nrhs, double *b, int ldb)
TODO.
void sopalin_dtrsm(pastix_data_t *pastix_data, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, sopalin_data_t *sopalin_data, pastix_rhs_t rhsb)
Calls the sequential, static, dynamic or runtime solve according to scheduler.
void sopalin_sdiag(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data, int nrhs, float *b, int ldb)
TODO.
void sopalin_strsm(pastix_data_t *pastix_data, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, sopalin_data_t *sopalin_data, pastix_rhs_t rhsb)
Calls the sequential, static, dynamic or runtime solve according to scheduler.
void sopalin_zdiag(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data, int nrhs, pastix_complex64_t *b, int ldb)
TODO.
void sopalin_ztrsm(pastix_data_t *pastix_data, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, sopalin_data_t *sopalin_data, pastix_rhs_t rhsb)
Calls the sequential, static, dynamic or runtime solve according to scheduler.
pastix_int_t faninnbr
Definition: solver.h:209
pastix_int_t recvnbr
Definition: solver.h:212
Solver column block structure.
Definition: solver.h:200