PaStiX Handbook  6.4.0
pastix_lowrank.h
Go to the documentation of this file.
1 /**
2  * @file pastix_lowrank.h
3  *
4  * PaStiX kernel header.
5  *
6  * @copyright 2011-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
7  * Univ. Bordeaux. All rights reserved.
8  *
9  * @version 6.4.0
10  * @author Mathieu Faverge
11  * @author Pierre Ramet
12  * @author Xavier Lacoste
13  * @author Esragul Korkmaz
14  * @author Gregoire Pichon
15  * @date 2024-07-05
16  *
17  */
18 #ifndef _pastix_lowrank_h_
19 #define _pastix_lowrank_h_
20 
21 /**
22  *
23  * @addtogroup kernel_lr_null
24  * @{
25  * This module contains all the internal functions for low-rank kernels
26  */
27 
28 /**
29  * @brief List of short names for the compression kernels
30  */
31 extern const char *compmeth_shnames[PastixCompressMethodNbr];
32 
33 /**
34  * @brief List of long names for the compression kernels
35  */
36 extern const char *compmeth_lgnames[PastixCompressMethodNbr];
37 
38 /**
39  * @brief Macro to specify if the U part of a low-rank matrix is orthogonal or not (Used in LRMM functions).
40  */
41 #define PASTIX_LRM3_ORTHOU (1 << 0)
42 /**
43  * @brief Macro to specify if the U part of a low-rank matrix has been allocated and need to be freed or not (Used in LRMM functions).
44  */
45 #define PASTIX_LRM3_ALLOCU (1 << 1)
46 /**
47  * @brief Macro to specify if the V part of a low-rank matrix has been allocated and need to be freed or not (Used in LRMM functions).
48  */
49 #define PASTIX_LRM3_ALLOCV (1 << 2)
50 /**
51  * @brief Macro to specify if the the operator on B, still needs to be applied to the V part of the low-rank matrix or not (Used in LRMM functions).
52  */
53 #define PASTIX_LRM3_TRANSB (1 << 3)
54 
55 /**
56  * @brief Define the minimal ratio for which we accept to compress a matrix into a low-rank form or not.
57  * @sa core_get_rklimit()
58  */
59 extern double pastix_lr_minratio;
60 
61 /**
62  * @brief Define the orthogonalization method.
63  */
65 
66 /**
67  *******************************************************************************
68  *
69  * @brief Compute the maximal rank accepted for a given matrix size for testings
70  *
71  *******************************************************************************
72  *
73  * @param[in] M
74  * The number of rows of the matrix
75  *
76  * @param[in] N
77  * The number of columns of the matrix
78  *
79  *******************************************************************************
80  *
81  * @return The maximal rank accepted for this matrix size.
82  *
83  *******************************************************************************/
84 static inline pastix_int_t
86  return pastix_imin( M, N );
87 }
88 
89 /**
90  *******************************************************************************
91  *
92  * @brief Compute the maximal rank accepted for a given matrix size for Just-In-Time strategy
93  *
94  *******************************************************************************
95  *
96  * @param[in] M
97  * The number of rows of the matrix
98  *
99  * @param[in] N
100  * The number of columns of the matrix
101  *
102  *******************************************************************************
103  *
104  * @return The maximal rank accepted for this matrix size.
105  *
106  *******************************************************************************/
107 static inline pastix_int_t
109  return ( pastix_lr_minratio * pastix_imin( M, N ) ) / 4;
110 }
111 
112 /**
113  *******************************************************************************
114  *
115  * @brief Compute the maximal rank accepted for a given matrix size for Minimal-Memory strategy
116  *
117  *******************************************************************************
118  *
119  * @param[in] M
120  * The number of rows of the matrix
121  *
122  * @param[in] N
123  * The number of columns of the matrix
124  *
125  *******************************************************************************
126  *
127  * @return The maximal rank accepted for this matrix size.
128  *
129  *******************************************************************************/
130 static inline pastix_int_t
132  return ( pastix_lr_minratio * M * N ) / ( M + N );
133 }
134 
135 /**
136  *******************************************************************************
137  *
138  * @brief TODO
139  *
140  *******************************************************************************
141  *
142  * @param[in] M
143  * The number of rows of the matrix
144  *
145  * @param[in] N
146  * The number of columns of the matrix
147  *
148  *******************************************************************************
149  *
150  * @return TODO
151  *
152  *******************************************************************************/
153 static inline pastix_int_t
155  return pastix_imin( M, N );
156 }
157 
159 
160 struct pastix_lr_s;
161 typedef struct pastix_lr_s pastix_lr_t;
162 
163 /**
164  * @brief The block low-rank structure to hold a matrix in low-rank form
165  */
166 typedef struct pastix_lrblock_s {
167  int rk; /**< Rank of the low-rank matrix: -1 is dense, otherwise rank-rk matrix */
168  int rkmax; /**< Leading dimension of the matrix u */
169  void *u; /**< Contains the dense matrix if rk=-1, or the u factor from u vT representation */
170  void *v; /**< Not referenced if rk=-1, otherwise, the v factor */
172 
173 /**
174  * @brief Type of the functions to compress a dense block into a low-rank form.
175  */
177  const void *, pastix_int_t, pastix_lrblock_t * );
178 
179 /**
180  * @brief Array of pointers to the multiple arithmetic and algorithmic variants of ge2lr
181  */
183 
184 /**
185  * @brief Type of the functions to add two low-rank blocks together.
186  */
187 typedef pastix_fixdbl_t (*fct_rradd_t)( const pastix_lr_t *, pastix_trans_t, const void *,
191 
192 /**
193  * @brief Array of pointers to the multiple arithmetic and algorithmic variants of rradd
194  */
196 
197 /**
198  * @brief Structure to define the type of function to use for the low-rank
199  * kernels and their parameters.
200  */
201 typedef struct pastix_lr_s {
202  pastix_compress_when_t compress_when; /**< When to compress in the full solver */
203  pastix_compress_method_t compress_method; /**< Compression method */
204  pastix_int_t compress_min_width; /**< Minimum width to compress a supernode */
205  pastix_int_t compress_min_height; /**< Minimum height to compress an off-diagonal block */
206  int compress_preselect; /**< Enable/disable the compression of preselected blocks */
207  int use_reltol; /**< Enable/disable relative tolerance vs absolute one */
208  int ilu_lvl; /**< The ILU levels above which the blocks are originally compressed */
209  double tolerance; /**< Absolute compression tolerance */
210  fct_rradd_t core_rradd; /**< Recompression function */
211  fct_ge2lr_t core_ge2lr; /**< Compression function */
212 } pastix_lr_t;
213 
214 /**
215  * @brief Enum to define the type of block.
216  */
217 typedef enum memory_stats_e {
218  FR_InDiag = 0, /**< Full-rank block inside a diagonal block from the non-split partition */
219  FR_OffDiag = 1, /**< Full-rank block outside a diagonal block from the non-split partition */
220  LR_InDiag = 2, /**< Non selected Low-rank block inside a diagonal block from the non-split partition */
221  LR_InSele = 3, /**< Selected low-rank block inside a diagonal block from the non-split partition */
222  LR_OffDiag = 4, /**< Low-rank block outside a diagonal block from the non-split partition */
223  LR_DInD = 5, /**< Non-compressible diagonal block inside a diagonal block from the non-split partition */
224  MEMORY_STATS_SIZE
226 
227 /**
228  * @}
229  */
230 #endif /* _pastix_lowrank_h_ */
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
double pastix_fixdbl_t
Definition: datatypes.h:65
int compress_preselect
pastix_compress_method_t compress_method
double tolerance
pastix_int_t compress_min_width
fct_rradd_t core_rradd
fct_ge2lr_t core_ge2lr
pastix_int_t compress_min_height
pastix_compress_when_t compress_when
static pastix_int_t core_get_rklimit_end(pastix_int_t M, pastix_int_t N)
Compute the maximal rank accepted for a given matrix size for Just-In-Time strategy.
const char * compmeth_lgnames[PastixCompressMethodNbr]
List of long names for the compression kernels.
Definition: lowrank.c:35
struct pastix_lrblock_s pastix_lrblock_t
The block low-rank structure to hold a matrix in low-rank form.
const fct_rradd_t rraddMethods[PastixCompressMethodNbr][4]
Array of pointers to the multiple arithmetic and algorithmic variants of rradd.
Definition: lowrank.c:52
enum memory_stats_e memory_stats_t
Enum to define the type of block.
memory_stats_e
Enum to define the type of block.
const fct_ge2lr_t ge2lrMethods[PastixCompressMethodNbr][4]
Array of pointers to the multiple arithmetic and algorithmic variants of ge2lr.
Definition: lowrank.c:43
double pastix_lr_minratio
Define the minimal ratio for which we accept to compress a matrix into a low-rank form or not.
Definition: lowrank.c:24
pastix_int_t pastix_lr_ortho
Define the orthogonalization method.
Definition: lowrank.c:25
static pastix_int_t core_get_rklimit_max(pastix_int_t M, pastix_int_t N)
Compute the maximal rank accepted for a given matrix size for testings.
pastix_fixdbl_t(* fct_rradd_t)(const pastix_lr_t *, pastix_trans_t, const void *, pastix_int_t, pastix_int_t, const pastix_lrblock_t *, pastix_int_t, pastix_int_t, pastix_lrblock_t *, pastix_int_t, pastix_int_t)
Type of the functions to add two low-rank blocks together.
pastix_int_t(* core_get_rklimit)(pastix_int_t, pastix_int_t)
Compute the maximal rank accepted for a given matrix size. The pointer is set according to the low-ra...
Definition: kernels_trace.c:46
static pastix_int_t core_get_rklimit_test(pastix_int_t M, pastix_int_t N)
TODO.
pastix_fixdbl_t(* fct_ge2lr_t)(int, pastix_fixdbl_t, pastix_int_t, pastix_int_t, pastix_int_t, const void *, pastix_int_t, pastix_lrblock_t *)
Type of the functions to compress a dense block into a low-rank form.
const char * compmeth_shnames[PastixCompressMethodNbr]
List of short names for the compression kernels.
Definition: lowrank.c:27
struct pastix_lr_s pastix_lr_t
Structure to define the type of function to use for the low-rank kernels and their parameters.
static pastix_int_t core_get_rklimit_begin(pastix_int_t M, pastix_int_t N)
Compute the maximal rank accepted for a given matrix size for Minimal-Memory strategy.
@ FR_InDiag
@ LR_DInD
@ LR_InSele
@ FR_OffDiag
@ LR_InDiag
@ LR_OffDiag
Structure to define the type of function to use for the low-rank kernels and their parameters.
The block low-rank structure to hold a matrix in low-rank form.
enum pastix_compress_when_e pastix_compress_when_t
Compression strategy available for IPARM_COMPRESS_WHEN parameter.
enum pastix_compress_method_e pastix_compress_method_t
Compression method available for IPARM_COMPRESS_METHOD parameter.
enum pastix_trans_e pastix_trans_t
Transpostion.
@ PastixCompressMethodNbr
Definition: api.h:400