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