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_LOSSLESS=4,
80  STRUMPACK_LOSSY=5
81  } STRUMPACK_COMPRESSION_TYPE;
82 
83 typedef enum
84  {
85  STRUMPACK_MATCHING_NONE=0,
86  STRUMPACK_MATCHING_MAX_CARDINALITY=1,
87  STRUMPACK_MATCHING_MAX_SMALLEST_DIAGONAL=2,
88  STRUMPACK_MATCHING_MAX_SMALLEST_DIAGONAL_2=3,
89  STRUMPACK_MATCHING_MAX_DIAGONAL_SUM=4,
90  STRUMPACK_MATCHING_MAX_DIAGONAL_PRODUCT_SCALING=5,
91  STRUMPACK_MATCHING_COMBBLAS=6
92  } STRUMPACK_MATCHING_JOB;
93 
94 typedef enum
95  {
96  STRUMPACK_NATURAL=0,
97  STRUMPACK_METIS=1,
98  STRUMPACK_PARMETIS=2,
99  STRUMPACK_SCOTCH=3,
100  STRUMPACK_PTSCOTCH=4,
101  STRUMPACK_RCM=5,
102  STRUMPACK_GEOMETRIC=6
103  } STRUMPACK_REORDERING_STRATEGY;
104 
105 typedef enum
106  {
107  STRUMPACK_CLASSICAL=0,
108  STRUMPACK_MODIFIED=1
109  } STRUMPACK_GRAM_SCHMIDT_TYPE;
110 
111 typedef enum
112  {
113  STRUMPACK_NORMAL=0,
114  STRUMPACK_UNIFORM=1
115  } STRUMPACK_RANDOM_DISTRIBUTION;
116 
117 typedef enum
118  {
119  STRUMPACK_LINEAR=0,
120  STRUMPACK_MERSENNE=1
121  } STRUMPACK_RANDOM_ENGINE;
122 
123 typedef enum
124  {
125  STRUMPACK_AUTO=0,
126  STRUMPACK_DIRECT=1,
127  STRUMPACK_REFINE=2,
128  STRUMPACK_PREC_GMRES=3,
129  STRUMPACK_GMRES=4,
130  STRUMPACK_PREC_BICGSTAB=5,
131  STRUMPACK_BICGSTAB=6
132  } STRUMPACK_KRYLOV_SOLVER;
133 
134 typedef enum
135  {
136  STRUMPACK_SUCCESS=0,
137  STRUMPACK_MATRIX_NOT_SET=1,
138  STRUMPACK_REORDERING_ERROR=2
139  } STRUMPACK_RETURN_CODE;
140 
141 
142 #ifdef __cplusplus
143 extern "C" {
144 #endif
145 
146  void STRUMPACK_init_mt
147  (STRUMPACK_SparseSolver* S, STRUMPACK_PRECISION precision,
148  STRUMPACK_INTERFACE interface, int argc, char* argv[], int verbose);
149 
150 #if defined(STRUMPACK_USE_MPI)
151  void STRUMPACK_init
152  (STRUMPACK_SparseSolver* S, MPI_Comm comm, STRUMPACK_PRECISION precision,
153  STRUMPACK_INTERFACE interface, int argc, char* argv[], int verbose);
154 #endif
155 
156  void STRUMPACK_destroy(STRUMPACK_SparseSolver* S);
157 
158  void STRUMPACK_set_csr_matrix
159  (STRUMPACK_SparseSolver S, const void* N, const void* row_ptr,
160  const void* col_ind, const void* values, int symmetric_pattern);
161 
162  void STRUMPACK_update_csr_matrix_values
163  (STRUMPACK_SparseSolver S, const void* N, const void* row_ptr,
164  const void* col_ind, const void* values, int symmetric_pattern);
165 
166 #if defined(STRUMPACK_USE_MPI)
167  void STRUMPACK_set_distributed_csr_matrix
168  (STRUMPACK_SparseSolver S, const void* local_rows,
169  const void* row_ptr, const void* col_ind, const void* values,
170  const void* dist, int symmetric_pattern);
171 
172  void STRUMPACK_update_distributed_csr_matrix_values
173  (STRUMPACK_SparseSolver S, const void* local_rows,
174  const void* row_ptr, const void* col_ind, const void* values,
175  const void* dist, int symmetric_pattern);
176 
177 
178  void STRUMPACK_set_MPIAIJ_matrix
179  (STRUMPACK_SparseSolver S, const void* n,
180  const void* d_ptr, const void* d_ind, const void* d_val,
181  const void* o_ptr, const void* o_ind, const void* o_val,
182  const void* garray);
183 
184  void STRUMPACK_update_MPIAIJ_matrix_values
185  (STRUMPACK_SparseSolver S, const void* n,
186  const void* d_ptr, const void* d_ind, const void* d_val,
187  const void* o_ptr, const void* o_ind, const void* o_val,
188  const void* garray);
189 #endif
190 
191  STRUMPACK_RETURN_CODE STRUMPACK_solve
192  (STRUMPACK_SparseSolver S, const void* b, void* x, int use_initial_guess);
193 
194  void STRUMPACK_set_from_options(STRUMPACK_SparseSolver S);
195 
196  STRUMPACK_RETURN_CODE STRUMPACK_reorder(STRUMPACK_SparseSolver S);
197 
198  STRUMPACK_RETURN_CODE STRUMPACK_reorder_regular
199  (STRUMPACK_SparseSolver S, int nx, int ny, int nz);
200 
201  STRUMPACK_RETURN_CODE STRUMPACK_factor(STRUMPACK_SparseSolver S);
202 
203 
204  /*
205  TODO add
206  - routines to update the matrix values!!!!!
207  - solve with multiple rhs??!!!
208  */
209 
210  /*************************************************************
211  ** Set options **********************************************
212  ************************************************************/
213  void STRUMPACK_set_verbose(STRUMPACK_SparseSolver S, int v);
214  void STRUMPACK_set_maxit(STRUMPACK_SparseSolver S, int maxit);
215  void STRUMPACK_set_gmres_restart(STRUMPACK_SparseSolver S, int m);
216  void STRUMPACK_set_rel_tol(STRUMPACK_SparseSolver S, double tol);
217  void STRUMPACK_set_abs_tol(STRUMPACK_SparseSolver S, double tol);
218  void STRUMPACK_set_nd_param(STRUMPACK_SparseSolver S, int nd_param);
219  void STRUMPACK_set_reordering_method(STRUMPACK_SparseSolver S, STRUMPACK_REORDERING_STRATEGY m);
220  void STRUMPACK_set_GramSchmidt_type(STRUMPACK_SparseSolver S, STRUMPACK_GRAM_SCHMIDT_TYPE t);
221  void STRUMPACK_set_matching(STRUMPACK_SparseSolver S, STRUMPACK_MATCHING_JOB job);
222  void STRUMPACK_set_Krylov_solver(STRUMPACK_SparseSolver S, STRUMPACK_KRYLOV_SOLVER solver_type);
223  void STRUMPACK_enable_gpu(STRUMPACK_SparseSolver S);
224  void STRUMPACK_disable_gpu(STRUMPACK_SparseSolver S);
225  void STRUMPACK_set_compression(STRUMPACK_SparseSolver S, STRUMPACK_COMPRESSION_TYPE t);
226  void STRUMPACK_set_compression_min_sep_size(STRUMPACK_SparseSolver S, int size);
227  void STRUMPACK_set_compression_min_front_size(STRUMPACK_SparseSolver S, int size);
228  void STRUMPACK_set_compression_leaf_size(STRUMPACK_SparseSolver S, int size);
229  void STRUMPACK_set_compression_rel_tol(STRUMPACK_SparseSolver S, double rctol);
230  void STRUMPACK_set_compression_abs_tol(STRUMPACK_SparseSolver S, double actol);
231  void STRUMPACK_set_compression_butterfly_levels(STRUMPACK_SparseSolver S, int l);
232 
233  /*************************************************************
234  ** Get options **********************************************
235  ************************************************************/
236  int STRUMPACK_verbose(STRUMPACK_SparseSolver S);
237  int STRUMPACK_maxit(STRUMPACK_SparseSolver S);
238  int STRUMPACK_get_gmres_restart(STRUMPACK_SparseSolver S);
239  double STRUMPACK_rel_tol(STRUMPACK_SparseSolver S);
240  double STRUMPACK_abs_tol(STRUMPACK_SparseSolver S);
241  int STRUMPACK_nd_param(STRUMPACK_SparseSolver S);
242  STRUMPACK_REORDERING_STRATEGY STRUMPACK_reordering_method(STRUMPACK_SparseSolver S);
243  STRUMPACK_GRAM_SCHMIDT_TYPE STRUMPACK_GramSchmidt_type(STRUMPACK_SparseSolver S);
244  STRUMPACK_MATCHING_JOB STRUMPACK_matching(STRUMPACK_SparseSolver S);
245  STRUMPACK_KRYLOV_SOLVER STRUMPACK_Krylov_solver(STRUMPACK_SparseSolver S);
246  int STRUMPACK_use_gpu(STRUMPACK_SparseSolver S);
247  STRUMPACK_COMPRESSION_TYPE STRUMPACK_compression(STRUMPACK_SparseSolver S);
248  int STRUMPACK_compression_min_sep_size(STRUMPACK_SparseSolver S);
249  int STRUMPACK_compression_min_front_size(STRUMPACK_SparseSolver S);
250  int STRUMPACK_compression_leaf_size(STRUMPACK_SparseSolver S);
251  double STRUMPACK_compression_rel_tol(STRUMPACK_SparseSolver S);
252  double STRUMPACK_compression_abs_tol(STRUMPACK_SparseSolver S);
253  int STRUMPACK_compression_butterfly_levels(STRUMPACK_SparseSolver S);
254 
255  /*************************************************************
256  ** Get solve statistics *************************************
257  ************************************************************/
258  int STRUMPACK_its(STRUMPACK_SparseSolver S);
259  int STRUMPACK_rank(STRUMPACK_SparseSolver S);
260  long long STRUMPACK_factor_nonzeros(STRUMPACK_SparseSolver S);
261  long long STRUMPACK_factor_memory(STRUMPACK_SparseSolver S);
262 
263 
264 
265  /*************************************************************
266  ** Deprecated routines **************************************
267  ************************************************************/
268  void STRUMPACK_set_mc64job(STRUMPACK_SparseSolver S, int job);
269  int STRUMPACK_mc64job(STRUMPACK_SparseSolver S);
270  void STRUMPACK_enable_HSS(STRUMPACK_SparseSolver S);
271  void STRUMPACK_disable_HSS(STRUMPACK_SparseSolver S);
272  void STRUMPACK_set_HSS_min_front_size(STRUMPACK_SparseSolver S, int size);
273  void STRUMPACK_set_HSS_min_sep_size(STRUMPACK_SparseSolver S, int size);
274  void STRUMPACK_set_HSS_max_rank(STRUMPACK_SparseSolver S, int max_rank);
275  void STRUMPACK_set_HSS_leaf_size(STRUMPACK_SparseSolver S, int leaf_size);
276  void STRUMPACK_set_HSS_rel_tol(STRUMPACK_SparseSolver S, double rctol);
277  void STRUMPACK_set_HSS_abs_tol(STRUMPACK_SparseSolver S, double actol);
278  int use_HSS(STRUMPACK_SparseSolver S);
279  int STRUMPACK_HSS_min_front_size(STRUMPACK_SparseSolver S);
280  int STRUMPACK_HSS_min_sep_size(STRUMPACK_SparseSolver S);
281  int STRUMPACK_HSS_max_rank(STRUMPACK_SparseSolver S);
282  int STRUMPACK_HSS_leaf_size(STRUMPACK_SparseSolver S);
283  double STRUMPACK_HSS_rel_tol(STRUMPACK_SparseSolver S);
284  double STRUMPACK_HSS_abs_tol(STRUMPACK_SparseSolver S);
285 
286 #ifdef __cplusplus
287 }
288 #endif
289 
290 #endif
STRUMPACK_SparseSolver
Definition: StrumpackSparseSolver.h:67