PaStiX Handbook  6.3.2
cpucblk_zschur.c
Go to the documentation of this file.
1 /**
2  *
3  * @file cpucblk_zschur.c
4  *
5  * Precision dependent routines to extract the Schur complement.
6  *
7  * @copyright 2015-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.3.2
11  * @author Gregoire Pichon
12  * @author Mathieu Faverge
13  * @date 2023-07-21
14  *
15  * @generated from /builds/solverstack/pastix/kernels/cpucblk_zschur.c, normal z -> z, Wed Dec 13 12:09:18 2023
16  *
17  **/
18 #include "common/common.h"
19 #include "blend/solver.h"
20 #include <lapacke.h>
21 #include "pastix_zcores.h"
22 #include "pastix_zlrcores.h"
23 
24 /**
25  *******************************************************************************
26  *
27  * @brief Extract a low-rank cblk panel to a dense lapack form
28  *
29  *******************************************************************************
30  *
31  * @param[in] cblk
32  * The column block to extract in the Schur array
33  *
34  * @param[in] upper_part
35  * If true, the upper part is also extracted in S.
36  *
37  * @param[inout] S
38  * The pointer to the top of the column of the cblk in the Schur array.
39  * On exit, the computed coefficient are copy to this array.
40  *
41  * @param[in] lds
42  * The leading dimension of the S array.
43  *
44  *******************************************************************************/
45 static inline void
47  int upper_part,
48  pastix_complex64_t *S,
49  pastix_int_t lds )
50 {
51  SolverBlok *blok = cblk[0].fblokptr;
52  SolverBlok *lblok = cblk[1].fblokptr;
53  pastix_int_t coefind;
54  pastix_int_t ncols = cblk_colnbr( cblk );
55  int ret;
56 
57  assert( cblk->cblktype & CBLK_COMPRESSED );
58  assert( cblk->cblktype & CBLK_LAYOUT_2D );
59 
60  for (; blok<lblok; blok++)
61  {
62  pastix_int_t nrows = blok_rownbr( blok );
63 
64  nrows = blok_rownbr( blok );
65  coefind = blok->coefind / ncols;
66 
67  ret = core_zlr2ge( PastixNoTrans, nrows, ncols,
68  blok->LRblock[0],
69  S + coefind, lds );
70  assert( ret == 0 );
71  /* TODO: check/fix with respect to full rank (L+U instead of just L or U)*/
72 
73  if ( upper_part ) {
74  if ( blok == cblk[0].fblokptr ) {
75  assert( cblk->fblokptr->LRblock[1]->rk == -1 );
76  assert( cblk->fblokptr->LRblock[1]->rkmax == ncols );
77 
78  core_zgeadd( PastixTrans, ncols, ncols,
79  1.0, cblk->fblokptr->LRblock[1]->u, ncols,
80  1.0, S + coefind * lds, lds );
81 
82  } else {
83  ret = core_zlr2ge( PastixTrans, nrows, ncols,
84  blok->LRblock[1],
85  S + coefind * lds, lds );
86  assert( ret == 0 );
87  }
88  }
89  }
90 
91  (void)ret;
92 }
93 
94 /**
95  *******************************************************************************
96  *
97  * @brief Extract a full-rank cblk panel to a dense lapack form
98  *
99  *******************************************************************************
100  *
101  * @param[in] cblk
102  * The column block to extract in the Schur array
103  *
104  * @param[in] upper_part
105  * If true, the upper part is also extracted in S.
106  *
107  * @param[inout] S
108  * The pointer to the top of the column of the cblk in the Schur array.
109  * On exit, the computed coefficient are copy to this array.
110  *
111  * @param[in] lds
112  * The leading dimension of the S array.
113  *
114  *******************************************************************************/
115 static inline void
117  int upper_part,
118  pastix_complex64_t *S,
119  pastix_int_t lds )
120 {
121  SolverBlok *blok = cblk[0].fblokptr;
122  SolverBlok *lblok = cblk[1].fblokptr;
123  pastix_int_t ncols = cblk_colnbr( cblk );
124  pastix_int_t nrows, coefind, stride, ret;
125  pastix_complex64_t *lcoeftab = cblk->lcoeftab;
126  pastix_complex64_t *ucoeftab = cblk->ucoeftab;
127  int layout2d = ( cblk->cblktype & CBLK_LAYOUT_2D );
128 
129  assert( !(cblk->cblktype & CBLK_COMPRESSED) );
130 
131  for (; blok<lblok; blok++)
132  {
133  nrows = blok_rownbr( blok );
134 
135  if (layout2d) {
136  coefind = blok->coefind / ncols;
137  stride = nrows;
138  }
139  else {
140  coefind = blok->coefind;
141  stride = cblk->stride;
142  }
143 
144  ret = LAPACKE_zlacpy_work( LAPACK_COL_MAJOR, 'A', nrows, ncols,
145  lcoeftab + blok->coefind, stride,
146  S + coefind, lds );
147  assert( ret == 0 );
148 
149  if ( upper_part )
150  {
151  core_zgeadd( PastixTrans, ncols, nrows,
152  1.0, ucoeftab + blok->coefind, stride,
153  1.0, S + coefind * lds, lds );
154  }
155  }
156 
157  (void)ret;
158 }
159 
160 /**
161  *******************************************************************************
162  *
163  * @brief Extract a cblk panel of the Schur complement to a dense lapack form.
164  *
165  *******************************************************************************
166  *
167  * @param[in] cblk
168  * The column block to extract in the Schur array
169  *
170  * @param[in] upper_part
171  * If true, the upper part is also extracted in S.
172  *
173  * @param[inout] S
174  * The pointer to the top of the column of the cblk in the Schur array.
175  * On exit, the computed coefficient are copy to this array.
176  *
177  * @param[in] lds
178  * The leading dimension of the S array.
179  *
180  *******************************************************************************/
181 void
183  int upper_part,
184  pastix_complex64_t *S,
185  pastix_int_t lds )
186 {
187  if ( cblk->cblktype & CBLK_COMPRESSED ) {
188  cpucblk_zgetschur_lr( cblk, upper_part, S, lds );
189  }
190  else {
191  cpucblk_zgetschur_fr( cblk, upper_part, S, lds );
192  }
193 }
static void cpucblk_zgetschur_lr(const SolverCblk *cblk, int upper_part, pastix_complex64_t *S, pastix_int_t lds)
Extract a low-rank cblk panel to a dense lapack form.
static void cpucblk_zgetschur_fr(const SolverCblk *cblk, int upper_part, pastix_complex64_t *S, pastix_int_t lds)
Extract a full-rank cblk panel to a dense lapack form.
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
int core_zgeadd(pastix_trans_t trans, pastix_int_t M, pastix_int_t N, pastix_complex64_t alpha, const pastix_complex64_t *A, pastix_int_t LDA, pastix_complex64_t beta, pastix_complex64_t *B, pastix_int_t LDB)
Add two matrices together.
Definition: core_zgeadd.c:78
void cpucblk_zgetschur(const SolverCblk *cblk, int upper_part, pastix_complex64_t *S, pastix_int_t lds)
Extract a cblk panel of the Schur complement to a dense lapack form.
int core_zlr2ge(pastix_trans_t trans, pastix_int_t m, pastix_int_t n, const pastix_lrblock_t *Alr, pastix_complex64_t *A, pastix_int_t lda)
Convert a low rank matrix into a dense matrix.
@ PastixNoTrans
Definition: api.h:445
@ PastixTrans
Definition: api.h:446
static pastix_int_t blok_rownbr(const SolverBlok *blok)
Compute the number of rows of a block.
Definition: solver.h:390
void * ucoeftab
Definition: solver.h:172
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Definition: solver.h:324
pastix_int_t coefind
Definition: solver.h:144
SolverBlok * fblokptr
Definition: solver.h:163
pastix_lrblock_t * LRblock[2]
Definition: solver.h:150
pastix_int_t stride
Definition: solver.h:164
int8_t cblktype
Definition: solver.h:159
void * lcoeftab
Definition: solver.h:171
Solver block structure.
Definition: solver.h:137
Solver column block structure.
Definition: solver.h:156