PaStiX Handbook  6.4.0
cpucblk_sschur.c
Go to the documentation of this file.
1 /**
2  *
3  * @file cpucblk_sschur.c
4  *
5  * Precision dependent routines to extract the Schur complement.
6  *
7  * @copyright 2015-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.4.0
11  * @author Gregoire Pichon
12  * @author Mathieu Faverge
13  * @date 2024-07-05
14  *
15  * @generated from /builds/solverstack/pastix/kernels/cpucblk_zschur.c, normal z -> s, Tue Oct 8 14:17:24 2024
16  *
17  **/
18 #include "common/common.h"
19 #include "blend/solver.h"
20 #include <lapacke.h>
21 #include "pastix_scores.h"
22 #include "pastix_slrcores.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  float *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_slr2ge( 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_sgeadd( 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_slr2ge( 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  float *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  float *lcoeftab = cblk->lcoeftab;
126  float *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_slacpy_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_sgeadd( 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  float *S,
185  pastix_int_t lds )
186 {
187  if ( cblk->cblktype & CBLK_COMPRESSED ) {
188  cpucblk_sgetschur_lr( cblk, upper_part, S, lds );
189  }
190  else {
191  cpucblk_sgetschur_fr( cblk, upper_part, S, lds );
192  }
193 }
static void cpucblk_sgetschur_lr(const SolverCblk *cblk, int upper_part, float *S, pastix_int_t lds)
Extract a low-rank cblk panel to a dense lapack form.
static void cpucblk_sgetschur_fr(const SolverCblk *cblk, int upper_part, float *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_sgeadd(pastix_trans_t trans, pastix_int_t M, pastix_int_t N, float alpha, const float *A, pastix_int_t LDA, float beta, float *B, pastix_int_t LDB)
Add two matrices together.
Definition: core_sgeadd.c:78
void cpucblk_sgetschur(const SolverCblk *cblk, int upper_part, float *S, pastix_int_t lds)
Extract a cblk panel of the Schur complement to a dense lapack form.
int core_slr2ge(pastix_trans_t trans, pastix_int_t m, pastix_int_t n, const pastix_lrblock_t *Alr, float *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:395
void * ucoeftab
Definition: solver.h:178
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Definition: solver.h:329
pastix_int_t coefind
Definition: solver.h:149
SolverBlok * fblokptr
Definition: solver.h:168
pastix_lrblock_t * LRblock[2]
Definition: solver.h:155
pastix_int_t stride
Definition: solver.h:169
int8_t cblktype
Definition: solver.h:164
void * lcoeftab
Definition: solver.h:177
Solver block structure.
Definition: solver.h:141
Solver column block structure.
Definition: solver.h:161