53 #ifndef AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
54 #define AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
56 #ifdef HAVE_TEUCHOS_COMPLEX
60 #include "Amesos2_config.h"
62 #include "Amesos2_MatrixAdapter.hpp"
69 #define AMESOS2_SLUD_GET_DIAG_SCALE(eq) (((eq)=='N') ? SLUD::NOEQUIL : ((eq)=='R') ? SLUD::ROW : ((eq)=='C') ? SLUD::COL : SLUD::BOTH)
71 #define AMESOS2_SLUD_GET_EQUED(ds) (((ds)==SLUD::NOEQUIL) ? 'N' : ((ds)==SLUD::ROW) ? 'R' : ((ds)==SLUD::COL) ? 'C' : 'B')
75 template <
class Matrix,
class Vector>
class Superludist;
77 SLUD::DiagScale_t get_diag_scale(
char eq);
78 char get_equed(SLUD::DiagScale_t ds);
109 struct FunctionMap<Superludist,double>
111 typedef TypeMap<Superludist,double> type_map;
126 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options,
int m,
int n,
double anorm,
127 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid, SLUD::SuperLUStat_t* stat,
130 SLUD::D::pdgstrf(options, m, n, anorm, LU, grid, stat, info);
137 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
138 SLUD::ScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
139 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
140 SLUD::int_t ldb,
int nrhs, type_map::SOLVEstruct_t* solve_struct,
141 SLUD::SuperLUStat_t* stat,
int* info)
143 SLUD::D::pdgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
144 fst_global_row, ldb, nrhs, solve_struct, stat, info);
154 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
155 SLUD::gridinfo_t* grid, type_map::type* B,
156 SLUD::int_t ldb,
int nrhs,
157 SLUD::SuperLUStat_t* stat,
int* info)
159 SLUD::D::pdgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
165 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
166 type_map::LUstruct_t* lu_struct,
167 SLUD::ScalePermstruct_t* scale_perm,
168 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
169 type_map::type* X, SLUD::int_t ldx,
int nrhs,
170 type_map::SOLVEstruct_t* solve_struct,
double* berr,
171 SLUD::SuperLUStat_t* stat,
int* info)
173 SLUD::D::pdgsrfs(n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
174 X, ldx, nrhs, solve_struct, berr, stat, info);
184 static void gsrfs_ABXglobal(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
185 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
186 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
187 SLUD::int_t ldx,
int nrhs,
double* berr,
188 SLUD::SuperLUStat_t* stat,
int* info)
190 SLUD::D::pdgsrfs_ABXglobal(n, A, anorm, lu_struct, grid, B, ldb,
191 X, ldx, nrhs, berr, stat, info);
198 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
199 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
200 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
201 type_map::type* nzval, SLUD::int_t* colind,
202 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
203 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
205 SLUD::D::dCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
206 l_numrows, fst_global_row,
207 nzval, colind, rowptr,
208 storage_t, data_t, mat_t);
218 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
219 SLUD::int_t numcols, SLUD::int_t nnz,
220 type_map::type* nzval, SLUD::int_t* rowind,
221 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
222 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
224 SLUD::D::dCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
225 nzval, rowind, colptr,
226 storage_t, data_t, mat_t);
237 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
238 type_map::type* x,
int ldx, SLUD::Stype_t stype,
239 SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
241 SLUD::D::dCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
244 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
245 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
246 type_map::type* X,
int ldx, type_map::type* B,
247 int ldb,
int nrhs, SLUD::gridinfo_t* grid)
249 SLUD::D::pdPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
250 X, ldx, B, ldb, nrhs, grid);
261 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
262 double* rowcnd,
double* colcnd,
double* amax,
int* info,
263 SLUD::gridinfo_t* grid)
265 SLUD::D::pdgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
272 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
273 double* rowcnd,
double* colcnd,
double* amax,
int* info)
275 SLUD::D::dgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
281 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
282 double rowcnd,
double colcnd,
double amax,
283 SLUD::DiagScale_t* equed)
285 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
286 SLUD::D::pdlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
287 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
303 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
304 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
306 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
307 SLUD::D::dlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
308 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
314 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
315 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
316 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
318 SLUD::D::ddistribute(fact, n, A, glu_freeable, lu, grid);
328 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
329 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
330 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
331 SLUD::gridinfo_t* grid)
333 SLUD::D::pddistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
344 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
345 SLUD::ScalePermstruct_t* scale_perm,
346 SLUD::Pslu_freeable_t* pslu_freeable,
347 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
349 SLUD::D::ddist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
359 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
361 return SLUD::D::pdlangs(norm, A, grid);
364 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
365 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
366 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
367 type_map::SOLVEstruct_t* solve_struct)
369 SLUD::D::dSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
372 static void LUstructInit(SLUD::int_t m, SLUD::int_t n,
373 type_map::LUstruct_t* lu)
377 #if defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
378 SLUD::D::LUstructInit(n, lu);
380 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
381 SLUD::D::LUstructInit(n, lu);
383 SLUD::D::LUstructInit(m, n, lu);
388 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid,
389 type_map::LUstruct_t* lu)
391 SLUD::D::Destroy_LU(m, grid, lu);
394 static void LUstructFree(type_map::LUstruct_t* lu)
396 SLUD::D::LUstructFree(lu);
399 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
400 type_map::SOLVEstruct_t* solve_struct)
402 SLUD::D::dSolveFinalize(options, solve_struct);
407 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
412 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
414 typedef TypeMap<Superludist,std::complex<double> > type_map;
416 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options,
int m,
int n,
double anorm,
417 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
418 SLUD::SuperLUStat_t* stat,
int* info)
420 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
423 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
424 SLUD::ScalePermstruct_t* scale_perm_struct,
425 SLUD::gridinfo_t* grid, type_map::type* B,
426 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
427 SLUD::int_t ldb,
int nrhs,
428 type_map::SOLVEstruct_t* solve_struct,
429 SLUD::SuperLUStat_t* stat,
int* info)
431 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
432 fst_global_row, ldb, nrhs, solve_struct, stat, info);
435 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
436 SLUD::gridinfo_t* grid, type_map::type* B,
437 SLUD::int_t ldb,
int nrhs, SLUD::SuperLUStat_t* stat,
int* info)
439 SLUD::Z::pzgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
442 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
443 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
444 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
445 type_map::type* nzval, SLUD::int_t* colind,
446 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
447 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
449 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
450 l_numrows, fst_global_row,
451 nzval, colind, rowptr,
452 storage_t, data_t, mat_t);
455 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
456 SLUD::int_t numcols, SLUD::int_t nnz,
457 type_map::type* nzval, SLUD::int_t* rowind,
458 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
459 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
461 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
462 nzval, rowind, colptr,
463 storage_t, data_t, mat_t);
466 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
467 TypeMap<Superludist,std::complex<double> >::type* x,
int ldx,
468 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
470 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
473 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
474 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
475 type_map::type* X,
int ldx,
476 type_map::type* B,
int ldb,
477 int nrhs, SLUD::gridinfo_t* grid)
479 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
480 X, ldx, B, ldb, nrhs, grid);
483 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
484 double* rowcnd,
double* colcnd,
double* amax,
int* info,
485 SLUD::gridinfo_t* grid)
487 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
490 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
491 double* rowcnd,
double* colcnd,
double* amax,
int* info)
493 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
496 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
497 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
499 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
500 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
501 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
504 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
505 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
507 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
508 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
509 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
512 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
513 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
514 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
516 SLUD::Z::zdistribute(fact, n, A, glu_freeable, lu, grid);
519 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
520 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
521 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
522 SLUD::gridinfo_t* grid)
524 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
527 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
528 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
529 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
530 SLUD::gridinfo_t* grid)
532 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
535 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
537 return SLUD::Z::pzlangs(norm, A, grid);
540 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
541 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
542 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
543 type_map::SOLVEstruct_t* solve_struct)
545 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
548 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
552 #if defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
553 SLUD::Z::LUstructInit(n, lu);
555 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
556 SLUD::Z::LUstructInit(n, lu);
558 SLUD::Z::LUstructInit(m, n, lu);
563 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
565 SLUD::Z::Destroy_LU(m, grid, lu);
568 static void LUstructFree(type_map::LUstruct_t* lu)
570 SLUD::Z::LUstructFree(lu);
573 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
574 type_map::SOLVEstruct_t* solve_struct)
576 SLUD::Z::zSolveFinalize(options, solve_struct);
579 #endif // HAVE_TEUCHOS_COMPLEX
584 #endif // AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
Declaration of Function mapping class for Amesos2.
Provides definition of SuperLU_DIST types as well as conversions and type traits. ...