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 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
138 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
139 SLUD::D::dScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
140 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
141 SLUD::int_t ldb,
int nrhs, type_map::SOLVEstruct_t* solve_struct,
142 SLUD::SuperLUStat_t* stat,
int* info)
144 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
145 SLUD::ScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
146 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
147 SLUD::int_t ldb,
int nrhs, type_map::SOLVEstruct_t* solve_struct,
148 SLUD::SuperLUStat_t* stat,
int* info)
151 SLUD::D::pdgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
152 fst_global_row, ldb, nrhs, solve_struct, stat, info);
162 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
163 SLUD::gridinfo_t* grid, type_map::type* B,
164 SLUD::int_t ldb,
int nrhs,
165 SLUD::SuperLUStat_t* stat,
int* info)
167 SLUD::D::pdgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
173 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
174 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
175 type_map::LUstruct_t* lu_struct,
176 SLUD::D::dScalePermstruct_t* scale_perm,
177 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
178 type_map::type* X, SLUD::int_t ldx,
int nrhs,
179 type_map::SOLVEstruct_t* solve_struct,
double* berr,
180 SLUD::SuperLUStat_t* stat,
int* info)
182 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
183 type_map::LUstruct_t* lu_struct,
184 SLUD::ScalePermstruct_t* scale_perm,
185 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
186 type_map::type* X, SLUD::int_t ldx,
int nrhs,
187 type_map::SOLVEstruct_t* solve_struct,
double* berr,
188 SLUD::SuperLUStat_t* stat,
int* info)
191 SLUD::D::pdgsrfs(n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
192 X, ldx, nrhs, solve_struct, berr, stat, info);
202 static void gsrfs_ABXglobal(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
203 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
204 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
205 SLUD::int_t ldx,
int nrhs,
double* berr,
206 SLUD::SuperLUStat_t* stat,
int* info)
208 SLUD::D::pdgsrfs_ABXglobal(n, A, anorm, lu_struct, grid, B, ldb,
209 X, ldx, nrhs, berr, stat, info);
216 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
217 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
218 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
219 type_map::type* nzval, SLUD::int_t* colind,
220 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
221 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
223 SLUD::D::dCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
224 l_numrows, fst_global_row,
225 nzval, colind, rowptr,
226 storage_t, data_t, mat_t);
236 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
237 SLUD::int_t numcols, SLUD::int_t nnz,
238 type_map::type* nzval, SLUD::int_t* rowind,
239 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
240 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
242 SLUD::D::dCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
243 nzval, rowind, colptr,
244 storage_t, data_t, mat_t);
255 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
256 type_map::type* x,
int ldx, SLUD::Stype_t stype,
257 SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
259 SLUD::D::dCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
262 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
263 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
264 type_map::type* X,
int ldx, type_map::type* B,
265 int ldb,
int nrhs, SLUD::gridinfo_t* grid)
267 SLUD::D::pdPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
268 X, ldx, B, ldb, nrhs, grid);
279 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
280 double* rowcnd,
double* colcnd,
double* amax, SLUD::int_t* info,
281 SLUD::gridinfo_t* grid)
283 SLUD::D::pdgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
290 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
291 double* rowcnd,
double* colcnd,
double* amax, SLUD::int_t* info)
293 SLUD::D::dgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
299 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
300 double rowcnd,
double colcnd,
double amax,
301 SLUD::DiagScale_t* equed)
303 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
304 SLUD::D::pdlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
305 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
321 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
322 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
324 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
325 SLUD::D::dlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
326 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
332 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
333 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
334 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
336 SLUD::D::ddistribute(fact, n, A, glu_freeable, lu, grid);
346 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
347 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
348 SLUD::SuperMatrix* A, SLUD::D::dScalePermstruct_t* scale_perm,
349 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
350 SLUD::gridinfo_t* grid)
352 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
353 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
354 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
355 SLUD::gridinfo_t* grid)
358 SLUD::D::pddistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
369 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
370 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
371 SLUD::D::dScalePermstruct_t* scale_perm,
372 SLUD::Pslu_freeable_t* pslu_freeable,
373 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
375 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
376 SLUD::ScalePermstruct_t* scale_perm,
377 SLUD::Pslu_freeable_t* pslu_freeable,
378 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
381 SLUD::D::ddist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
391 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
393 return SLUD::D::pdlangs(norm, A, grid);
396 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
397 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
398 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
399 type_map::SOLVEstruct_t* solve_struct)
401 SLUD::D::dSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
404 static void LUstructInit(SLUD::int_t m, SLUD::int_t n,
405 type_map::LUstruct_t* lu)
409 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
410 SLUD::D::dLUstructInit(n, lu);
411 #elif defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
412 SLUD::D::LUstructInit(n, lu);
414 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
415 SLUD::D::LUstructInit(n, lu);
417 SLUD::D::LUstructInit(m, n, lu);
422 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid,
423 type_map::LUstruct_t* lu)
425 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
426 SLUD::D::dDestroy_LU(m, grid, lu);
428 SLUD::D::Destroy_LU(m, grid, lu);
432 static void LUstructFree(type_map::LUstruct_t* lu)
434 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
435 SLUD::D::dLUstructFree(lu);
437 SLUD::D::LUstructFree(lu);
441 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
442 type_map::SOLVEstruct_t* solve_struct)
444 SLUD::D::dSolveFinalize(options, solve_struct);
449 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
454 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
456 typedef TypeMap<Superludist,std::complex<double> > type_map;
458 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options,
int m,
int n,
double anorm,
459 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
460 SLUD::SuperLUStat_t* stat,
int* info)
462 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
465 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
466 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
467 SLUD::Z::zScalePermstruct_t* scale_perm_struct,
468 SLUD::gridinfo_t* grid, type_map::type* B,
469 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
470 SLUD::int_t ldb,
int nrhs,
471 type_map::SOLVEstruct_t* solve_struct,
472 SLUD::SuperLUStat_t* stat,
int* info)
474 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
475 SLUD::ScalePermstruct_t* scale_perm_struct,
476 SLUD::gridinfo_t* grid, type_map::type* B,
477 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
478 SLUD::int_t ldb,
int nrhs,
479 type_map::SOLVEstruct_t* solve_struct,
482 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
483 fst_global_row, ldb, nrhs, solve_struct, stat, info);
486 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
487 SLUD::gridinfo_t* grid, type_map::type* B,
488 SLUD::int_t ldb,
int nrhs, SLUD::SuperLUStat_t* stat,
int* info)
490 SLUD::Z::pzgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
493 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
494 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
495 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
496 type_map::type* nzval, SLUD::int_t* colind,
497 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
498 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
500 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
501 l_numrows, fst_global_row,
502 nzval, colind, rowptr,
503 storage_t, data_t, mat_t);
506 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
507 SLUD::int_t numcols, SLUD::int_t nnz,
508 type_map::type* nzval, SLUD::int_t* rowind,
509 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
510 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
512 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
513 nzval, rowind, colptr,
514 storage_t, data_t, mat_t);
517 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
518 TypeMap<Superludist,std::complex<double> >::type* x,
int ldx,
519 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
521 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
524 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
525 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
526 type_map::type* X,
int ldx,
527 type_map::type* B,
int ldb,
528 int nrhs, SLUD::gridinfo_t* grid)
530 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
531 X, ldx, B, ldb, nrhs, grid);
534 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
535 double* rowcnd,
double* colcnd,
double* amax,
int* info,
536 SLUD::gridinfo_t* grid)
538 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
541 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
542 double* rowcnd,
double* colcnd,
double* amax,
int* info)
544 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
547 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
548 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
550 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
551 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
552 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
555 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
556 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
558 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
559 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
560 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
563 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
564 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
565 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
567 SLUD::Z::zdistribute(fact, n, A, glu_freeable, lu, grid);
570 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
571 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
572 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
573 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
574 SLUD::gridinfo_t* grid)
576 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
577 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
578 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
579 SLUD::gridinfo_t* grid)
582 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
585 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
586 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
587 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
588 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
589 SLUD::gridinfo_t* grid)
591 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
592 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
593 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
594 SLUD::gridinfo_t* grid)
597 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
600 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
602 return SLUD::Z::pzlangs(norm, A, grid);
605 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
606 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
607 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
608 type_map::SOLVEstruct_t* solve_struct)
610 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
613 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
617 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
618 SLUD::Z::zLUstructInit(n, lu);
619 #elif defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
620 SLUD::Z::LUstructInit(n, lu);
622 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
623 SLUD::Z::LUstructInit(n, lu);
625 SLUD::Z::LUstructInit(m, n, lu);
630 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
632 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
633 SLUD::Z::zDestroy_LU(m, grid, lu);
635 SLUD::Z::Destroy_LU(m, grid, lu);
639 static void LUstructFree(type_map::LUstruct_t* lu)
641 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
642 SLUD::Z::zLUstructFree(lu);
644 SLUD::Z::LUstructFree(lu);
648 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
649 type_map::SOLVEstruct_t* solve_struct)
651 SLUD::Z::zSolveFinalize(options, solve_struct);
654 #endif // HAVE_TEUCHOS_COMPLEX
659 #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. ...