PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
cpucblk_zcinit.c
Go to the documentation of this file.
1/**
2 *
3 * @file cpucblk_zcinit.c
4 *
5 * Mixed-Precision dependent coeficient array initialization routines.
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 Xavier Lacoste
12 * @author Pierre Ramet
13 * @author Mathieu Faverge
14 * @author Esragul Korkmaz
15 * @author Tony Delarue
16 * @author Brieuc Nicolas
17 * @date 2024-07-05
18 *
19 * @generated from /builds/2mk6rsew/0/solverstack/pastix/kernels/cpucblk_zcinit.c, mixed zc -> zc, Tue Feb 25 14:35:00 2025
20 *
21 **/
22#include "common/common.h"
23#include "blend/solver.h"
24#include "bcsc/bcsc.h"
25#include "pastix_zcores.h"
26#include "pastix_zlrcores.h"
27#include <lapacke.h>
28
29#ifndef DOXYGEN_SHOULD_SKIP_THIS
30#if defined(PRECISION_zc)
31#define cpucblk_zccheck_overflow( value, overflow ) \
32{ \
33 double rvalue = fabs( creal( value ) ); \
34 double ivalue = fabs( cimag( value ) ); \
35 if ( pastix_unlikely( (rvalue > overflow) || (ivalue > overflow) ) ) { \
36 pastix_print_warning( "cpucblk_zccheck_overflow, Incorrect value overflow for mixed precision" ); \
37 return 1; \
38 } \
39}
40#else
41#define cpucblk_dscheck_overflow( value, overflow ) \
42{ \
43 double valabs = fabs( value ); \
44 if ( pastix_unlikely( valabs > overflow ) ) { \
45 pastix_print_warning( "cpucblk_dscheck_overflow, Incorrect value overflow for mixed precision" ); \
46 return 1; \
47 } \
48}
49#endif
50#endif /* DOXYGEN_SHOULD_SKIP_THIS */
51
52/**
53 *******************************************************************************
54 *
55 * @brief Initialize the full-rank coeftab structure from the internat bcsc.
56 *
57 *******************************************************************************
58 *
59 * @param[in] side
60 * Define which side of the matrix must be initialized.
61 * @arg PastixLCoef if lower part only
62 * @arg PastixUCoef if upper part only
63 * @arg PastixLUCoef if both sides.
64 *
65 * @param[in] solvmtx
66 * PaStiX structure to store numerical data and flags
67 *
68 * @param[in] bcsc
69 * The internal bcsc structure that hold the graph with permutation
70 * stored by cblk.
71 *
72 * @param[in] itercblk
73 * The index of the cblk to fill in both bcsc and solvmtx structures.
74 *
75 *******************************************************************************
76 *
77 * @return 0 on success, 1 in case of overflow during initialization.
78 *
79 *******************************************************************************/
80static inline int
82 const SolverMatrix *solvmtx,
83 const pastix_bcsc_t *bcsc,
84 pastix_int_t itercblk )
85{
86 SolverCblk *solvcblk = solvmtx->cblktab + itercblk;
87 const bcsc_cblk_t *csccblk = bcsc->cscftab + solvcblk->bcscnum;
88 SolverBlok *solvblok;
89 SolverBlok *lsolvblok = (solvcblk+1)->fblokptr;
90 pastix_complex32_t *lcoeftab = solvcblk->lcoeftab;
91 pastix_complex32_t *ucoeftab = solvcblk->ucoeftab;
92 pastix_complex64_t *Lvalues = bcsc->Lvalues;
93 pastix_complex64_t *Uvalues = bcsc->Uvalues;
94 pastix_int_t ldd = solvcblk->stride;
95 pastix_int_t itercoltab, iterval, coefindx;
96 int is2d = solvcblk->cblktype & CBLK_LAYOUT_2D;
97 double overflow = LAPACKE_slamch( 'o' );
98
99 assert( (side != PastixUCoef) || (ucoeftab != NULL) );
100
101 for (itercoltab=0; itercoltab<csccblk->colnbr; itercoltab++)
102 {
103 pastix_int_t frow = csccblk->coltab[itercoltab];
104 pastix_int_t lrow = csccblk->coltab[itercoltab+1];
105 solvblok = solvcblk->fblokptr;
106 if ( is2d ) {
107 ldd = blok_rownbr( solvblok );
108 }
109
110 for (iterval=frow; iterval<lrow; iterval++)
111 {
112 pastix_int_t rownum = bcsc->rowtab[iterval];
113
114 /* If values in the lower part of the matrix */
115 if (rownum >= (solvcblk->fcolnum+itercoltab))
116 {
117 while ((solvblok < lsolvblok) &&
118 ((solvblok->lrownum < rownum) ||
119 (solvblok->frownum > rownum)))
120 {
121 solvblok++;
122 if ( is2d ) {
123 ldd = blok_rownbr( solvblok );
124 }
125 }
126
127 if ( solvblok < lsolvblok )
128 {
129 coefindx = solvblok->coefind;
130 coefindx += rownum - solvblok->frownum; /* Row shift */
131 coefindx += itercoltab * ldd; /* Column shift */
132 pastix_cblk_lock( solvcblk );
133 solvblok->iluklvl = 0;
134 pastix_cblk_unlock( solvcblk );
135
136 if ( side != PastixUCoef ) {
137 cpucblk_zccheck_overflow( Lvalues[iterval], overflow )
138 lcoeftab[coefindx] = (pastix_complex32_t) Lvalues[iterval];
139 }
140
141 if ( (side != PastixLCoef) &&
142 (rownum > (solvcblk->fcolnum + itercoltab)) )
143 {
144 cpucblk_zccheck_overflow( Uvalues[iterval], overflow );
145#if defined(PRECISION_zc)
146 if (bcsc->mtxtype == PastixHermitian) {
147 ucoeftab[coefindx] = (pastix_complex32_t) conj(Uvalues[iterval]);
148 }
149 else
150#endif
151 {
152 ucoeftab[coefindx] = (pastix_complex32_t) Uvalues[iterval];
153 }
154 }
155 }
156#if defined(PASTIX_DEBUG_COEFTAB)
157 else
158 {
159 fprintf( stderr, "cpucblk_zfillin: drop coeff from CSC c=%ld(%ld) l=%ld(%ld) cblk=%ld fcol=%ld lcol=%ld\n",
160 (long)solvcblk->fcolnum + itercoltab, (long)itercoltab,
161 (long)rownum, (long)iterval, (long)itercblk,
162 (long)solvcblk->fcolnum, (long)solvcblk->lcolnum );
163 }
164#endif
165 }
166 }
167 }
168 (void)overflow;
169 return 0;
170}
171
172/**
173 *******************************************************************************
174 *
175 * @brief Initialize the low-rank coeftab structure from the internal bcsc.
176 *
177 *******************************************************************************
178 *
179 * @param[in] side
180 * Define which side of the matrix must be initialized.
181 * @arg PastixLCoef if lower part only
182 * @arg PastixUCoef if upper part only
183 * @arg PastixLUCoef if both sides.
184 *
185 * @param[in] solvmtx
186 * PaStiX structure to store numerical data and flags
187 *
188 * @param[in] bcsc
189 * The internal bcsc structure that hold the graph with permutation
190 * stored by cblk.
191 *
192 * @param[in] itercblk
193 * The index of the cblk to fill in both bcsc and solvmtx structures.
194 *
195 *******************************************************************************
196 *
197 * @return 0 on success, 1 in case of overflow during initialization.
198 *
199 *******************************************************************************/
200static inline int
202 const SolverMatrix *solvmtx,
203 const pastix_bcsc_t *bcsc,
204 pastix_int_t itercblk )
205{
206 SolverCblk *solvcblk = solvmtx->cblktab + itercblk;
207 const bcsc_cblk_t *csccblk = bcsc->cscftab + solvcblk->bcscnum;
208 SolverBlok *solvblok;
209 SolverBlok *lsolvblok = (solvcblk+1)->fblokptr;
210 pastix_complex32_t *lcoeftab, *ucoeftab;
211 pastix_complex64_t *Lvalues = bcsc->Lvalues;
212 pastix_complex64_t *Uvalues = bcsc->Uvalues;
213 pastix_int_t itercoltab, iterval, coefindx, ldd;
214 double overflow = LAPACKE_slamch( 'o' );
215
216 assert( solvcblk->cblktype & CBLK_LAYOUT_2D );
217
218 for (itercoltab=0; itercoltab<csccblk->colnbr; itercoltab++)
219 {
220 pastix_int_t frow = csccblk->coltab[itercoltab];
221 pastix_int_t lrow = csccblk->coltab[itercoltab+1];
222
223 solvblok = solvcblk->fblokptr;
224 ldd = blok_rownbr( solvblok );
225 lcoeftab = (pastix_complex32_t*)(solvblok->LRblock[0]->u);
226 ucoeftab = (pastix_complex32_t*)(solvblok->LRblock[1]->u);
227
228 for (iterval=frow; iterval<lrow; iterval++)
229 {
230 pastix_int_t rownum = bcsc->rowtab[iterval];
231
232 /* If values in the lower part of the matrix */
233 if (rownum >= (solvcblk->fcolnum+itercoltab))
234 {
235 while ((solvblok < lsolvblok) &&
236 ((solvblok->lrownum < rownum) ||
237 (solvblok->frownum > rownum)))
238 {
239 solvblok++;
240 ldd = blok_rownbr( solvblok );
241 lcoeftab = (pastix_complex32_t*)(solvblok->LRblock[0]->u);
242 ucoeftab = (pastix_complex32_t*)(solvblok->LRblock[1]->u);
243 }
244
245 if ( solvblok < lsolvblok )
246 {
247 coefindx = rownum - solvblok->frownum; /* Row shift */
248 coefindx += itercoltab * ldd; /* Column shift */
249 pastix_cblk_lock( solvcblk );
250 solvblok->iluklvl = 0;
251 pastix_cblk_unlock( solvcblk );
252
253 if ( side != PastixUCoef ) {
254 cpucblk_zccheck_overflow( Lvalues[iterval], overflow );
255 lcoeftab[coefindx] = (pastix_complex32_t) Lvalues[iterval];
256 }
257
258 if ( (side != PastixLCoef) &&
259 (rownum > (solvcblk->fcolnum + itercoltab)) )
260 {
261 cpucblk_zccheck_overflow( Uvalues[iterval], overflow);
262#if defined(PRECISION_zc)
263 if (bcsc->mtxtype == PastixHermitian) {
264 ucoeftab[coefindx] = (pastix_complex32_t) conj(Uvalues[iterval]);
265 }
266 else
267#endif
268 {
269 ucoeftab[coefindx] = (pastix_complex32_t) Uvalues[iterval];
270 }
271 }
272 }
273#if defined(PASTIX_DEBUG_COEFTAB)
274 else
275 {
276 fprintf( stderr, "cpucblk_zfillin: drop coeff from CSC c=%ld(%ld) l=%ld(%ld) cblk=%ld fcol=%ld lcol=%ld\n",
277 (long)solvcblk->fcolnum + itercoltab, (long)itercoltab,
278 (long)rownum, (long)iterval, (long)itercblk,
279 (long)solvcblk->fcolnum, (long)solvcblk->lcolnum );
280 }
281#endif
282 }
283 }
284 }
285 (void)overflow;
286 return 0;
287}
288
289/**
290 *******************************************************************************
291 *
292 * @brief Initialize the coeftab structure from the internal bcsc.
293 *
294 *******************************************************************************
295 *
296 * @param[in] side
297 * Define which side of the matrix must be initialized.
298 * @arg PastixLCoef if lower part only
299 * @arg PastixUCoef if upper part only
300 * @arg PastixLUCoef if both sides.
301 *
302 * @param[in] solvmtx
303 * PaStiX structure to store numerical data and flags
304 *
305 * @param[in] bcsc
306 * The internal bcsc structure that hold the graph with permutation
307 * stored by cblk.
308 *
309 * @param[in] itercblk
310 * The index of the cblk to fill in both bcsc and solvmtx structures.
311 *
312 *******************************************************************************
313 *
314 * @return 0 on success, 1 in case of overflow during initialization.
315 *
316 *******************************************************************************/
317int
319 const SolverMatrix *solvmtx,
320 const pastix_bcsc_t *bcsc,
321 pastix_int_t itercblk )
322{
323 int rc;
324 if ( (solvmtx->cblktab + itercblk)->cblktype & CBLK_COMPRESSED ) {
325 rc = cpucblk_zcfillin_lr( side, solvmtx, bcsc, itercblk );
326 }
327 else {
328 rc = cpucblk_zcfillin_fr( side, solvmtx, bcsc, itercblk );
329 }
330 return rc;
331}
static int cpucblk_zcfillin_fr(pastix_coefside_t side, const SolverMatrix *solvmtx, const pastix_bcsc_t *bcsc, pastix_int_t itercblk)
Initialize the full-rank coeftab structure from the internat bcsc.
int cpucblk_zcfillin(pastix_coefside_t side, const SolverMatrix *solvmtx, const pastix_bcsc_t *bcsc, pastix_int_t itercblk)
Initialize the coeftab structure from the internal bcsc.
static int cpucblk_zcfillin_lr(pastix_coefside_t side, const SolverMatrix *solvmtx, const pastix_bcsc_t *bcsc, pastix_int_t itercblk)
Initialize the low-rank coeftab structure from the internal bcsc.
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
float _Complex pastix_complex32_t
Definition datatypes.h:76
pastix_int_t colnbr
Definition bcsc.h:111
pastix_int_t * coltab
Definition bcsc.h:113
Compressed colptr format for the bcsc.
Definition bcsc.h:110
#define PastixHermitian
Definition api.h:460
enum pastix_coefside_e pastix_coefside_t
Data blocks used in the kernel.
@ PastixLCoef
Definition api.h:478
@ PastixUCoef
Definition api.h:479
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
pastix_int_t lrownum
Definition solver.h:148
pastix_int_t frownum
Definition solver.h:147
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 bcscnum
Definition solver.h:175
SolverCblk *restrict cblktab
Definition solver.h:228
pastix_int_t stride
Definition solver.h:169
int8_t cblktype
Definition solver.h:164
pastix_int_t lcolnum
Definition solver.h:167
void * lcoeftab
Definition solver.h:177
pastix_int_t fcolnum
Definition solver.h:166
Solver block structure.
Definition solver.h:141
Solver column block structure.
Definition solver.h:161
Solver column block structure.
Definition solver.h:203