PaStiX Handbook  6.4.0
parsec_dpotrf.c
Go to the documentation of this file.
1 /**
2  *
3  * @file parsec_dpotrf.c
4  *
5  * PaStiX dpotrf PaRSEC wrapper.
6  *
7  * @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.4.0
11  * @author Mathieu Faverge
12  * @author Esragul Korkmaz
13  * @author Pierre Ramet
14  * @date 2024-07-05
15  * @generated from /builds/solverstack/pastix/sopalin/parsec/parsec_zpotrf.c, normal z -> d, Tue Oct 8 14:17:33 2024
16  *
17  * @addtogroup parsec_potrf
18  * @{
19  *
20  **/
21 #include <parsec.h>
22 #include <parsec/data_distribution.h>
23 #include <parsec/private_mempool.h>
24 #include <parsec/arena.h>
25 #include <parsec/data_dist/matrix/matrix.h>
26 #include "common.h"
27 #include "blend/solver.h"
28 #include "sopalin/sopalin_data.h"
29 #include "dpotrf_sp1dplus.h"
30 #include "dpotrf_sp2d.h"
31 #include "pastix_parsec.h"
32 
33 /**
34  *******************************************************************************
35  *
36  * @brief Generate the PaRSEC taskpool object for the Cholesky factorization with
37  * 1D kernels.
38  *
39  * The function only return the object that describes the Cholesky factorization
40  * of a sparse symmetric positive definite (or Symmetric positive definite in
41  * the real case) matrix A.
42  * The factorization has the form
43  *
44  * \f[ A = L\times L^T \f]
45  *
46  * where L is a sparse lower triangular matrix.
47  *
48  * In this object, all operations are panel based operation which might result in
49  * lower parallelism for large problems.
50  *
51  * @warning The computations are not done by this call.
52  *
53  *******************************************************************************
54  *
55  * @param[inout] A
56  * Descriptor of the sparse matrix A.
57  * On exit, A is overwritten with the factorized matrix.
58  *
59  * @param[inout] sopalin_data
60  * Solver matrix information structure that will guide the algorithm.
61  *
62  *******************************************************************************
63  *
64  * @retval NULL if incorrect parameters are given.
65  * @retval The parsec taskpool describing the operation that can be
66  * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
67  * destroy with parsec_dpotrf_sp1dplus_Destruct().
68  *
69  *******************************************************************************
70  *
71  * @sa parsec_dpotrf_sp1dplus
72  * @sa parsec_dpotrf_sp1dplus_Destruct
73  * @sa parsec_dpotrf_sp1dplus
74  * @sa parsec_cpotrf_sp1dplus_New
75  * @sa parsec_dpotrf_sp1dplus_New
76  * @sa parsec_spotrf_sp1dplus_New
77  *
78  ******************************************************************************/
79 parsec_taskpool_t*
81  sopalin_data_t *sopalin_data )
82 {
83  parsec_dpotrf_sp1dplus_taskpool_t *parsec_dpotrf_sp1dplus = NULL;
84  pastix_int_t lwork;
85 
86  lwork = sopalin_data->solvmtx->gemmmax;
87  if ( (sopalin_data->solvmtx->lowrank.compress_when != PastixCompressNever) &&
88  (sopalin_data->solvmtx->lowrank.ilu_lvl < INT_MAX) )
89  {
90  lwork = pastix_imax( lwork, 2 * sopalin_data->solvmtx->blokmax );
91  }
92 
93  parsec_dpotrf_sp1dplus = parsec_dpotrf_sp1dplus_new( A, sopalin_data, NULL, lwork );
94 
95  parsec_dpotrf_sp1dplus->_g_p_work = (parsec_memory_pool_t*)malloc(sizeof(parsec_memory_pool_t));
96  parsec_private_memory_init( parsec_dpotrf_sp1dplus->_g_p_work,
97  lwork * sizeof(double) );
98 
99  parsec_arena_construct( parsec_dpotrf_sp1dplus->arenas[PARSEC_dpotrf_sp1dplus_DEFAULT_ARENA],
100  sizeof(double), PARSEC_ARENA_ALIGNMENT_SSE,
101  parsec_datatype_double_t );
102 
103 #if defined(PASTIX_GENERATE_MODEL)
104  parsec_dpotrf_sp1dplus->_g_forced_pushout = 1;
105 #endif
106  return (parsec_taskpool_t*)parsec_dpotrf_sp1dplus;
107 }
108 
109 /**
110  *******************************************************************************
111  *
112  * @brief Free the data structure associated to a taskpool created with
113  * parsec_dpotrf_sp1dplus_New().
114  *
115  *******************************************************************************
116  *
117  * @param[inout] taskpool
118  * On entry, the taskpool to destroy.
119  * On exit, the taskpool cannot be used anymore.
120  *
121  ******************************************************************************/
122 void
123 parsec_dpotrf_sp1dplus_Destruct( parsec_taskpool_t *taskpool )
124 {
125  parsec_dpotrf_sp1dplus_taskpool_t *parsec_dpotrf_sp1dplus = NULL;
126  parsec_dpotrf_sp1dplus = (parsec_dpotrf_sp1dplus_taskpool_t *)taskpool;
127 
128  parsec_private_memory_fini( parsec_dpotrf_sp1dplus->_g_p_work );
129  free( parsec_dpotrf_sp1dplus->_g_p_work );
130 
131  parsec_taskpool_free( taskpool );
132 }
133 
134 /**
135  *******************************************************************************
136  *
137  * @brief Perform a sparse Cholesky factorization with 1D kernels.
138  *
139  * The function performs the Cholesky factorization of a sparse symmetric
140  * positive definite (or Symmetric positive definite in the real case) matrix
141  * A.
142  * The factorization has the form
143  *
144  * \f[ A = L\times L^T \f]
145  *
146  * where L is a sparse lower triangular matrix.
147  *
148  *******************************************************************************
149  *
150  * @param[inout] parsec
151  * The parsec context of the application that will run the operation.
152  *
153  * @param[inout] A
154  * Descriptor of the sparse matrix A.
155  * On exit, A is overwritten with the factorized matrix.
156  *
157  * @param[inout] sopalin_data
158  * Solver matrix information structure that will guide the algorithm.
159  *
160  *******************************************************************************
161  *
162  * @retval NULL if incorrect parameters are given.
163  * @retval The parsec taskpool describing the operation that can be
164  * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
165  * destroy with parsec_dpotrf_sp1dplus_Destruct().
166  *
167  *******************************************************************************
168  *
169  * @sa parsec_dpotrf_sp1dplus_New
170  * @sa parsec_dpotrf_sp1dplus_Destruct
171  *
172  ******************************************************************************/
173 int
174 parsec_dpotrf_sp1dplus( parsec_context_t *parsec,
176  sopalin_data_t *sopalin_data )
177 {
178  parsec_taskpool_t *parsec_dpotrf_sp1dplus = NULL;
179  int info = 0;
180 
182 
183  if ( parsec_dpotrf_sp1dplus == NULL ) {
184  return -1;
185  }
186 
187  parsec_context_add_taskpool( parsec, (parsec_taskpool_t*)parsec_dpotrf_sp1dplus );
188  parsec_context_start( parsec );
189  parsec_context_wait( parsec );
191 
192  return info;
193 }
194 
195 /**
196  *******************************************************************************
197  *
198  * @brief Generate the PaRSEC taskpoolr object for the Cholesky factorization with
199  * 1D and 2D kernels.
200  *
201  * The function only return the object that describes the Cholesky factorization
202  * of a sparse symmetric positive definite (or Symmetric positive definite in
203  * the real case) matrix A.
204  * The factorization has the form
205  *
206  * \f[ A = L\times L^T \f]
207  *
208  * where L is a sparse lower triangular matrix.
209  *
210  * In this object, operations are panel based operations for the lower levels of
211  * the elimination tree, and the higher levels are taskpoold by 2D tasks scheme to
212  * create more parallelism and adapt to large architectures.
213  *
214  * @warning The computations are not done by this call.
215  *
216  *******************************************************************************
217  *
218  * @param[inout] A
219  * Descriptor of the sparse matrix A.
220  * On exit, A is overwritten with the factorized matrix.
221  *
222  * @param[inout] sopalin_data
223  * Solver matrix information structure that will guide the algorithm.
224  *
225  *******************************************************************************
226  *
227  * @retval NULL if incorrect parameters are given.
228  * @retval The parsec taskpool describing the operation that can be
229  * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
230  * destroy with parsec_dpotrf_sp2d_Destruct().
231  *
232  *******************************************************************************
233  *
234  * @sa parsec_dpotrf_sp2d
235  * @sa parsec_dpotrf_sp2d_Destruct
236  * @sa parsec_dgetrf_sp2d
237  * @sa parsec_cpotrf_sp2d_New
238  * @sa parsec_dpotrf_sp2d_New
239  * @sa parsec_spotrf_sp2d_New
240  *
241  ******************************************************************************/
242 parsec_taskpool_t*
244  sopalin_data_t *sopalin_data )
245 {
246  parsec_dpotrf_sp2d_taskpool_t *parsec_dpotrf_sp2d = NULL;
247  pastix_int_t lwork;
248 
249  lwork = sopalin_data->solvmtx->gemmmax;
250  if ( (sopalin_data->solvmtx->lowrank.compress_when != PastixCompressNever) &&
251  (sopalin_data->solvmtx->lowrank.ilu_lvl < INT_MAX) )
252  {
253  lwork = pastix_imax( lwork, 2 * sopalin_data->solvmtx->blokmax );
254  }
255 
256  parsec_dpotrf_sp2d = parsec_dpotrf_sp2d_new( A, sopalin_data, NULL, lwork );
257 
258  parsec_dpotrf_sp2d->_g_p_work = (parsec_memory_pool_t*)malloc(sizeof(parsec_memory_pool_t));
259  parsec_private_memory_init( parsec_dpotrf_sp2d->_g_p_work,
260  lwork * sizeof(double) );
261 
262  parsec_arena_construct( parsec_dpotrf_sp2d->arenas[PARSEC_dpotrf_sp2d_DEFAULT_ARENA],
263  sizeof(double), PARSEC_ARENA_ALIGNMENT_SSE,
264  parsec_datatype_double_t );
265 
266 #if defined(PASTIX_GENERATE_MODEL)
267  parsec_dpotrf_sp2d->_g_forced_pushout = 1;
268 #endif
269  return (parsec_taskpool_t*)parsec_dpotrf_sp2d;
270 }
271 
272 /**
273  *******************************************************************************
274  *
275  * @brief Free the data structure associated to a taskpool created with
276  * parsec_dpotrf_sp2d_New().
277  *
278  *******************************************************************************
279  *
280  * @param[inout] taskpool
281  * On entry, the taskpool to destroy.
282  * On exit, the taskpool cannot be used anymore.
283  *
284  ******************************************************************************/
285 void
286 parsec_dpotrf_sp2d_Destruct( parsec_taskpool_t *taskpool )
287 {
288  parsec_dpotrf_sp2d_taskpool_t *parsec_dpotrf_sp2d = NULL;
289  parsec_dpotrf_sp2d = (parsec_dpotrf_sp2d_taskpool_t *)taskpool;
290 
291  parsec_private_memory_fini( parsec_dpotrf_sp2d->_g_p_work );
292  free( parsec_dpotrf_sp2d->_g_p_work );
293 
294  parsec_taskpool_free( taskpool );
295 }
296 
297 /**
298  *******************************************************************************
299  *
300  * @brief Perform a sparse Cholesky factorization with 1D and 2D kernels.
301  *
302  * The function performs the Cholesky factorization of a sparse symmetric
303  * positive definite (or Symmetric positive definite in the real case) matrix
304  * A.
305  * The factorization has the form
306  *
307  * \f[ A = L\times L^T \f]
308  *
309  * where L is a sparse lower triangular matrix.
310  *
311  *******************************************************************************
312  *
313  * @param[inout] parsec
314  * The parsec context of the application that will run the operation.
315  *
316  * @param[inout] A
317  * Descriptor of the sparse matrix A.
318  * On exit, A is overwritten with the factorized matrix.
319  *
320  * @param[inout] sopalin_data
321  * Solver matrix information structure that will guide the algorithm.
322  *
323  *******************************************************************************
324  *
325  * @retval NULL if incorrect parameters are given.
326  * @retval The parsec taskpool describing the operation that can be
327  * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
328  * destroy with parsec_dpotrf_sp2d_Destruct().
329  *
330  *******************************************************************************
331  *
332  * @sa parsec_dpotrf_sp2d_New
333  * @sa parsec_dpotrf_sp2d_Destruct
334  *
335  ******************************************************************************/
336 int
337 parsec_dpotrf_sp2d( parsec_context_t *parsec,
339  sopalin_data_t *sopalin_data )
340 {
341  parsec_taskpool_t *parsec_dpotrf_sp2d = NULL;
342  int info = 0;
343 
344  parsec_dpotrf_sp2d = parsec_dpotrf_sp2d_New( A, sopalin_data );
345 
346  if ( parsec_dpotrf_sp2d == NULL ) {
347  return -1;
348  }
349 
350  parsec_context_add_taskpool( parsec, (parsec_taskpool_t*)parsec_dpotrf_sp2d );
351  parsec_context_start( parsec );
352  parsec_context_wait( parsec );
354 
355  return info;
356 }
357 
358 /**
359  *******************************************************************************
360  *
361  * @brief Perform a sparse Cholesky factorization using PaRSEC runtime.
362  *
363  * The function performs the Cholesky factorization of a sparse symmetric
364  * positive definite (or Symmetric positive definite in the real case) matrix
365  * A.
366  * The factorization has the form
367  *
368  * \f[ A = L\times L^T \f]
369  *
370  * where L is a sparse lower triangular matrix.
371  *
372  * The algorithm is automatically chosen between the 1D and 2D version based on
373  * the API parameter IPARM_TASKS2D_LEVEL. If IPARM_TASKS2D_LEVEL != 0
374  * the 2D scheme is applied, the 1D otherwise.
375  *
376  *******************************************************************************
377  *
378  * @param[inout] pastix_data
379  * The pastix_data structure that describes the solver instance.
380  *
381  * @param[inout] sopalin_data
382  * Solver matrix information structure that will guide the algorithm.
383  *
384  *******************************************************************************
385  *
386  * @sa parsec_dpotrf_sp1dplus
387  * @sa parsec_dpotrf_sp2d
388  *
389  ******************************************************************************/
390 void
392  sopalin_data_t *sopalin_data )
393 {
394  parsec_sparse_matrix_desc_t *sdesc = sopalin_data->solvmtx->parsec_desc;
395  parsec_context_t *ctx;
396 
397  /*
398  * Start PaRSEC if not already started
399  */
400  if (pastix_data->parsec == NULL) {
401  int argc = 0;
402  pastix_parsec_init( pastix_data, &argc, NULL, NULL );
403  }
404  ctx = pastix_data->parsec;
405 
406  if ( sdesc == NULL ) {
407  /* Create the matrix descriptor */
408  parsec_sparse_matrix_init( sopalin_data->solvmtx,
409  sizeof( double ), PastixSymmetric,
410  pastix_data->inter_node_procnbr,
411  pastix_data->inter_node_procnum );
412  sdesc = sopalin_data->solvmtx->parsec_desc;
413  }
414 
415  /*
416  * Select 1D or 2D jdf based on 2d tasks level
417  */
418  if ( pastix_data->iparm[IPARM_TASKS2D_LEVEL] != 0 )
419  {
420  parsec_dpotrf_sp2d( ctx, sdesc,
421  sopalin_data );
422  }
423  else {
424  parsec_dpotrf_sp1dplus( ctx, sdesc,
425  sopalin_data );
426  }
427 
428  return;
429 }
430 
431 /**
432  *@}
433  */
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
void parsec_dpotrf_sp2d_Destruct(parsec_taskpool_t *taskpool)
Free the data structure associated to a taskpool created with parsec_dpotrf_sp2d_New().
int parsec_dpotrf_sp2d(parsec_context_t *parsec, parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Perform a sparse Cholesky factorization with 1D and 2D kernels.
void parsec_dpotrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
Perform a sparse Cholesky factorization using PaRSEC runtime.
int parsec_dpotrf_sp1dplus(parsec_context_t *parsec, parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Perform a sparse Cholesky factorization with 1D kernels.
parsec_taskpool_t * parsec_dpotrf_sp2d_New(parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Generate the PaRSEC taskpoolr object for the Cholesky factorization with 1D and 2D kernels.
parsec_taskpool_t * parsec_dpotrf_sp1dplus_New(parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Generate the PaRSEC taskpool object for the Cholesky factorization with 1D kernels.
Definition: parsec_dpotrf.c:80
void parsec_dpotrf_sp1dplus_Destruct(parsec_taskpool_t *taskpool)
Free the data structure associated to a taskpool created with parsec_dpotrf_sp1dplus_New().
#define PastixSymmetric
Definition: api.h:459
@ PastixCompressNever
Definition: api.h:385
@ IPARM_TASKS2D_LEVEL
Definition: api.h:90
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
PaRSEC descriptor stucture for the sparse matrix.
Definition: pastix_parsec.h:35
int inter_node_procnum
Definition: pastixdata.h:84
int inter_node_procnbr
Definition: pastixdata.h:83
void * parsec
Definition: pastixdata.h:87
pastix_int_t * iparm
Definition: pastixdata.h:70
Main PaStiX data structure.
Definition: pastixdata.h:68