PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
symbol.h
Go to the documentation of this file.
1/**
2 *
3 * @file symbol.h
4 *
5 * PaStiX symbol structure routines
6 *
7 * @copyright 2004-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author David Goudin
12 * @author Francois Pellegrini
13 * @author Mathieu Faverge
14 * @author Pascal Henon
15 * @author Pierre Ramet
16 * @author Gregoire Pichon
17 * @author Tony Delarue
18 * @author Vincent Bridonneau
19 * @date 2024-07-05
20 *
21 * @addtogroup pastix_symbol
22 * @{
23 * @brief Functions to generate and manipulate the symbolic factorization
24 * structure
25 *
26 * This module provides the set of function to generate the symbolic
27 * factorization structure based on a given graph, and an associated
28 * ordering. The symbolic structure is described in the symbol_matrix_t
29 * structure, and it can be generated through two different algorithms
30 * respectively for direct and incomplete factorization.
31 *
32 **/
33#ifndef _symbol_h_
34#define _symbol_h_
35
36#ifndef DOXYGEN_SHOULD_SKIP_THIS
37#define SYMBCBLK_NOTHING 0
38#define SYMBCBLK_PROJ 1
39#define SYMBCBLK_KWAY 2
40#endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
42/**
43 * @brief Symbol column block structure.
44 */
45typedef struct symbol_cblk_s {
46 pastix_int_t fcolnum; /**< First column index */
47 pastix_int_t lcolnum; /**< Last column index (inclusive) */
48 pastix_int_t bloknum; /**< First block in column (diagonal) */
49 pastix_int_t brownum; /**< First block in row facing the diagonal block in browtab, 0-based */
50 int8_t selevtx;
51#if defined( PASTIX_SYMBOL_DUMP_SYMBMTX )
52 pastix_int_t split_cblk;
53#endif
55
56/**
57 * @brief Symbol block structure.
58 */
59typedef struct symbol_blok_s {
60 pastix_int_t frownum; /**< First row index */
61 pastix_int_t lrownum; /**< Last row index (inclusive) */
62 pastix_int_t lcblknm; /**< Local column block */
63 pastix_int_t fcblknm; /**< Facing column block */
65
66/**
67 * @brief Symbol matrix structure.
68 *
69 * This structure describes the symbolic block structure of the factorized
70 * matrix L, U is never stored as it is a symmetry of L. This structure is
71 * global and replicated on all processes. The default way to number the block
72 * is the CSC format where block are continuously number per column, the browtab
73 * array stores the CSR representation of the L structure to have a faster
74 * access to the list of blocks updating a column block.
75 *
76 */
77typedef struct symbol_matrix_s {
78 pastix_int_t baseval; /**< Base value for numbering */
79 pastix_int_t cblknbr; /**< Number of column blocks */
80 pastix_int_t bloknbr; /**< Number of blocks */
81 pastix_int_t nodenbr; /**< Number of nodes (Equal to gN in spm) */
82 pastix_int_t schurfcol; /**< First column of the schur complement */
83 symbol_cblk_t *cblktab; /**< Array of column blocks [+1,based] */
84 symbol_blok_t *bloktab; /**< Array of blocks in CSC format [based] */
85 pastix_int_t *browtab; /**< Array of blocks in CSR format [based] */
86 pastix_int_t browmax; /**< Maximum number of input edges per node */
87 pastix_int_t dof; /**< Degrees of freedom per node (constant
88 if > 0, variadic if < 1 */
89 pastix_int_t *dofs; /**< Array of the first column of each element
90 in the expanded matrix [+1,based] */
92
93/**
94 *******************************************************************************
95 *
96 * @brief Get the expanded column indexes of a symbol_cblk.
97 *
98 *******************************************************************************
99 *
100 * @param[in] symbmtx
101 * Pointer to the symbol matrix.
102 *
103 * @param[in] symbcblk
104 * The pointer to the current symbol_cblk.
105 *
106 * @param[inout] fcolnum
107 * First column index of the current cblk.
108 *
109 * @param[inout] lcolnum
110 * Last column index of the current cblk.
111 *
112 * @return The number of columns of the expanded cblk.
113 *
114 *******************************************************************************/
115static inline pastix_int_t
117 symbol_cblk_t *symbcblk,
118 pastix_int_t *fcolnum,
119 pastix_int_t *lcolnum )
120{
121 if ( symbmtx->dof < 0 ) {
122 *fcolnum = symbmtx->dofs[symbcblk->fcolnum];
123 *lcolnum = symbmtx->dofs[symbcblk->lcolnum + 1] - 1;
124 }
125 else {
126 *fcolnum = symbmtx->dof * symbcblk->fcolnum;
127 *lcolnum = symbmtx->dof * ( symbcblk->lcolnum + 1 ) - 1;
128 }
129 return (*lcolnum) - (*fcolnum) + 1;
130}
131
132/**
133 *******************************************************************************
134 *
135 * @brief Get the expanded row index of a symbol_blok.
136 *
137 *******************************************************************************
138 *
139 * @param[in] symbmtx
140 * Pointer to the symbol matrix.
141 *
142 * @param[in] symbblok
143 * The pointer to the current symbol_blok.
144 *
145 * @param[inout] frownum
146 * First row index of the current blok.
147 *
148 * @param[inout] lrownum
149 * Last row index of the current blok.
150 *
151 * @return The number of rows of the expanded blok.
152 *
153 *******************************************************************************/
154static inline pastix_int_t
156 symbol_blok_t *symbblok,
157 pastix_int_t *frownum,
158 pastix_int_t *lrownum )
159{
160 if ( symbmtx->dof < 0 ) {
161 *frownum = symbmtx->dofs[symbblok->frownum];
162 *lrownum = symbmtx->dofs[symbblok->lrownum + 1] - 1;
163 }
164 else {
165 *frownum = symbmtx->dof * symbblok->frownum;
166 *lrownum = symbmtx->dof * ( symbblok->lrownum + 1 ) - 1;
167 }
168 return (*lrownum) - (*frownum) + 1;
169}
170
171/**
172 * @brief Check if a block is included inside another one.
173 *
174 * Indicate if a blok is included inside another block.
175 * i.e. indicate if the row range of the first block is included in the
176 * one of the second.
177 *
178 * @param[in] blok The block that is tested for inclusion.
179 * @param[in] fblok The block that is suppose to include the first one.
180 *
181 * @retval true if the first block is included in the second one.
182 * @retval false if the first block is not included in the second one.
183 */
184static inline int
186 const symbol_blok_t *fblok )
187{
188 return ((blok->frownum >= fblok->frownum) &&
189 (blok->lrownum <= fblok->lrownum));
190}
191
192/**
193 * @name Symbol basic subroutines
194 * @{
195 */
196void pastixSymbolInit( const pastix_graph_t *graph,
197 const pastix_order_t *order,
198 symbol_matrix_t *symbptr );
199void pastixSymbolExit( symbol_matrix_t *symbptr );
200void pastixSymbolBase( symbol_matrix_t *symbptr,
201 const pastix_int_t baseval );
202void pastixSymbolRealloc( symbol_matrix_t *symbptr );
203int pastixSymbolCheck ( const symbol_matrix_t *symbptr );
204void pastixSymbolExpand ( symbol_matrix_t *symbptr );
205
206/**
207 * @}
208 * @name Symbol IO subroutines
209 * @{
210 */
211int pastixSymbolSave( const symbol_matrix_t *symbptr,
212 FILE *stream );
214 FILE *stream );
215int pastixSymbolDraw( const symbol_matrix_t *symbptr,
216 FILE *stream );
217void pastixSymbolDrawMap( pastix_data_t *pastix_data,
218 const char *extname,
219 pastix_int_t sndeidx );
220
221/**
222 * @}
223 * @name Symbol statistical information subroutines
224 * @{
225 */
226void pastixSymbolPrintStats( const symbol_matrix_t *symbptr );
227size_t pastixSymbolGetNNZ( const symbol_matrix_t *symbptr );
228void pastixSymbolGetFlops( const symbol_matrix_t *symbmtx,
229 pastix_coeftype_t flttype,
230 pastix_factotype_t factotype,
231 double *thflops,
232 double *rlflops );
233void pastixSymbolGetTimes( const symbol_matrix_t *symbmtx,
234 pastix_coeftype_t flttype,
235 pastix_factotype_t factotype,
236 double *cblkcost,
237 double *blokcost );
238
239/**
240 * @}
241 * @name Symbol reordering subroutines
242 * @{
243 */
246
247/**
248 * @}
249 * @name Symbol construction subroutines
250 * @{
251 */
253 const pastix_graph_t *graphA,
254 const pastix_order_t *ordeptr );
256 pastix_int_t levelk,
257 const pastix_graph_t *graphA,
258 const pastix_order_t *ordeptr );
261 pastix_int_t bloksrc,
262 pastix_int_t bloknum,
263 pastix_int_t startsearch,
264 int ricar );
265/**
266 * @}
267 */
268
269#endif /* _symbol_h_ */
270
271/**
272 * @}
273 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
spm_coeftype_t pastix_coeftype_t
Arithmetic types.
Definition api.h:294
enum pastix_factotype_e pastix_factotype_t
Factorization algorithms available for IPARM_FACTORIZATION parameter.
Order structure.
Definition order.h:47
pastix_int_t fcblknm
Definition symbol.h:63
pastix_int_t frownum
Definition symbol.h:60
pastix_int_t lrownum
Definition symbol.h:61
pastix_int_t bloknbr
Definition symbol.h:80
pastix_int_t * browtab
Definition symbol.h:85
pastix_int_t baseval
Definition symbol.h:78
symbol_cblk_t * cblktab
Definition symbol.h:83
pastix_int_t schurfcol
Definition symbol.h:82
pastix_int_t browmax
Definition symbol.h:86
pastix_int_t bloknum
Definition symbol.h:48
pastix_int_t brownum
Definition symbol.h:49
pastix_int_t fcolnum
Definition symbol.h:46
pastix_int_t lcolnum
Definition symbol.h:47
pastix_int_t dof
Definition symbol.h:87
symbol_blok_t * bloktab
Definition symbol.h:84
pastix_int_t lcblknm
Definition symbol.h:62
pastix_int_t * dofs
Definition symbol.h:89
pastix_int_t nodenbr
Definition symbol.h:81
pastix_int_t cblknbr
Definition symbol.h:79
void pastixSymbolRealloc(symbol_matrix_t *symbptr)
Reallocate the data structure to optimize the memory alignment.
Definition symbol.c:170
void pastixSymbolInit(const pastix_graph_t *graph, const pastix_order_t *order, symbol_matrix_t *symbptr)
Initialize the symbol structure.
Definition symbol.c:105
void pastixSymbolBase(symbol_matrix_t *symbptr, const pastix_int_t baseval)
Sets the base of the given symbol matrix structure to the given base value.
Definition symbol_base.c:37
void pastixSymbolPrintStats(const symbol_matrix_t *symbptr)
Print statistical information about the symbolic matrix structure.
Definition symbol.c:389
int pastixSymbolDraw(const symbol_matrix_t *symbptr, FILE *stream)
Export the symbol structure in a PostScript format.
struct symbol_matrix_s symbol_matrix_t
Symbol matrix structure.
void pastixSymbolBuildRowtab(symbol_matrix_t *symbptr)
Construct the browtab array that stores the blocks in a CSR way.
Definition symbol.c:302
size_t pastixSymbolGetNNZ(const symbol_matrix_t *symbptr)
Computes the number of non-zero elements in L.
pastix_int_t pastixSymbolGetFacingBloknum(const symbol_matrix_t *symbptr, pastix_int_t bloksrc, pastix_int_t bloknum, pastix_int_t startsearch, int ricar)
Search the targeted block C for a couple of blocks A and B.
Definition symbol.c:232
void pastixSymbolDrawMap(pastix_data_t *pastix_data, const char *extname, pastix_int_t sndeidx)
Dump a separator mapping into a map file.
struct symbol_blok_s symbol_blok_t
Symbol block structure.
void pastixSymbolGetTimes(const symbol_matrix_t *symbmtx, pastix_coeftype_t flttype, pastix_factotype_t factotype, double *cblkcost, double *blokcost)
Computes the cost of structure for the costMatrixBuild() function.
static pastix_int_t symbol_blok_get_rownum(const symbol_matrix_t *symbmtx, symbol_blok_t *symbblok, pastix_int_t *frownum, pastix_int_t *lrownum)
Get the expanded row index of a symbol_blok.
Definition symbol.h:155
void pastixSymbolReordering(pastix_data_t *)
Compute the reordering on the complete matrix.
static int is_symbblock_inside_fblock(const symbol_blok_t *blok, const symbol_blok_t *fblok)
Check if a block is included inside another one.
Definition symbol.h:185
struct symbol_cblk_s symbol_cblk_t
Symbol column block structure.
int pastixSymbolSave(const symbol_matrix_t *symbptr, FILE *stream)
Save the given block matrix structure to the given stream.
Definition symbol_io.c:147
int pastixSymbolLoad(symbol_matrix_t *symbptr, FILE *stream)
Load the given block matrix structure from the given stream.
Definition symbol_io.c:51
void pastixSymbolGetFlops(const symbol_matrix_t *symbmtx, pastix_coeftype_t flttype, pastix_factotype_t factotype, double *thflops, double *rlflops)
Computes the number of theoretical and real flops.
void pastixSymbolExpand(symbol_matrix_t *symbptr)
Expand the symbol matrix structure based on the dof information (compressed -> expanded)
static pastix_int_t symbol_cblk_get_colnum(const symbol_matrix_t *symbmtx, symbol_cblk_t *symbcblk, pastix_int_t *fcolnum, pastix_int_t *lcolnum)
Get the expanded column indexes of a symbol_cblk.
Definition symbol.h:116
int pastixSymbolFaxDirect(symbol_matrix_t *symbptr, const pastix_graph_t *graphA, const pastix_order_t *ordeptr)
Compute the block symbolic factorization of the given matrix graph according to the given vertex orde...
void pastixSymbolReorderingPrintComplexity(const symbol_matrix_t *symbptr)
Compute the number of operations required to compute the reordering on the complete matrix.
void pastixSymbolExit(symbol_matrix_t *symbptr)
Free the content of symbolic matrix.
Definition symbol.c:137
int pastixSymbolCheck(const symbol_matrix_t *symbptr)
Checks the consistency of the given symbolic block matrix.
int pastixSymbolFaxILUk(symbol_matrix_t *symbptr, pastix_int_t levelk, const pastix_graph_t *graphA, const pastix_order_t *ordeptr)
Create the symbol matrix from the graph of the non zero pattern of the factorized matrix and the supe...
Symbol block structure.
Definition symbol.h:59
Symbol column block structure.
Definition symbol.h:45
Symbol matrix structure.
Definition symbol.h:77
Main PaStiX data structure.
Definition pastixdata.h:68