PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
parsec_cgetrf.c
Go to the documentation of this file.
1/**
2 *
3 * @file parsec_cgetrf.c
4 *
5 * PaStiX cgetrf 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/2mk6rsew/0/solverstack/pastix/sopalin/parsec/parsec_zgetrf.c, normal z -> c, Tue Feb 25 14:35:19 2025
16 *
17 * @addtogroup parsec_getrf
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 "cgetrf_sp1dplus.h"
30#include "cgetrf_sp2d.h"
31#include "pastix_parsec.h"
32
33/**
34 *******************************************************************************
35 *
36 * @brief Generate the PaRSEC taskpool object for the LU factorization with
37 * 1D kernels.
38 *
39 * The function only return the object that describes the LU factorization of a
40 * sparse general matrix A.
41 * The factorization has the form
42 *
43 * \f[ A = L\times U \f]
44 *
45 * where L is a sparse lower triangular matrix, and U a sparse upper triangular
46 * with the same pattern as L^t.
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_cgetrf_sp1dplus_Destruct().
68 *
69 *******************************************************************************
70 *
71 * @sa parsec_cgetrf_sp1dplus
72 * @sa parsec_cgetrf_sp1dplus_Destruct
73 * @sa parsec_cgetrf_sp1dplus
74 * @sa parsec_cgetrf_sp1dplus_New
75 * @sa parsec_dgetrf_sp1dplus_New
76 * @sa parsec_sgetrf_sp1dplus_New
77 *
78 ******************************************************************************/
79parsec_taskpool_t*
81 sopalin_data_t *sopalin_data )
82{
83 parsec_cgetrf_sp1dplus_taskpool_t *parsec_cgetrf_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_cgetrf_sp1dplus = parsec_cgetrf_sp1dplus_new( A, sopalin_data, NULL, lwork );
94
95 parsec_cgetrf_sp1dplus->_g_p_work = (parsec_memory_pool_t*)malloc(sizeof(parsec_memory_pool_t));
96 parsec_private_memory_init( parsec_cgetrf_sp1dplus->_g_p_work,
97 lwork * sizeof(pastix_complex32_t) );
98
99 parsec_arena_construct( parsec_cgetrf_sp1dplus->arenas[PARSEC_cgetrf_sp1dplus_DEFAULT_ARENA],
100 sizeof(pastix_complex32_t), PARSEC_ARENA_ALIGNMENT_SSE,
101 parsec_datatype_complex_t );
102
103#if defined(PASTIX_GENERATE_MODEL)
104 parsec_cgetrf_sp1dplus->_g_forced_pushout = 1;
105#endif
106 return (parsec_taskpool_t*)parsec_cgetrf_sp1dplus;
107}
108
109/**
110 *******************************************************************************
111 *
112 * @brief Free the data structure associated to a taskpool created with
113 * parsec_cgetrf_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 ******************************************************************************/
122void
123parsec_cgetrf_sp1dplus_Destruct( parsec_taskpool_t *taskpool )
124{
125 parsec_cgetrf_sp1dplus_taskpool_t *parsec_cgetrf_sp1dplus = NULL;
126 parsec_cgetrf_sp1dplus = (parsec_cgetrf_sp1dplus_taskpool_t *)taskpool;
127
128 parsec_private_memory_fini( parsec_cgetrf_sp1dplus->_g_p_work );
129 free( parsec_cgetrf_sp1dplus->_g_p_work );
130
131 parsec_taskpool_free( taskpool );
132}
133
134/**
135 *******************************************************************************
136 *
137 * @brief Perform a sparse LU factorization with 1D kernels.
138 *
139 * The function performs the LU factorization of a sparse general matrix A.
140 * The factorization has the form
141 *
142 * \f[ A = L\times U \f]
143 *
144 * where L is a sparse lower triangular matrix, and U a sparse upper triangular
145 * with the same pattern as L^t.
146 *
147 *******************************************************************************
148 *
149 * @param[inout] parsec
150 * The parsec context of the application that will run the operation.
151 *
152 * @param[inout] A
153 * Descriptor of the sparse matrix A.
154 * On exit, A is overwritten with the factorized matrix.
155 *
156 * @param[inout] sopalin_data
157 * Solver matrix information structure that will guide the algorithm.
158 *
159 *******************************************************************************
160 *
161 * @retval NULL if incorrect parameters are given.
162 * @retval The parsec taskpool describing the operation that can be
163 * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
164 * destroy with parsec_cgetrf_sp1dplus_Destruct().
165 *
166 *******************************************************************************
167 *
168 * @sa parsec_cgetrf_sp1dplus_New
169 * @sa parsec_cgetrf_sp1dplus_Destruct
170 *
171 ******************************************************************************/
172int
173parsec_cgetrf_sp1dplus( parsec_context_t *parsec,
175 sopalin_data_t *sopalin_data )
176{
177 parsec_taskpool_t *parsec_cgetrf_sp1dplus = NULL;
178 int info = 0;
179
181
182 if ( parsec_cgetrf_sp1dplus == NULL ) {
183 return -1;
184 }
185
186 parsec_context_add_taskpool( parsec, (parsec_taskpool_t*)parsec_cgetrf_sp1dplus );
187 parsec_context_start( parsec );
188 parsec_context_wait( parsec );
190
191 return info;
192}
193
194/**
195 *******************************************************************************
196 *
197 * @brief Generate the PaRSEC taskpoolr object for the LU factorization with
198 * 1D and 2D kernels.
199 *
200 * The function only return the object that describes the LU factorization of a
201 * sparse general matrix A.
202 * The factorization has the form
203 *
204 * \f[ A = L\times U \f]
205 *
206 * where L is a sparse lower triangular matrix, and U a sparse upper triangular
207 * with the same pattern as L^t.
208 *
209 * In this object, operations are panel based operations for the lower levels of
210 * the elimination tree, and the higher levels are taskpoold by 2D tasks scheme to
211 * create more parallelism and adapt to large architectures.
212 *
213 * @warning The computations are not done by this call.
214 *
215 *******************************************************************************
216 *
217 * @param[inout] A
218 * Descriptor of the sparse matrix A.
219 * On exit, A is overwritten with the factorized matrix.
220 *
221 * @param[inout] sopalin_data
222 * Solver matrix information structure that will guide the algorithm.
223 *
224 *******************************************************************************
225 *
226 * @retval NULL if incorrect parameters are given.
227 * @retval The parsec taskpool describing the operation that can be
228 * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
229 * destroy with parsec_cgetrf_sp2d_Destruct().
230 *
231 *******************************************************************************
232 *
233 * @sa parsec_cgetrf_sp2d
234 * @sa parsec_cgetrf_sp2d_Destruct
235 * @sa parsec_cgetrf_sp2d
236 * @sa parsec_cgetrf_sp2d_New
237 * @sa parsec_dgetrf_sp2d_New
238 * @sa parsec_sgetrf_sp2d_New
239 *
240 ******************************************************************************/
241parsec_taskpool_t*
243 sopalin_data_t *sopalin_data )
244{
245 parsec_cgetrf_sp2d_taskpool_t *parsec_cgetrf_sp2d = NULL;
246 pastix_int_t lwork;
247
248 lwork = sopalin_data->solvmtx->gemmmax;
249 if ( (sopalin_data->solvmtx->lowrank.compress_when != PastixCompressNever) &&
250 (sopalin_data->solvmtx->lowrank.ilu_lvl < INT_MAX) )
251 {
252 lwork = pastix_imax( lwork, 2 * sopalin_data->solvmtx->blokmax );
253 }
254
255 parsec_cgetrf_sp2d = parsec_cgetrf_sp2d_new( A, sopalin_data, NULL, lwork );
256
257 parsec_cgetrf_sp2d->_g_p_work = (parsec_memory_pool_t*)malloc(sizeof(parsec_memory_pool_t));
258 parsec_private_memory_init( parsec_cgetrf_sp2d->_g_p_work,
259 lwork * sizeof(pastix_complex32_t) );
260
261 parsec_arena_construct( parsec_cgetrf_sp2d->arenas[PARSEC_cgetrf_sp2d_DEFAULT_ARENA],
262 sizeof(pastix_complex32_t), PARSEC_ARENA_ALIGNMENT_SSE,
263 parsec_datatype_complex_t );
264
265#if defined(PASTIX_GENERATE_MODEL)
266 parsec_cgetrf_sp2d->_g_forced_pushout = 1;
267#endif
268 return (parsec_taskpool_t*)parsec_cgetrf_sp2d;
269}
270
271/**
272 *******************************************************************************
273 *
274 * @brief Free the data structure associated to a taskpool created with
275 * parsec_cgetrf_sp2d_New().
276 *
277 *******************************************************************************
278 *
279 * @param[inout] taskpool
280 * On entry, the taskpool to destroy.
281 * On exit, the taskpool cannot be used anymore.
282 *
283 ******************************************************************************/
284void
285parsec_cgetrf_sp2d_Destruct( parsec_taskpool_t *taskpool )
286{
287 parsec_cgetrf_sp2d_taskpool_t *parsec_cgetrf_sp2d = NULL;
288 parsec_cgetrf_sp2d = (parsec_cgetrf_sp2d_taskpool_t *)taskpool;
289
290 parsec_private_memory_fini( parsec_cgetrf_sp2d->_g_p_work );
291 free( parsec_cgetrf_sp2d->_g_p_work );
292
293 parsec_taskpool_free( taskpool );
294}
295
296/**
297 *******************************************************************************
298 *
299 * @brief Perform a sparse LU factorization with 1D and 2D kernels.
300 *
301 * The function performs the LU factorization of a sparse general matrix A.
302 * The factorization has the form
303 *
304 * \f[ A = L\times U \f]
305 *
306 * where L is a sparse lower triangular matrix, and U a sparse upper triangular
307 * with the same pattern as L^t.
308 *
309 *******************************************************************************
310 *
311 * @param[inout] parsec
312 * The parsec context of the application that will run the operation.
313 *
314 * @param[inout] A
315 * Descriptor of the sparse matrix A.
316 * On exit, A is overwritten with the factorized matrix.
317 *
318 * @param[inout] sopalin_data
319 * Solver matrix information structure that will guide the algorithm.
320 *
321 *******************************************************************************
322 *
323 * @retval NULL if incorrect parameters are given.
324 * @retval The parsec taskpool describing the operation that can be
325 * enqueued in the runtime with parsec_enqueue(). It, then, needs to be
326 * destroy with parsec_cgetrf_sp2d_Destruct().
327 *
328 *******************************************************************************
329 *
330 * @sa parsec_cgetrf_sp2d_New
331 * @sa parsec_cgetrf_sp2d_Destruct
332 *
333 ******************************************************************************/
334int
335parsec_cgetrf_sp2d( parsec_context_t *parsec,
337 sopalin_data_t *sopalin_data )
338{
339 parsec_taskpool_t *parsec_cgetrf_sp2d = NULL;
340 int info = 0;
341
342 parsec_cgetrf_sp2d = parsec_cgetrf_sp2d_New( A, sopalin_data );
343
344 if ( parsec_cgetrf_sp2d == NULL ) {
345 return -1;
346 }
347
348 parsec_context_add_taskpool( parsec, (parsec_taskpool_t*)parsec_cgetrf_sp2d );
349 parsec_context_start( parsec );
350 parsec_context_wait( parsec );
352
353 return info;
354}
355
356/**
357 *******************************************************************************
358 *
359 * @brief Perform a sparse LU factorization using PaRSEC runtime.
360 *
361 * The function performs the LU factorization of a sparse general matrix A.
362 * The factorization has the form
363 *
364 * \f[ A = L\times U \f]
365 *
366 * where L is a sparse lower triangular matrix, and U a sparse upper triangular
367 * with the same pattern as L^t.
368 *
369 * The algorithm is automatically chosen between the 1D and 2D version based on
370 * the API parameter IPARM_TASKS2D_LEVEL. If IPARM_TASKS2D_LEVEL != 0
371 * the 2D scheme is applied, the 1D otherwise.
372 *
373 *******************************************************************************
374 *
375 * @param[inout] pastix_data
376 * The pastix_data structure that describes the solver instance.
377 *
378 * @param[inout] sopalin_data
379 * Solver matrix information structure that will guide the algorithm.
380 *
381 *******************************************************************************
382 *
383 * @sa parsec_cgetrf_sp1dplus
384 * @sa parsec_cgetrf_sp2d
385 *
386 ******************************************************************************/
387void
389 sopalin_data_t *sopalin_data )
390{
391 parsec_sparse_matrix_desc_t *sdesc = sopalin_data->solvmtx->parsec_desc;
392 parsec_context_t *ctx;
393
394 /*
395 * Start PaRSEC if not already started
396 */
397 if (pastix_data->parsec == NULL) {
398 int argc = 0;
399 pastix_parsec_init( pastix_data, &argc, NULL, NULL );
400 }
401 ctx = pastix_data->parsec;
402
403 if ( sdesc == NULL ) {
404 /* Create the matrix descriptor */
405 parsec_sparse_matrix_init( sopalin_data->solvmtx,
407 pastix_data->inter_node_procnbr,
408 pastix_data->inter_node_procnum );
409 sdesc = sopalin_data->solvmtx->parsec_desc;
410 }
411
412 /*
413 * Select 1D or 2D jdf based on 2d tasks level
414 */
415 if ( pastix_data->iparm[IPARM_TASKS2D_LEVEL] != 0 )
416 {
417 parsec_cgetrf_sp2d( ctx, sdesc,
418 sopalin_data );
419 }
420 else {
421 parsec_cgetrf_sp1dplus( ctx, sdesc,
422 sopalin_data );
423 }
424
425 return;
426}
427
428/**
429 *@}
430 */
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_cgetrf_sp2d_New(parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Generate the PaRSEC taskpoolr object for the LU factorization with 1D and 2D kernels.
int parsec_cgetrf_sp2d(parsec_context_t *parsec, parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Perform a sparse LU factorization with 1D and 2D kernels.
int parsec_cgetrf_sp1dplus(parsec_context_t *parsec, parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Perform a sparse LU factorization with 1D kernels.
void parsec_cgetrf_sp1dplus_Destruct(parsec_taskpool_t *taskpool)
Free the data structure associated to a taskpool created with parsec_cgetrf_sp1dplus_New().
parsec_taskpool_t * parsec_cgetrf_sp1dplus_New(parsec_sparse_matrix_desc_t *A, sopalin_data_t *sopalin_data)
Generate the PaRSEC taskpool object for the LU factorization with 1D kernels.
void parsec_cgetrf_sp2d_Destruct(parsec_taskpool_t *taskpool)
Free the data structure associated to a taskpool created with parsec_cgetrf_sp2d_New().
void parsec_cgetrf(pastix_data_t *pastix_data, sopalin_data_t *sopalin_data)
Perform a sparse LU factorization using PaRSEC runtime.
#define PastixGeneral
Definition api.h:458
@ 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.
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