StrumpackSparseSolver.h
1 /*
2  * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3  * Regents of the University of California, through Lawrence Berkeley
4  * National Laboratory (subject to receipt of any required approvals
5  * from the U.S. Dept. of Energy). All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE. This software is owned by the U.S. Department of Energy. As
12  * such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly. Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25  * (Lawrence Berkeley National Lab, Computational Research
26  * Division).
27  *
28  */
29 #ifndef STRUMPACK_SPARSE_SOLVER_H
30 #define STRUMPACK_SPARSE_SOLVER_H
31 
32 #include <stdint.h>
33 #include "StrumpackConfig.hpp"
34 
35 #if defined(STRUMPACK_USE_MPI)
36 #define OMPI_SKIP_MPICXX 1
37 #include "mpi.h"
38 #endif
39 
45 typedef enum
46  {
47  STRUMPACK_FLOAT,
48  STRUMPACK_DOUBLE,
49  STRUMPACK_FLOATCOMPLEX,
50  STRUMPACK_DOUBLECOMPLEX,
51  STRUMPACK_FLOAT_64,
52  STRUMPACK_DOUBLE_64,
53  STRUMPACK_FLOATCOMPLEX_64,
54  STRUMPACK_DOUBLECOMPLEX_64
55  } STRUMPACK_PRECISION;
56 
61 typedef enum
62  {
63  STRUMPACK_MT,
64  STRUMPACK_MPI_DIST
65  } STRUMPACK_INTERFACE;
66 
67 typedef struct {
68  void* solver;
69  STRUMPACK_PRECISION precision;
70  STRUMPACK_INTERFACE interface;
72 
73 typedef enum
74  {
75  STRUMPACK_NONE=0,
76  STRUMPACK_HSS=1,
77  STRUMPACK_BLR=2,
78  STRUMPACK_HODLR=3,
79  STRUMPACK_BLR_HODLR=4,
80  STRUMPACK_ZFP_BLR_HODLR=5,
81  STRUMPACK_LOSSLESS=6,
82  STRUMPACK_LOSSY=7
83  } STRUMPACK_COMPRESSION_TYPE;
84 
85 typedef enum
86  {
87  STRUMPACK_MATCHING_NONE=0,
88  STRUMPACK_MATCHING_MAX_CARDINALITY=1,
89  STRUMPACK_MATCHING_MAX_SMALLEST_DIAGONAL=2,
90  STRUMPACK_MATCHING_MAX_SMALLEST_DIAGONAL_2=3,
91  STRUMPACK_MATCHING_MAX_DIAGONAL_SUM=4,
92  STRUMPACK_MATCHING_MAX_DIAGONAL_PRODUCT_SCALING=5,
93  STRUMPACK_MATCHING_COMBBLAS=6
94  } STRUMPACK_MATCHING_JOB;
95 
96 typedef enum
97  {
98  STRUMPACK_NATURAL=0,
99  STRUMPACK_METIS=1,
100  STRUMPACK_PARMETIS=2,
101  STRUMPACK_SCOTCH=3,
102  STRUMPACK_PTSCOTCH=4,
103  STRUMPACK_RCM=5,
104  STRUMPACK_GEOMETRIC=6
105  } STRUMPACK_REORDERING_STRATEGY;
106 
107 typedef enum
108  {
109  STRUMPACK_CLASSICAL=0,
110  STRUMPACK_MODIFIED=1
111  } STRUMPACK_GRAM_SCHMIDT_TYPE;
112 
113 typedef enum
114  {
115  STRUMPACK_NORMAL=0,
116  STRUMPACK_UNIFORM=1
117  } STRUMPACK_RANDOM_DISTRIBUTION;
118 
119 typedef enum
120  {
121  STRUMPACK_LINEAR=0,
122  STRUMPACK_MERSENNE=1
123  } STRUMPACK_RANDOM_ENGINE;
124 
125 typedef enum
126  {
127  STRUMPACK_AUTO=0,
128  STRUMPACK_DIRECT=1,
129  STRUMPACK_REFINE=2,
130  STRUMPACK_PREC_GMRES=3,
131  STRUMPACK_GMRES=4,
132  STRUMPACK_PREC_BICGSTAB=5,
133  STRUMPACK_BICGSTAB=6
134  } STRUMPACK_KRYLOV_SOLVER;
135 
136 typedef enum
137  {
138  STRUMPACK_SUCCESS=0,
139  STRUMPACK_MATRIX_NOT_SET=1,
140  STRUMPACK_REORDERING_ERROR=2
141  } STRUMPACK_RETURN_CODE;
142 
143 
144 #ifdef __cplusplus
145 extern "C" {
146 #endif
147 
148  void STRUMPACK_init_mt
149  (STRUMPACK_SparseSolver* S, STRUMPACK_PRECISION precision,
150  STRUMPACK_INTERFACE interface, int argc, char* argv[], int verbose);
151 
152 #if defined(STRUMPACK_USE_MPI)
153  void STRUMPACK_init
154  (STRUMPACK_SparseSolver* S, MPI_Comm comm, STRUMPACK_PRECISION precision,
155  STRUMPACK_INTERFACE interface, int argc, char* argv[], int verbose);
156 #endif
157 
158  void STRUMPACK_destroy(STRUMPACK_SparseSolver* S);
159 
160  void STRUMPACK_set_csr_matrix
161  (STRUMPACK_SparseSolver S, const void* N, const void* row_ptr,
162  const void* col_ind, const void* values, int symmetric_pattern);
163 
164  void STRUMPACK_update_csr_matrix_values
165  (STRUMPACK_SparseSolver S, const void* N, const void* row_ptr,
166  const void* col_ind, const void* values, int symmetric_pattern);
167 
168 #if defined(STRUMPACK_USE_MPI)
169  void STRUMPACK_set_distributed_csr_matrix
170  (STRUMPACK_SparseSolver S, const void* local_rows,
171  const void* row_ptr, const void* col_ind, const void* values,
172  const void* dist, int symmetric_pattern);
173 
174  void STRUMPACK_update_distributed_csr_matrix_values
175  (STRUMPACK_SparseSolver S, const void* local_rows,
176  const void* row_ptr, const void* col_ind, const void* values,
177  const void* dist, int symmetric_pattern);
178 
179 
180  void STRUMPACK_set_MPIAIJ_matrix
181  (STRUMPACK_SparseSolver S, const void* n,
182  const void* d_ptr, const void* d_ind, const void* d_val,
183  const void* o_ptr, const void* o_ind, const void* o_val,
184  const void* garray);
185 
186  void STRUMPACK_update_MPIAIJ_matrix_values
187  (STRUMPACK_SparseSolver S, const void* n,
188  const void* d_ptr, const void* d_ind, const void* d_val,
189  const void* o_ptr, const void* o_ind, const void* o_val,
190  const void* garray);
191 #endif
192 
193  STRUMPACK_RETURN_CODE STRUMPACK_solve
194  (STRUMPACK_SparseSolver S, const void* b, void* x, int use_initial_guess);
195 
196  STRUMPACK_RETURN_CODE STRUMPACK_matsolve
197  (STRUMPACK_SparseSolver S, int nrhs, const void* b, int ldb,
198  void* x, int ldx, int use_initial_guess);
199 
200  void STRUMPACK_set_from_options(STRUMPACK_SparseSolver S);
201 
202  STRUMPACK_RETURN_CODE STRUMPACK_reorder(STRUMPACK_SparseSolver S);
203 
204  STRUMPACK_RETURN_CODE STRUMPACK_reorder_regular
205  (STRUMPACK_SparseSolver S, int nx, int ny, int nz, int components, int width);
206 
207  STRUMPACK_RETURN_CODE STRUMPACK_factor(STRUMPACK_SparseSolver S);
208 
209  void STRUMPACK_move_to_gpu(STRUMPACK_SparseSolver S);
210 
211  void STRUMPACK_remove_from_gpu(STRUMPACK_SparseSolver S);
212 
213  void STRUMPACK_delete_factors(STRUMPACK_SparseSolver S);
214 
215 
216  /*************************************************************
217  ** Set options **********************************************
218  ************************************************************/
219  void STRUMPACK_set_verbose(STRUMPACK_SparseSolver S, int v);
220  void STRUMPACK_set_maxit(STRUMPACK_SparseSolver S, int maxit);
221  void STRUMPACK_set_gmres_restart(STRUMPACK_SparseSolver S, int m);
222  void STRUMPACK_set_rel_tol(STRUMPACK_SparseSolver S, double tol);
223  void STRUMPACK_set_abs_tol(STRUMPACK_SparseSolver S, double tol);
224  void STRUMPACK_set_nd_param(STRUMPACK_SparseSolver S, int nd_param);
225  void STRUMPACK_set_reordering_method(STRUMPACK_SparseSolver S, STRUMPACK_REORDERING_STRATEGY m);
226  void STRUMPACK_enable_METIS_NodeNDP(STRUMPACK_SparseSolver S);
227  void STRUMPACK_disable_METIS_NodeNDP(STRUMPACK_SparseSolver S);
228  void STRUMPACK_set_nx(STRUMPACK_SparseSolver S, int nx);
229  void STRUMPACK_set_ny(STRUMPACK_SparseSolver S, int ny);
230  void STRUMPACK_set_nz(STRUMPACK_SparseSolver S, int nz);
231  void STRUMPACK_set_components(STRUMPACK_SparseSolver S, int nc);
232  void STRUMPACK_set_separator_width(STRUMPACK_SparseSolver S, int w);
233  void STRUMPACK_set_GramSchmidt_type(STRUMPACK_SparseSolver S, STRUMPACK_GRAM_SCHMIDT_TYPE t);
234  void STRUMPACK_set_matching(STRUMPACK_SparseSolver S, STRUMPACK_MATCHING_JOB job);
235  void STRUMPACK_set_Krylov_solver(STRUMPACK_SparseSolver S, STRUMPACK_KRYLOV_SOLVER solver_type);
236  void STRUMPACK_enable_gpu(STRUMPACK_SparseSolver S);
237  void STRUMPACK_disable_gpu(STRUMPACK_SparseSolver S);
238  void STRUMPACK_set_compression(STRUMPACK_SparseSolver S, STRUMPACK_COMPRESSION_TYPE t);
239  void STRUMPACK_set_compression_min_sep_size(STRUMPACK_SparseSolver S, int size);
240  void STRUMPACK_set_compression_min_front_size(STRUMPACK_SparseSolver S, int size);
241  void STRUMPACK_set_compression_leaf_size(STRUMPACK_SparseSolver S, int size);
242  void STRUMPACK_set_compression_rel_tol(STRUMPACK_SparseSolver S, double rctol);
243  void STRUMPACK_set_compression_abs_tol(STRUMPACK_SparseSolver S, double actol);
244  void STRUMPACK_set_compression_butterfly_levels(STRUMPACK_SparseSolver S, int l);
245  void STRUMPACK_set_compression_lossy_precision(STRUMPACK_SparseSolver S, int p);
246 
247  /*************************************************************
248  ** Get options **********************************************
249  ************************************************************/
250  int STRUMPACK_verbose(STRUMPACK_SparseSolver S);
251  int STRUMPACK_maxit(STRUMPACK_SparseSolver S);
252  int STRUMPACK_get_gmres_restart(STRUMPACK_SparseSolver S);
253  double STRUMPACK_rel_tol(STRUMPACK_SparseSolver S);
254  double STRUMPACK_abs_tol(STRUMPACK_SparseSolver S);
255  int STRUMPACK_nd_param(STRUMPACK_SparseSolver S);
256  STRUMPACK_REORDERING_STRATEGY STRUMPACK_reordering_method(STRUMPACK_SparseSolver S);
257  int STRUMPACK_use_METIS_NodeNDP(STRUMPACK_SparseSolver S);
258  STRUMPACK_MATCHING_JOB STRUMPACK_matching(STRUMPACK_SparseSolver S);
259  STRUMPACK_GRAM_SCHMIDT_TYPE STRUMPACK_GramSchmidt_type(STRUMPACK_SparseSolver S);
260  STRUMPACK_KRYLOV_SOLVER STRUMPACK_Krylov_solver(STRUMPACK_SparseSolver S);
261  int STRUMPACK_use_gpu(STRUMPACK_SparseSolver S);
262  STRUMPACK_COMPRESSION_TYPE STRUMPACK_compression(STRUMPACK_SparseSolver S);
263  int STRUMPACK_compression_min_sep_size(STRUMPACK_SparseSolver S);
264  int STRUMPACK_compression_min_front_size(STRUMPACK_SparseSolver S);
265  int STRUMPACK_compression_leaf_size(STRUMPACK_SparseSolver S);
266  double STRUMPACK_compression_rel_tol(STRUMPACK_SparseSolver S);
267  double STRUMPACK_compression_abs_tol(STRUMPACK_SparseSolver S);
268  int STRUMPACK_compression_butterfly_levels(STRUMPACK_SparseSolver S);
269  int STRUMPACK_compression_lossy_precision(STRUMPACK_SparseSolver S);
270 
271  /*************************************************************
272  ** Get solve statistics *************************************
273  ************************************************************/
274  int STRUMPACK_its(STRUMPACK_SparseSolver S);
275  int STRUMPACK_rank(STRUMPACK_SparseSolver S);
276  long long STRUMPACK_factor_nonzeros(STRUMPACK_SparseSolver S);
277  long long STRUMPACK_factor_memory(STRUMPACK_SparseSolver S);
278 
279 
280 
281  /*************************************************************
282  ** Deprecated routines **************************************
283  ************************************************************/
284  void STRUMPACK_set_mc64job(STRUMPACK_SparseSolver S, int job);
285  int STRUMPACK_mc64job(STRUMPACK_SparseSolver S);
286  void STRUMPACK_enable_HSS(STRUMPACK_SparseSolver S);
287  void STRUMPACK_disable_HSS(STRUMPACK_SparseSolver S);
288  void STRUMPACK_set_HSS_min_front_size(STRUMPACK_SparseSolver S, int size);
289  void STRUMPACK_set_HSS_min_sep_size(STRUMPACK_SparseSolver S, int size);
290  void STRUMPACK_set_HSS_max_rank(STRUMPACK_SparseSolver S, int max_rank);
291  void STRUMPACK_set_HSS_leaf_size(STRUMPACK_SparseSolver S, int leaf_size);
292  void STRUMPACK_set_HSS_rel_tol(STRUMPACK_SparseSolver S, double rctol);
293  void STRUMPACK_set_HSS_abs_tol(STRUMPACK_SparseSolver S, double actol);
294  int use_HSS(STRUMPACK_SparseSolver S);
295  int STRUMPACK_HSS_min_front_size(STRUMPACK_SparseSolver S);
296  int STRUMPACK_HSS_min_sep_size(STRUMPACK_SparseSolver S);
297  int STRUMPACK_HSS_max_rank(STRUMPACK_SparseSolver S);
298  int STRUMPACK_HSS_leaf_size(STRUMPACK_SparseSolver S);
299  double STRUMPACK_HSS_rel_tol(STRUMPACK_SparseSolver S);
300  double STRUMPACK_HSS_abs_tol(STRUMPACK_SparseSolver S);
301 
302 #ifdef __cplusplus
303 }
304 #endif
305 
306 #endif
Definition: StrumpackSparseSolver.h:67