PaStiX Handbook  6.3.2
pastix_task_sopalin.c
Go to the documentation of this file.
1 /**
2  *
3  * @file pastix_task_sopalin.c
4  *
5  * PaStiX factorization 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 Esragul Korkmaz
16  * @author Gregoire Pichon
17  * @author Theophile Terraz
18  * @author Alycia Lisito
19  * @author Brieuc Nicolas
20  * @author nbredel
21  * @author Nolan Bredel
22  * @author Tony Delarue
23  * @date 2023-12-11
24  *
25  **/
26 #include "common.h"
27 #include <lapacke.h>
28 #include "isched.h"
29 #include <spm.h>
30 #include "bcsc/bcsc.h"
31 #include "blend/solver.h"
32 #include "coeftab.h"
33 #include "sopalin/sopalin_data.h"
34 #include "kernels/pastix_lowrank.h"
39 #include "kernels/kernels_trace.h"
40 #include "pastix_papi.h"
41 
42 #if defined(PASTIX_WITH_PARSEC)
44 #endif
45 
46 #if defined(PASTIX_WITH_STARPU)
48 #endif
49 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 static void (*sopalinFacto[5][4])(pastix_data_t *, sopalin_data_t*) =
52 {
58 };
59 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
60 
61 /**
62  *******************************************************************************
63  *
64  * @ingroup pastix_numfact
65  *
66  * @brief Fill the internal block CSC structure.
67  *
68  * This internal block CSC can be used by the refinement step with or without
69  * the preconditioner obtained by the numerical factorization.
70  *
71  * This routine is affected by the following parameters:
72  * IPARM_VERBOSE.
73  *
74  *******************************************************************************
75  *
76  * @param[inout] pastix_data
77  * The pastix_data structure that describes the solver instance.
78  * On exit, the internal block CSC is filled with entries from
79  * the spm matrix.
80  *
81  * @param[inout] spm
82  * The sparse matrix descriptor that describes problem instance.
83  * On exit, if IPARM_FREE_CSCUSER is set, the spm is freed.
84  *
85  *******************************************************************************
86  *
87  * @retval PASTIX_SUCCESS on successful exit,
88  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect,
89  * @retval PASTIX_ERR_OUTOFMEMORY if one allocation failed.
90  *
91  *******************************************************************************/
92 int
94  spmatrix_t *spm )
95 {
96  double time;
97 
98  /*
99  * Check parameters
100  */
101  if (pastix_data == NULL) {
102  pastix_print_error( "pastix_subtask_spm2bcsc: wrong pastix_data parameter" );
104  }
105  if (spm == NULL) {
106  pastix_print_error( "pastix_subtask_spm2bcsc: wrong spm parameter" );
108  }
109  if ( !(pastix_data->steps & STEP_ANALYSE) ) {
110  pastix_print_error( "pastix_subtask_spm2bcsc: All steps from pastix_task_init() to pastix_task_blend() have to be called before calling this function" );
112  }
113 
114  /*
115  * Compute the norm of A, to scale the epsilon parameter for pivoting
116  */
117  {
118  pastix_data->dparm[ DPARM_A_NORM ] = spmNorm( SpmFrobeniusNorm, spm );
119  if ( pastix_data->iparm[IPARM_VERBOSE] > PastixVerboseNo ) {
120  pastix_print( pastix_data->inter_node_procnum, 0,
121  " ||A||_2 = %e\n",
122  pastix_data->dparm[ DPARM_A_NORM ] );
123  }
124  }
125 
126  /*
127  * Switch the SolverMatrix pointer according to the runtime.
128  */
129  {
130  pastix_int_t isched = pastix_data->iparm[IPARM_SCHEDULER];
131 
132  /*
133  * Temporary disable LDL[th] factorization with runtime
134  */
135  if ( ( isched == PastixSchedParsec ) &&
136  ( ( pastix_data->iparm[IPARM_FACTORIZATION] == PastixFactLDLH ) ||
137  ( pastix_data->iparm[IPARM_FACTORIZATION] == PastixFactLDLT ) ) ) {
138  isched = PastixSchedDynamic;
139  }
140 
141  if ( isSchedRuntime( isched ) ) {
142  pastix_data->solvmatr = pastix_data->solvglob;
143  }
144  else {
145  assert( isSchedPthread( isched ) );
146  pastix_data->solvmatr = pastix_data->solvloc;
147  }
148  pastix_data->sched = isched;
149  }
150 
151  /*
152  * Fill in the internal blocked CSC. We consider that if this step is called
153  * the spm values have changed so we need to update the blocked csc.
154  */
155  if ( pastix_data->bcsc != NULL )
156  {
157  bcscExit( pastix_data->bcsc );
158  memFree_null( pastix_data->bcsc );
159  }
160  MALLOC_INTERN( pastix_data->bcsc, 1, pastix_bcsc_t );
161 
162  time = bcscInit( spm,
163  pastix_data->ordemesh,
164  pastix_data->solvmatr,
165  (pastix_data->iparm[IPARM_FACTORIZATION] == PastixFactLU), /*&& (! pastix_data->iparm[IPARM_ONLY_REFINE]) )*/
166  pastix_data->bcsc );
167 
168  if ( pastix_data->iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
169  pastix_print( pastix_data->inter_node_procnum, 0, OUT_BCSC_TIME, time );
170  }
171 
172  if ( pastix_data->iparm[IPARM_FREE_CSCUSER] ) {
173  spmExit( spm );
174  }
175 
176  /*
177  * Invalidate following step, and add current step to the ones performed
178  */
179  pastix_data->steps &= ~STEP_BCSC2CTAB;
180  pastix_data->steps |= STEP_CSC2BCSC;
181 
182  return PASTIX_SUCCESS;
183 }
184 
185 /**
186  *******************************************************************************
187  *
188  * @ingroup pastix_numfact
189  *
190  * @brief Fill the internal solver matrix structure.
191  *
192  * This step is linked with the pastix_subtask_sopalin() since this structure is
193  * only used during the numerical factorization.
194  *
195  * This routine is affected by the following parameters:
196  * IPARM_VERBOSE, [IPARM_FACTORIZATION.
197  *
198  *******************************************************************************
199  *
200  * @param[inout] pastix_data
201  * The pastix_data structure that describes the solver instance.
202  * On exit, the internal solver structure is filled with entries from
203  * the internal block CSC matrix.
204  *
205  *******************************************************************************
206  *
207  * @retval PASTIX_SUCCESS on successful exit,
208  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect,
209  * @retval PASTIX_ERR_OUTOFMEMORY if one allocation failed.
210  *
211  *******************************************************************************/
212 int
214 {
215  pastix_bcsc_t *bcsc;
216  pastix_lr_t *lr;
217  Clock timer;
218  pastix_mtxtype_t mtxtype;
219 
220  /*
221  * Check parameters
222  */
223  if (pastix_data == NULL) {
224  pastix_print_error( "pastix_subtask_bcsc2ctab: wrong pastix_data parameter" );
226  }
227  if ( !(pastix_data->steps & STEP_CSC2BCSC) ) {
228  pastix_print_error( "pastix_subtask_bcsc2ctab: All steps from pastix_task_init() to pastix_stask_blend() have to be called before calling this function" );
230  }
231  if (pastix_data->bcsc == NULL) {
232  pastix_print_error( "pastix_subtask_bcsc2ctab: wrong pastix_data->bcsc parameter" );
234  }
235 
236  /* Ensure that the scheduler is correct */
237  pastix_check_and_correct_scheduler( pastix_data );
238 
239  clockSyncStart( timer, pastix_data->inter_node_comm );
240 
241  /* Initialize low-rank parameters */
242  lr = &(pastix_data->solvmatr->lowrank);
243  lr->compress_when = pastix_data->iparm[IPARM_COMPRESS_WHEN];
244  lr->compress_method = pastix_data->iparm[IPARM_COMPRESS_METHOD];
248  lr->use_reltol = pastix_data->iparm[IPARM_COMPRESS_RELTOL];
249  lr->tolerance = pastix_data->dparm[DPARM_COMPRESS_TOLERANCE];
250  lr->ilu_lvl = pastix_data->iparm[IPARM_COMPRESS_ILUK];
251 
254 
255  bcsc = pastix_data->bcsc;
256 
257  /* Make sure that mixed-precision isn't called in single precision */
258  {
259  int isDouble = (bcsc->flttype == PastixComplex64) || (bcsc->flttype == PastixDouble);
260  if ( pastix_data->iparm[IPARM_MIXED] && !isDouble )
261  {
262  pastix_print_warning( "pastix_subtask_bcsc2ctab: Mixed precision solve is not possible with single precision matrix\n"
263  " Mixed precision is disabled\n" );
264  pastix_data->iparm[IPARM_MIXED] = 0;
265  }
266  }
267 
268  /* Make sure IPARM_MIXED is 0 or 1 */
269  pastix_data->iparm[IPARM_MIXED] = pastix_data->iparm[IPARM_MIXED] ? 1 : 0;
270 
271  /* Initialize the float type of the solver matrix */
272  pastix_data->solvmatr->flttype = bcsc->flttype - pastix_data->iparm[IPARM_MIXED];
273 
274  /* Associate the compression methods corresponding to the precision of the solver matrix */
275  lr->core_ge2lr = ge2lrMethods[ pastix_data->iparm[IPARM_COMPRESS_METHOD] ][ (pastix_data->solvmatr->flttype-2) ];
276  lr->core_rradd = rraddMethods[ pastix_data->iparm[IPARM_COMPRESS_METHOD] ][ (pastix_data->solvmatr->flttype-2) ];
277 
278  /*
279  * Update the ilu level based on when
280  */
281  if ( lr->ilu_lvl == -2 ) {
282  if ( pastix_data->iparm[IPARM_COMPRESS_WHEN] == PastixCompressWhenBegin ) {
283  lr->ilu_lvl = -1;
284  }
285  else if ( pastix_data->iparm[IPARM_COMPRESS_WHEN] == PastixCompressWhenEnd ) {
286  lr->ilu_lvl = INT_MAX;
287  }
288  else if ( pastix_data->iparm[IPARM_COMPRESS_WHEN] == PastixCompressWhenDuring ) {
289  lr->ilu_lvl = 0;
290  }
291  }
292 
293  /*
294  * Set the maximum rank function
295  */
296  if ( pastix_data->iparm[IPARM_COMPRESS_WHEN] == PastixCompressWhenBegin ) {
298  }
299  else {
301  }
302 
303  pastix_data->solvmatr->factotype = pastix_data->iparm[IPARM_FACTORIZATION];
304 
305 #if defined(PASTIX_WITH_MPI)
306  if ( ( pastix_data->iparm[IPARM_COMPRESS_WHEN] != PastixCompressNever ) &&
307  ( pastix_data->iparm[IPARM_SCHEDULER] == PastixSchedParsec ) &&
308  ( pastix_data->procnbr > 1 ) )
309  {
310  pastix_print_error( "pastix_task_sopalin: Low-Rank with MPI communication is not available yet with PaRSEC\n" );
312  }
313 #endif
314  /*
315  * Fill in the internal coeftab structure. We consider that if this step is
316  * called the bcsc values have changed, or a factorization have already been
317  * performed, so we need to update the coeftab arrays.
318  */
319  if (pastix_data->bcsc != NULL)
320  {
321  coeftabExit( pastix_data->solvmatr );
322  }
323 
324  coeftabInit( pastix_data,
326 
327  switch( pastix_data->iparm[IPARM_FACTORIZATION] ) {
328  case PastixFactLLH:
329  case PastixFactLDLH:
330  mtxtype = PastixHermitian;
331  break;
332 
333  case PastixFactLLT:
334  case PastixFactLDLT:
335  mtxtype = PastixSymmetric;
336  break;
337 
338  case PastixFactLU:
339  default:
340  mtxtype = PastixGeneral;
341  }
342 
343 #if defined(PASTIX_WITH_PARSEC)
344  if ( pastix_data->iparm[IPARM_SCHEDULER] == PastixSchedParsec )
345  {
346  /* Start PaRSEC if not already started */
347  if (pastix_data->parsec == NULL) {
348  int argc = 0;
349  pastix_parsec_init( pastix_data, &argc, NULL, NULL );
350  }
351  /* Create the matrix descriptor */
352  parsec_sparse_matrix_init( pastix_data->solvmatr,
353  pastix_size_of( bcsc->flttype ), mtxtype,
354  pastix_data->inter_node_procnbr,
355  pastix_data->inter_node_procnum );
356  }
357 #endif
358 
359 #if defined(PASTIX_WITH_STARPU)
360  if ( pastix_data->iparm[IPARM_SCHEDULER] == PastixSchedStarPU )
361  {
362  /* Create the matrix descriptor */
363  starpu_sparse_matrix_init( pastix_data->solvmatr,
364  mtxtype,
365  pastix_data->inter_node_procnbr,
366  pastix_data->inter_node_procnum,
367  pastix_data->bcsc->flttype );
368  }
369 #endif
370 
371  clockSyncStop( timer, pastix_data->inter_node_comm );
372  if ( pastix_data->iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
373  pastix_print( pastix_data->inter_node_procnum, 0, OUT_COEFTAB_TIME,
374  clockVal(timer) );
375  }
376 
377  /* Invalidate following step, and add current step to the ones performed */
378  pastix_data->steps &= ~STEP_NUMFACT;
379  pastix_data->steps |= STEP_BCSC2CTAB;
380 
381  (void)mtxtype;
382  return PASTIX_SUCCESS;
383 }
384 
385 /**
386  *******************************************************************************
387  *
388  * @ingroup pastix_numfact
389  *
390  * @brief Factorize the given problem using Cholesky or LU decomposition.
391  *
392  * The user can call the pastix_task_solve() to obtain the solution.
393  *
394  * This routine is affected by the following parameters:
395  * IPARM_VERBOSE, IPARM_FACTORIZATION, IPARM_COMPRESS_WHEN.
396  *
397  *******************************************************************************
398  *
399  * @param[inout] pastix_data
400  * The pastix_data structure that describes the solver instance.
401  * On exit, the solver matrix structure stores the factorization of the
402  * given problem.
403  *
404  *******************************************************************************
405  *
406  * @retval PASTIX_SUCCESS on successful exit,
407  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect,
408  * @retval PASTIX_ERR_OUTOFMEMORY if one allocation failed.
409  *
410  *******************************************************************************/
411 int
413 {
414  sopalin_data_t sopalin_data;
415  SolverBackup_t *sbackup;
416  pastix_bcsc_t *bcsc;
417  PASTIX_Comm pastix_comm;
418  pastix_int_t *iparm;
419  double *dparm;
420 
421  /*
422  * Check parameters
423  */
424  if (pastix_data == NULL) {
425  pastix_print_error( "pastix_subtask_sopalin: wrong pastix_data parameter" );
427  }
428  if ( !(pastix_data->steps & STEP_ANALYSE) ) {
429  pastix_print_error( "pastix_subtask_sopalin: All steps from pastix_task_init() to pastix_task_analyze() have to be called before calling this function" );
431  }
432  if ( !(pastix_data->steps & STEP_CSC2BCSC) ) {
433  pastix_print_error( "pastix_subtask_sopalin: All steps from pastix_task_init() to pastix_task_analyze() have to be called before calling this function" );
435  }
436  if ( !(pastix_data->steps & STEP_BCSC2CTAB) ) {
437  pastix_print_error( "pastix_subtask_sopalin: All steps from pastix_task_init() to pastix_task_analyze() have to be called before calling this function" );
439  }
440 
441  bcsc = pastix_data->bcsc;
442  if (bcsc == NULL) {
443  pastix_print_error( "pastix_subtask_sopalin: wrong pastix_data_bcsc parameter" );
445  }
446 
447  /* Ensure that the scheduler is correct */
448  pastix_check_and_correct_scheduler( pastix_data );
449 
450  pastix_comm = pastix_data->inter_node_comm;
451  iparm = pastix_data->iparm;
452  dparm = pastix_data->dparm;
453 
454  /* Prepare the sopalin_data structure */
455  {
456  double threshold;
457 
458  sopalin_data.solvmtx = pastix_data->solvmatr;
459 
460  /* TODO: might change the behavior: if the user wants a ratio of the norm, it could compute it himself */
461  if ( dparm[ DPARM_EPSILON_MAGN_CTRL ] < 0. ) {
462  threshold = - dparm[ DPARM_EPSILON_MAGN_CTRL ];
463  }
464  else if ( dparm[ DPARM_EPSILON_MAGN_CTRL ] == 0. ) {
465  /*
466  * Use the rule presented in "Making Sparse Gaussian Elimination
467  * Scalable by Static Pivoting", S. X. Li, J. Demmel
468  *
469  * sqrt(eps) * ||A||_1 is a small half precision perturbation
470  * introduced in the pb when the pivot is too small
471  */
472  double eps;
473  if ( (bcsc->flttype == PastixFloat) || (bcsc->flttype == PastixComplex32) ) {
474  eps = LAPACKE_slamch_work( 'e' );
475  }
476  else {
477  eps = LAPACKE_dlamch_work( 'e' );
478  }
479  threshold = eps * dparm[DPARM_A_NORM];
480  }
481  else {
482  threshold = dparm[ DPARM_EPSILON_MAGN_CTRL ] * dparm[DPARM_A_NORM];
483  }
484 
485  sopalin_data.solvmtx->diagthreshold = threshold;
486  sopalin_data.solvmtx->nbpivots = 0;
487 
488  sopalin_data.cpu_coefs = &(pastix_data->cpu_models->coefficients[bcsc->flttype-2]);
489  sopalin_data.gpu_coefs = &(pastix_data->gpu_models->coefficients[bcsc->flttype-2]);
490  sopalin_data.cpu_models = pastix_data->cpu_models;
491  sopalin_data.gpu_models = pastix_data->gpu_models;
492  }
493 
494  sbackup = solverBackupInit( pastix_data->solvmatr );
495  pastix_data->solvmatr->restore = 2;
496  {
497  void (*factofct)( pastix_data_t *, sopalin_data_t *);
498  double timer, timer_local, flops, flops_g, energy = 0.;
499 
500  factofct = sopalinFacto[ pastix_data->iparm[IPARM_FACTORIZATION] ][pastix_data->solvmatr->flttype-2];
501  assert(factofct);
502 
503  papiEnergyStart();
504  if ( pastix_data->iparm[IPARM_TRACE] & PastixTraceNumfact ) {
506  }
507  clockSyncStart( timer, pastix_comm );
508  clockStart(timer_local);
509 
510  factofct( pastix_data, &sopalin_data );
511 
512  clockStop(timer_local);
513  clockSyncStop( timer, pastix_comm );
514  if ( pastix_data->iparm[IPARM_TRACE] & PastixTraceNumfact ) {
516  }
517  energy = papiEnergyStop();
518 
519  /* Output time, flops, energy and power */
520  pastix_data->dparm[DPARM_FACT_TIME] = clockVal(timer);
521  flops = pastix_data->dparm[DPARM_FACT_THFLOPS] / pastix_data->dparm[DPARM_FACT_TIME];
522  pastix_data->dparm[DPARM_FACT_FLOPS] = ((flops / 1024.) / 1024.) / 1024.;
523  pastix_data->dparm[DPARM_FACT_ENERGY] = energy;
524 
525  /* Compute the number of flops performed (may be different from THFLOPS for low-rank) */
526  {
527  double flops_l = pastix_data->dparm[DPARM_FACT_RLFLOPS];
528  MPI_Allreduce( &flops_l, &flops_g, 1, MPI_DOUBLE, MPI_SUM, pastix_data->inter_node_comm );
529  }
530 
531  /* Reduce the number of pivots */
532  {
533  int nbpivot_l = sopalin_data.solvmtx->nbpivots;
534  int nbpivot_g;
535  MPI_Allreduce( &nbpivot_l, &nbpivot_g, 1, MPI_INT, MPI_SUM, pastix_data->inter_node_comm );
536  pastix_data->iparm[IPARM_STATIC_PIVOTING] = nbpivot_g;
537  }
538 
539  if ( iparm[IPARM_VERBOSE] > PastixVerboseNot ) {
540  pastix_print( pastix_data->inter_node_procnum, 0, OUT_SOPALIN_TIME,
541  clockVal(timer),
542  pastix_print_value( flops ),
543  pastix_print_unit( flops ),
544  pastix_print_value( flops_g ),
545  pastix_print_unit( flops_g ),
546  (long)pastix_data->iparm[IPARM_STATIC_PIVOTING] );
547 #if defined(PASTIX_WITH_PAPI)
548  {
549  double power = energy / pastix_data->dparm[DPARM_FACT_TIME];
550  pastix_print( pastix_data->inter_node_procnum, 0, OUT_SOPALIN_ENERGY,
551  pastix_print_value_deci( energy ),
552  pastix_print_unit_deci( energy ),
553  pastix_print_value_deci( power ),
554  pastix_print_unit_deci( power ) );
555  }
556 #endif
557  }
558 
559 #if defined(PASTIX_WITH_PARSEC) && defined(PASTIX_DEBUG_PARSEC)
560  {
561  int i;
562  fprintf(stderr, "-- Check status of PaRSEC nbtasks counters\n" );
563  for (i=0; i<32; i++) {
564  if ( parsec_nbtasks_on_gpu[i] != 0 ) {
565  fprintf(stderr, "Device %d => %d\n",
566  i, parsec_nbtasks_on_gpu[i] );
567  }
568  parsec_nbtasks_on_gpu[i] = 0;
569  }
570  }
571 #endif /* defined(PASTIX_WITH_PARSEC) && defined(PASTIX_DEBUG_PARSEC) */
572  }
573  solverBackupRestore( pastix_data->solvmatr, sbackup );
574  solverBackupExit( sbackup );
575 
576 #if defined(PASTIX_NUMFACT_DUMP_SOLVER)
577  {
578  FILE *stream = NULL;
579 
580  pastix_gendirectories( pastix_data );
581  stream = pastix_fopenw( pastix_data->dir_local, "solver.eps", "w" );
582  if ( stream ) {
583  solverDraw( pastix_data->solvmatr,
584  stream, iparm[IPARM_VERBOSE],
585  pastix_data->dir_local );
586  fclose(stream);
587  }
588  }
589 #endif
590 
591  /* Compute the memory usage */
592  {
593  coeftabMemory[pastix_data->solvmatr->flttype-2]( pastix_data->solvmatr, pastix_data->iparm, pastix_data->dparm );
594 #if defined(PASTIX_WITH_MPI)
595  MPI_Allreduce( MPI_IN_PLACE, pastix_data->dparm + DPARM_MEM_FR, 1, MPI_DOUBLE, MPI_SUM, pastix_data->inter_node_comm );
596  MPI_Allreduce( MPI_IN_PLACE, pastix_data->dparm + DPARM_MEM_LR, 1, MPI_DOUBLE, MPI_SUM, pastix_data->inter_node_comm );
597 #endif
598  }
599 
600  /* Invalidate following steps, and add factorization step to the ones performed */
601  pastix_data->steps &= ~( STEP_BCSC2CTAB |
602  STEP_SOLVE |
603  STEP_REFINE );
604  pastix_data->steps |= STEP_NUMFACT;
605 
606  (void)pastix_comm;
607  return EXIT_SUCCESS;
608 }
609 
610 /**
611  *******************************************************************************
612  *
613  * @ingroup pastix_users
614  *
615  * @brief Perform all the numerical factorization steps:
616  * fill the internal block CSC and the solver matrix structures,
617  * then apply the factorization step.
618  *
619  * The user can call the pastix_task_solve() to obtain the solution.
620  *
621  * This routine is affected by the following parameters:
622  * IPARM_VERBOSE.
623  *
624  *******************************************************************************
625  *
626  * @param[inout] pastix_data
627  * The pastix_data structure that describes the solver instance.
628  * On exit, the internal block CSC is filled with entries from the
629  * spm matrix and the solver matrix structure stores the factorization
630  * of the given problem.
631  *
632  * @param[inout] spm
633  * The sparse matrix descriptor that describes problem instance.
634  * On exit, the spm structure is freed if IPARM_FREE_CSCUSER is true.
635  *
636  *******************************************************************************
637  *
638  * @retval PASTIX_SUCCESS on successful exit,
639  * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect,
640  * @retval PASTIX_ERR_OUTOFMEMORY if one allocation failed.
641  *
642  *******************************************************************************/
643 int
645  spmatrix_t *spm )
646 {
647  pastix_int_t *iparm;
648  pastix_int_t procnum;
649  pastix_int_t steps;
650  int rc;
651 
652  /*
653  * Check parameters
654  */
655  if (pastix_data == NULL) {
656  pastix_print_error( "pastix_task_sopalin: wrong pastix_data parameter" );
658  }
659  if (spm == NULL) {
660  pastix_print_error( "pastix_task_sopalin: wrong spm parameter" );
662  }
663  if ( !(pastix_data->steps & STEP_ANALYSE) ) {
664  pastix_print_error( "pastix_task_sopalin: All steps from pastix_task_init() to pastix_task_blend() have to be called before calling this function" );
666  }
667 
668  iparm = pastix_data->iparm;
669  procnum = pastix_data->inter_node_procnum;
670 
671  if (iparm[IPARM_VERBOSE] > PastixVerboseNot) {
672  pastix_print( procnum, 0, OUT_STEP_SOPALIN,
673  pastixFactotypeStr( iparm[IPARM_FACTORIZATION] ) );
674  }
675 
676  /* Invalidate upcoming steps */
677  steps = ~(STEP_CSC2BCSC |
678  STEP_BCSC2CTAB |
679  STEP_NUMFACT |
680  STEP_SOLVE |
681  STEP_REFINE );
682  pastix_data->steps &= steps;
683 
684  rc = pastix_subtask_spm2bcsc( pastix_data, spm );
685  if (rc != PASTIX_SUCCESS) {
686  return rc;
687  }
688 
689  rc = pastix_subtask_bcsc2ctab( pastix_data );
690  if (rc != PASTIX_SUCCESS) {
691  return rc;
692  }
693 
694  rc = pastix_subtask_sopalin( pastix_data );
695  if (rc != PASTIX_SUCCESS) {
696  return rc;
697  }
698 
699  return EXIT_SUCCESS;
700 }
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
double bcscInit(const spmatrix_t *spm, const pastix_order_t *ord, const SolverMatrix *solvmtx, pastix_int_t initAt, pastix_bcsc_t *bcsc)
Initializes the block csc matrix.
Definition: bcsc.c:1887
void bcscExit(pastix_bcsc_t *bcsc)
Frees the block csc structure but do not free the bcsc pointer.
Definition: bcsc.c:1917
int solverBackupRestore(SolverMatrix *solvmtx, const SolverBackup_t *b)
Restore initial values.
void solverBackupExit(SolverBackup_t *b)
Free the solver backup data structure.
int solverDraw(const SolverMatrix *solvptr, FILE *stream, int verbose, const char *directory)
Writes a PostScript picture of the low-rank solver matrix.
Definition: solver_draw.c:56
SolverBackup_t * solverBackupInit(const SolverMatrix *solvmtx)
Initialize the backup structure.
Definition: solver_backup.c:59
void coeftabInit(pastix_data_t *pastix_data, pastix_coefside_t side)
Initialize the solver matrix structure.
Definition: coeftab.c:204
void coeftabExit(SolverMatrix *solvmtx)
Free the solver matrix structure.
Definition: coeftab.c:267
coeftab_fct_memory_t coeftabMemory[4]
List of functions to compute the memory gain in low-rank per precision.
Definition: coeftab.c:45
void kernelsTraceStop()
Pauses the trace module.
void kernelsTraceStart()
Resumes the trace module.
Definition: kernels_trace.c:90
int compress_preselect
pastix_compress_method_t compress_method
double tolerance
pastix_int_t compress_min_width
fct_rradd_t core_rradd
fct_ge2lr_t core_ge2lr
pastix_int_t compress_min_height
pastix_compress_when_t compress_when
static pastix_int_t core_get_rklimit_end(pastix_int_t M, pastix_int_t N)
Compute the maximal rank accepted for a given matrix size for Just-In-Time strategy.
const fct_rradd_t rraddMethods[PastixCompressMethodNbr][4]
Array of pointers to the multiple arithmetic and algorithmic variants of rradd.
Definition: lowrank.c:52
const fct_ge2lr_t ge2lrMethods[PastixCompressMethodNbr][4]
Array of pointers to the multiple arithmetic and algorithmic variants of ge2lr.
Definition: lowrank.c:43
double pastix_lr_minratio
Define the minimal ratio for which we accept to compress a matrix into a low-rank form or not.
Definition: lowrank.c:24
pastix_int_t pastix_lr_ortho
Define the orthogonalization method.
Definition: lowrank.c:25
pastix_int_t(* core_get_rklimit)(pastix_int_t, pastix_int_t)
Compute the maximal rank accepted for a given matrix size. The pointer is set according to the low-ra...
Definition: kernels_trace.c:46
static pastix_int_t core_get_rklimit_begin(pastix_int_t M, pastix_int_t N)
Compute the maximal rank accepted for a given matrix size for Minimal-Memory strategy.
Structure to define the type of function to use for the low-rank kernels and their parameters.
#define PastixSymmetric
Definition: api.h:459
#define PastixGeneral
Definition: api.h:458
spm_mtxtype_t pastix_mtxtype_t
Matrix symmetry type property.
Definition: api.h:457
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
#define PastixHermitian
Definition: api.h:460
void pastix_gendirectories(pastix_data_t *pastix_data)
Generate a unique temporary directory to store output files.
Definition: api.c:76
@ PastixFactLDLH
Definition: api.h:319
@ PastixFactLDLT
Definition: api.h:316
@ PastixFactLLH
Definition: api.h:315
@ PastixFactLU
Definition: api.h:317
@ PastixFactLLT
Definition: api.h:318
@ DPARM_FACT_THFLOPS
Definition: api.h:172
@ DPARM_EPSILON_MAGN_CTRL
Definition: api.h:163
@ DPARM_A_NORM
Definition: api.h:183
@ DPARM_MEM_FR
Definition: api.h:175
@ DPARM_FACT_TIME
Definition: api.h:170
@ DPARM_FACT_RLFLOPS
Definition: api.h:173
@ DPARM_MEM_LR
Definition: api.h:176
@ DPARM_COMPRESS_TOLERANCE
Definition: api.h:184
@ DPARM_FACT_FLOPS
Definition: api.h:171
@ DPARM_FACT_ENERGY
Definition: api.h:174
@ DPARM_COMPRESS_MIN_RATIO
Definition: api.h:185
@ PastixLCoef
Definition: api.h:478
@ PastixLUCoef
Definition: api.h:480
@ PastixCompressWhenBegin
Definition: api.h:386
@ PastixCompressWhenEnd
Definition: api.h:387
@ PastixCompressNever
Definition: api.h:385
@ PastixCompressWhenDuring
Definition: api.h:388
@ IPARM_FACTORIZATION
Definition: api.h:99
@ IPARM_COMPRESS_WHEN
Definition: api.h:131
@ IPARM_COMPRESS_MIN_WIDTH
Definition: api.h:129
@ IPARM_MIXED
Definition: api.h:139
@ IPARM_FREE_CSCUSER
Definition: api.h:102
@ IPARM_STATIC_PIVOTING
Definition: api.h:101
@ IPARM_COMPRESS_MIN_HEIGHT
Definition: api.h:130
@ IPARM_COMPRESS_ILUK
Definition: api.h:136
@ IPARM_SCHEDULER
Definition: api.h:117
@ IPARM_COMPRESS_METHOD
Definition: api.h:132
@ IPARM_VERBOSE
Definition: api.h:36
@ IPARM_COMPRESS_ORTHO
Definition: api.h:133
@ IPARM_COMPRESS_RELTOL
Definition: api.h:134
@ IPARM_TRACE
Definition: api.h:44
@ IPARM_COMPRESS_PRESELECT
Definition: api.h:135
@ PastixVerboseNot
Definition: api.h:220
@ PastixVerboseNo
Definition: api.h:221
@ PastixSchedDynamic
Definition: api.h:338
@ PastixSchedStarPU
Definition: api.h:337
@ PastixSchedParsec
Definition: api.h:336
@ PASTIX_SUCCESS
Definition: api.h:367
@ PASTIX_ERR_BADPARAMETER
Definition: api.h:374
@ PastixTraceNumfact
Definition: api.h:211
int pastix_subtask_sopalin(pastix_data_t *pastix_data)
Factorize the given problem using Cholesky or LU decomposition.
int pastix_subtask_spm2bcsc(pastix_data_t *pastix_data, spmatrix_t *spm)
Fill the internal block CSC structure.
int pastix_subtask_bcsc2ctab(pastix_data_t *pastix_data)
Fill the internal solver matrix structure.
void parsec_sparse_matrix_init(SolverMatrix *solvmtx, int typesize, pastix_mtxtype_t mtxtype, int nodes, int myrank)
Generate the PaRSEC descriptor of the sparse matrix.
void pastix_parsec_init(pastix_data_t *pastix, int *argc, char **argv[], const int *bindtab)
Startup the PaRSEC runtime system.
Definition: parsec.c:61
void starpu_sparse_matrix_init(SolverMatrix *solvmtx, pastix_mtxtype_t mtxtype, int nodes, int myrank, pastix_coeftype_t flttype)
Generate the StarPU descriptor of the sparse matrix.
int inter_node_procnum
Definition: pastixdata.h:83
pastix_model_t * cpu_models
Definition: pastixdata.h:106
pastix_model_t * gpu_models
Definition: pastixdata.h:107
SolverMatrix * solvmatr
Definition: pastixdata.h:102
int inter_node_procnbr
Definition: pastixdata.h:82
pastix_scheduler_t sched
Definition: pastixdata.h:73
SolverMatrix * solvglob
Definition: pastixdata.h:104
void * parsec
Definition: pastixdata.h:86
SolverMatrix * solvloc
Definition: pastixdata.h:103
pastix_order_t * ordemesh
Definition: pastixdata.h:97
pastix_int_t * iparm
Definition: pastixdata.h:69
char * dir_local
Definition: pastixdata.h:110
double * dparm
Definition: pastixdata.h:70
PASTIX_Comm inter_node_comm
Definition: pastixdata.h:77
pastix_bcsc_t * bcsc
Definition: pastixdata.h:101
pastix_int_t steps
Definition: pastixdata.h:72
int pastix_task_numfact(pastix_data_t *pastix_data, spmatrix_t *spm)
Perform all the numerical factorization steps: fill the internal block CSC and the solver matrix stru...
Main PaStiX data structure.
Definition: pastixdata.h:67
void sopalin_cgetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_chetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_cpotrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_cpxtrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_csytrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_dgetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_dpotrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_dsytrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_sgetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_spotrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_ssytrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_zgetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_zhetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_zpotrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_zpxtrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
void sopalin_zsytrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
TODO.
pastix_coeftype_t flttype
Definition: solver.h:225
pastix_lr_t lowrank
Definition: solver.h:230
pastix_factotype_t factotype
Definition: solver.h:231