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