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