Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Superludist_FunctionMap.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Amesos2: Templated Direct Sparse Solver Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
52
53#ifndef AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
54#define AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
55
56#ifdef HAVE_TEUCHOS_COMPLEX
57#include <complex>
58#endif
59
60#include "Amesos2_config.h"
62#include "Amesos2_MatrixAdapter.hpp"
64
65
66// Declarations of SuperLU_DIST types and namespace are found in
67// Superludist_TypeMap.hpp
68
69#define AMESOS2_SLUD_GET_DIAG_SCALE(eq) (((eq)=='N') ? SLUD::NOEQUIL : ((eq)=='R') ? SLUD::ROW : ((eq)=='C') ? SLUD::COL : SLUD::BOTH)
70
71#define AMESOS2_SLUD_GET_EQUED(ds) (((ds)==SLUD::NOEQUIL) ? 'N' : ((ds)==SLUD::ROW) ? 'R' : ((ds)==SLUD::COL) ? 'C' : 'B')
72
73namespace Amesos2 {
74
75 template <class Matrix, class Vector> class Superludist;
76
77 SLUD::DiagScale_t get_diag_scale(char eq);
78 char get_equed(SLUD::DiagScale_t ds);
79
80
81 /* ==================== Specializations ====================
82 *
83 * \cond SuperLU_DIST_function_specializations
84 */
85
108 template <>
109 struct FunctionMap<Superludist,double>
110 {
111 typedef TypeMap<Superludist,double> type_map;
112
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,
128 int* info)
129 {
130 SLUD::D::pdgstrf(options, m, n, anorm, LU, grid, stat, info);
131 }
132
137#if (SUPERLU_DIST_MAJOR_VERSION > 7)
138 static void gstrs(SLUD::amesos2_superlu_dist_options_t* options,
139 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
140 SLUD::D::dScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
141 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
142 SLUD::int_t ldb, int nrhs, type_map::SOLVEstruct_t* solve_struct,
143 SLUD::SuperLUStat_t* stat, int* info)
144#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
145 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
146 SLUD::D::dScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
147 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
148 SLUD::int_t ldb, int nrhs, type_map::SOLVEstruct_t* solve_struct,
149 SLUD::SuperLUStat_t* stat, int* info)
150#else
151 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
152 SLUD::ScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
153 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
154 SLUD::int_t ldb, int nrhs, type_map::SOLVEstruct_t* solve_struct,
155 SLUD::SuperLUStat_t* stat, int* info)
156#endif
157 {
158#if (SUPERLU_DIST_MAJOR_VERSION > 7)
159 SLUD::D::pdgstrs(options, n, lu_struct, scale_perm_struct, grid, B, l_numrows,
160 fst_global_row, ldb, nrhs, solve_struct, stat, info);
161#else
162 SLUD::D::pdgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
163 fst_global_row, ldb, nrhs, solve_struct, stat, info);
164#endif
165 }
166
174#if (SUPERLU_DIST_MAJOR_VERSION > 7)
175 static void gstrs_Bglobal(SLUD::amesos2_superlu_dist_options_t* options,
176 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
177 SLUD::gridinfo_t* grid, type_map::type* B,
178 SLUD::int_t ldb, int nrhs,
179 SLUD::SuperLUStat_t* stat, int* info)
180
181 {
182 SLUD::D::pdgstrs_Bglobal(options, n, lu_struct, grid, B, ldb, nrhs, stat, info);
183 }
184#else
185 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
186 SLUD::gridinfo_t* grid, type_map::type* B,
187 SLUD::int_t ldb, int nrhs,
188 SLUD::SuperLUStat_t* stat, int* info)
189
190 {
191 SLUD::D::pdgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
192 }
193#endif
194
198#if (SUPERLU_DIST_MAJOR_VERSION > 7)
199 static void gsrfs(SLUD::amesos2_superlu_dist_options_t* options,
200 SLUD::int_t n, SLUD::SuperMatrix* A, double anorm,
201 type_map::LUstruct_t* lu_struct,
202 SLUD::D::dScalePermstruct_t* scale_perm,
203 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
204 type_map::type* X, SLUD::int_t ldx, int nrhs,
205 type_map::SOLVEstruct_t* solve_struct, double* berr,
206 SLUD::SuperLUStat_t* stat, int* info)
207#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
208 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A, double anorm,
209 type_map::LUstruct_t* lu_struct,
210 SLUD::D::dScalePermstruct_t* scale_perm,
211 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
212 type_map::type* X, SLUD::int_t ldx, int nrhs,
213 type_map::SOLVEstruct_t* solve_struct, double* berr,
214 SLUD::SuperLUStat_t* stat, int* info)
215#else
216 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A, double anorm,
217 type_map::LUstruct_t* lu_struct,
218 SLUD::ScalePermstruct_t* scale_perm,
219 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
220 type_map::type* X, SLUD::int_t ldx, int nrhs,
221 type_map::SOLVEstruct_t* solve_struct, double* berr,
222 SLUD::SuperLUStat_t* stat, int* info)
223#endif
224 {
225#if (SUPERLU_DIST_MAJOR_VERSION > 7)
226 SLUD::D::pdgsrfs(options, n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
227 X, ldx, nrhs, solve_struct, berr, stat, info);
228#else
229 SLUD::D::pdgsrfs(n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
230 X, ldx, nrhs, solve_struct, berr, stat, info);
231#endif
232 }
233
241#if (SUPERLU_DIST_MAJOR_VERSION > 7)
242 static void gsrfs_ABXglobal(SLUD::amesos2_superlu_dist_options_t* options,
243 SLUD::int_t n, SLUD::SuperMatrix* A, double anorm,
244 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
245 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
246 SLUD::int_t ldx, int nrhs, double* berr,
247 SLUD::SuperLUStat_t* stat, int* info)
248 {
249 SLUD::D::pdgsrfs_ABXglobal(options, n, A, anorm, lu_struct, grid, B, ldb,
250 X, ldx, nrhs, berr, stat, info);
251 }
252#else
253 static void gsrfs_ABXglobal(SLUD::int_t n, SLUD::SuperMatrix* A, double anorm,
254 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
255 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
256 SLUD::int_t ldx, int nrhs, double* berr,
257 SLUD::SuperLUStat_t* stat, int* info)
258 {
259 SLUD::D::pdgsrfs_ABXglobal(n, A, anorm, lu_struct, grid, B, ldb,
260 X, ldx, nrhs, berr, stat, info);
261 }
262#endif
263
268 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
269 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
270 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
271 type_map::type* nzval, SLUD::int_t* colind,
272 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
273 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
274 {
275 SLUD::D::dCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
276 l_numrows, fst_global_row,
277 nzval, colind, rowptr,
278 storage_t, data_t, mat_t);
279 }
280
288 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
289 SLUD::int_t numcols, SLUD::int_t nnz,
290 type_map::type* nzval, SLUD::int_t* rowind,
291 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
292 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
293 {
294 SLUD::D::dCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
295 nzval, rowind, colptr,
296 storage_t, data_t, mat_t);
297 }
298
307 static void create_Dense_Matrix(SLUD::SuperMatrix* X, int m, int n,
308 type_map::type* x, int ldx, SLUD::Stype_t stype,
309 SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
310 {
311 SLUD::D::dCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
312 }
313
314 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
315 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
316 type_map::type* X, int ldx, type_map::type* B,
317 int ldb, int nrhs, SLUD::gridinfo_t* grid)
318 {
319 SLUD::D::pdPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
320 X, ldx, B, ldb, nrhs, grid);
321 }
322
331 static void gsequ_loc(SLUD::SuperMatrix* A, double* r, double* c,
332 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info,
333 SLUD::gridinfo_t* grid)
334 {
335 SLUD::D::pdgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
336 }
337
342 static void gsequ(SLUD::SuperMatrix* A, double* r, double* c,
343 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info)
344 {
345 SLUD::D::dgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
346 }
347
351 static void laqgs_loc(SLUD::SuperMatrix* A, double* r, double* c,
352 double rowcnd, double colcnd, double amax,
353 SLUD::DiagScale_t* equed)
354 {
355 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
356 SLUD::D::pdlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
357 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
358 }
359
373 static void laqgs(SLUD::SuperMatrix* A, double* r, double* c,
374 double rowcnd, double colcnd, double amax, SLUD::DiagScale_t* equed)
375 {
376 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
377 SLUD::D::dlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
378 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
379 }
380
381 /*
382 * This version suitable for A in NCPformat
383 */
384#if (SUPERLU_DIST_MAJOR_VERSION > 7)
385 static void distribute(SLUD::amesos2_superlu_dist_options_t* options,
386 SLUD::fact_t fact, SLUD::int_t n,
387 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
388 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
389 {
390 SLUD::D::ddistribute(options, n, A, glu_freeable, lu, grid);
391 }
392#else
393 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
394 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
395 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
396 {
397 SLUD::D::ddistribute(fact, n, A, glu_freeable, lu, grid);
398 }
399#endif
400
401 /*
402 * This version suitable for A in NR_loc format.
403 *
404 * This routine should be used in the case where fact ==
405 * SamePattern_SameRowPerm, otherwise dist_psymbtonum should be
406 * called.o
407 */
408#if (SUPERLU_DIST_MAJOR_VERSION > 7)
409 static void pdistribute(SLUD::amesos2_superlu_dist_options_t* options,
410 SLUD::int_t n,
411 SLUD::SuperMatrix* A, SLUD::D::dScalePermstruct_t* scale_perm,
412 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
413 SLUD::gridinfo_t* grid)
414#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
415 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
416 SLUD::SuperMatrix* A, SLUD::D::dScalePermstruct_t* scale_perm,
417 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
418 SLUD::gridinfo_t* grid)
419#else
420 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
421 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
422 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
423 SLUD::gridinfo_t* grid)
424#endif
425 {
426#if (SUPERLU_DIST_MAJOR_VERSION > 7)
427 SLUD::D::pddistribute(options, n, A, scale_perm, glu_freeable, lu, grid);
428#else
429 SLUD::D::pddistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
430#endif
431 }
432
433 /*
434 * Distributes the input matrix A onto the 2D process grid based on
435 * the L/U graph data in pslu_freeable. On exit the struct lu
436 * contains the information necessary to perform a numeric
437 * factorization using gstrf.
438 *
439 * This routine should always be called with fact == DOFACT
440 */
441#if (SUPERLU_DIST_MAJOR_VERSION > 7)
442 static void dist_psymbtonum(SLUD::amesos2_superlu_dist_options_t* options,
443 SLUD::int_t n, SLUD::SuperMatrix* A,
444 SLUD::D::dScalePermstruct_t* scale_perm,
445 SLUD::Pslu_freeable_t* pslu_freeable,
446 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
447#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
448 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
449 SLUD::D::dScalePermstruct_t* scale_perm,
450 SLUD::Pslu_freeable_t* pslu_freeable,
451 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
452#else
453 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
454 SLUD::ScalePermstruct_t* scale_perm,
455 SLUD::Pslu_freeable_t* pslu_freeable,
456 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
457#endif
458 {
459#if (SUPERLU_DIST_MAJOR_VERSION > 7)
460 SLUD::D::ddist_psymbtonum(options, n, A, scale_perm, pslu_freeable, lu, grid);
461#else
462 SLUD::D::ddist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
463#endif
464 }
465
466 /*
467 * The parameter norm may be one of:
468 * - 'M' for the max absolute matrix entry value
469 * - '1' for the norm1(A)
470 * - 'I' for the normI(A)
471 * - 'F' for the Frobenius norm of A
472 */
473 static double plangs(char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
474 {
475 return SLUD::D::pdlangs(norm, A, grid);
476 }
477
478 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
479 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
480 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
481 type_map::SOLVEstruct_t* solve_struct)
482 {
483 SLUD::D::dSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
484 }
485
486 static void LUstructInit(SLUD::int_t m, SLUD::int_t n,
487 type_map::LUstruct_t* lu)
488 {
491#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
492 SLUD::D::dLUstructInit(n, lu);
493#elif defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
494 SLUD::D::LUstructInit(n, lu);
495#else
496#ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
497 SLUD::D::LUstructInit(n, lu);
498#else
499 SLUD::D::LUstructInit(m, n, lu);
500#endif
501#endif
502 }
503
504 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid,
505 type_map::LUstruct_t* lu)
506 {
507#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
508 SLUD::D::dDestroy_LU(m, grid, lu);
509#else
510 SLUD::D::Destroy_LU(m, grid, lu);
511#endif
512 }
513
514 static void LUstructFree(type_map::LUstruct_t* lu)
515 {
516#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
517 SLUD::D::dLUstructFree(lu);
518#else
519 SLUD::D::LUstructFree(lu);
520#endif
521 }
522
523 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
524 type_map::SOLVEstruct_t* solve_struct)
525 {
526 SLUD::D::dSolveFinalize(options, solve_struct);
527 }
528
529 static int ldperm_dist(int job, int n, SLUD::int_t nnz, SLUD::int_t colptr[], SLUD::int_t adjncy[],
530 double nzval[], SLUD::int_t *perm, double u[], double v[])
531 {
532 return SLUD::D::dldperm_dist(job, n, nnz, colptr, adjncy, nzval, perm, u, v);
533 }
534 };
535
536
537#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
538 /* The specializations for Teuchos::as<> for SLUD::complex and
539 * SLUD::doublecomplex are provided in Amesos2_Superlu_Type.hpp
540 */
541 template <>
542 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
543 {
544 typedef TypeMap<Superludist,std::complex<double> > type_map;
545
546 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options, int m, int n, double anorm,
547 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
548 SLUD::SuperLUStat_t* stat, int* info)
549 {
550 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
551 }
552
553#if (SUPERLU_DIST_MAJOR_VERSION > 7)
554 static void gstrs(SLUD::amesos2_superlu_dist_options_t* options,
555 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
556 SLUD::Z::zScalePermstruct_t* scale_perm_struct,
557 SLUD::gridinfo_t* grid, type_map::type* B,
558 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
559 SLUD::int_t ldb, int nrhs,
560 type_map::SOLVEstruct_t* solve_struct,
561 SLUD::SuperLUStat_t* stat, int* info)
562#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
563 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
564 SLUD::Z::zScalePermstruct_t* scale_perm_struct,
565 SLUD::gridinfo_t* grid, type_map::type* B,
566 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
567 SLUD::int_t ldb, int nrhs,
568 type_map::SOLVEstruct_t* solve_struct,
569 SLUD::SuperLUStat_t* stat, int* info)
570#else
571 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
572 SLUD::ScalePermstruct_t* scale_perm_struct,
573 SLUD::gridinfo_t* grid, type_map::type* B,
574 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
575 SLUD::int_t ldb, int nrhs,
576 type_map::SOLVEstruct_t* solve_struct,
577 SLUD::SuperLUStat_t* stat, int* info)
578#endif
579 {
580#if (SUPERLU_DIST_MAJOR_VERSION > 7)
581 SLUD::Z::pzgstrs(options, n, lu_struct, scale_perm_struct, grid, B, l_numrows,
582 fst_global_row, ldb, nrhs, solve_struct, stat, info);
583#else
584 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
585 fst_global_row, ldb, nrhs, solve_struct, stat, info);
586#endif
587 }
588
589#if (SUPERLU_DIST_MAJOR_VERSION > 7)
590 static void gstrs_Bglobal(SLUD::amesos2_superlu_dist_options_t* options,
591 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
592 SLUD::gridinfo_t* grid, type_map::type* B,
593 SLUD::int_t ldb, int nrhs, SLUD::SuperLUStat_t* stat, int* info)
594 {
595 SLUD::Z::pzgstrs_Bglobal(options,n, lu_struct, grid, B, ldb, nrhs, stat, info);
596 }
597#else
598 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
599 SLUD::gridinfo_t* grid, type_map::type* B,
600 SLUD::int_t ldb, int nrhs, SLUD::SuperLUStat_t* stat, int* info)
601 {
602 SLUD::Z::pzgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
603 }
604#endif
605
606 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
607 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
608 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
609 type_map::type* nzval, SLUD::int_t* colind,
610 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
611 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
612 {
613 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
614 l_numrows, fst_global_row,
615 nzval, colind, rowptr,
616 storage_t, data_t, mat_t);
617 }
618
619 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
620 SLUD::int_t numcols, SLUD::int_t nnz,
621 type_map::type* nzval, SLUD::int_t* rowind,
622 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
623 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
624 {
625 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
626 nzval, rowind, colptr,
627 storage_t, data_t, mat_t);
628 }
629
630 static void create_Dense_Matrix(SLUD::SuperMatrix* X, int m, int n,
631 TypeMap<Superludist,std::complex<double> >::type* x, int ldx,
632 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
633 {
634 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
635 }
636
637 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
638 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
639 type_map::type* X, int ldx,
640 type_map::type* B, int ldb,
641 int nrhs, SLUD::gridinfo_t* grid)
642 {
643 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
644 X, ldx, B, ldb, nrhs, grid);
645 }
646
647 static void gsequ_loc(SLUD::SuperMatrix* A, double* r, double* c,
648 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info,
649 SLUD::gridinfo_t* grid)
650 {
651 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
652 }
653
654 static void gsequ(SLUD::SuperMatrix* A, double* r, double* c,
655 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info)
656 {
657 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
658 }
659
660 static void laqgs_loc(SLUD::SuperMatrix* A, double* r, double* c,
661 double rowcnd, double colcnd, double amax, SLUD::DiagScale_t* equed)
662 {
663 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
664 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
665 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
666 }
667
668 static void laqgs(SLUD::SuperMatrix* A, double* r, double* c,
669 double rowcnd, double colcnd, double amax, SLUD::DiagScale_t* equed)
670 {
671 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
672 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
673 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
674 }
675
676#if (SUPERLU_DIST_MAJOR_VERSION > 7)
677 static void distribute(SLUD::amesos2_superlu_dist_options_t* options,
678 SLUD::int_t n,
679 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
680 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
681 {
682 SLUD::Z::zdistribute(options, n, A, glu_freeable, lu, grid);
683 }
684#else
685 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
686 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
687 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
688 {
689 SLUD::Z::zdistribute(fact, n, A, glu_freeable, lu, grid);
690 }
691#endif
692
693#if (SUPERLU_DIST_MAJOR_VERSION > 7)
694 static void pdistribute(SLUD::amesos2_superlu_dist_options_t* options,
695 SLUD::int_t n,
696 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
697 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
698 SLUD::gridinfo_t* grid)
699#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
700 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
701 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
702 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
703 SLUD::gridinfo_t* grid)
704#else
705 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
706 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
707 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
708 SLUD::gridinfo_t* grid)
709#endif
710 {
711#if (SUPERLU_DIST_MAJOR_VERSION > 7)
712 SLUD::Z::pzdistribute(options, n, A, scale_perm, glu_freeable, lu, grid);
713#else
714 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
715#endif
716 }
717
718#if (SUPERLU_DIST_MAJOR_VERSION > 7)
719 static void dist_psymbtonum(SLUD::amesos2_superlu_dist_options_t* options,
720 SLUD::int_t n,
721 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
722 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
723 SLUD::gridinfo_t* grid)
724#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
725 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
726 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
727 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
728 SLUD::gridinfo_t* grid)
729#else
730 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
731 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
732 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
733 SLUD::gridinfo_t* grid)
734#endif
735 {
736#if (SUPERLU_DIST_MAJOR_VERSION > 7)
737 SLUD::Z::zdist_psymbtonum(options, n, A, scale_perm, pslu_freeable, lu, grid);
738#else
739 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
740#endif
741 }
742
743 static double plangs(char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
744 {
745 return SLUD::Z::pzlangs(norm, A, grid);
746 }
747
748 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
749 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
750 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
751 type_map::SOLVEstruct_t* solve_struct)
752 {
753 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
754 }
755
756 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
757 {
760#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
761 SLUD::Z::zLUstructInit(n, lu);
762#elif defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
763 SLUD::Z::LUstructInit(n, lu);
764#else
765#ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
766 SLUD::Z::LUstructInit(n, lu);
767#else
768 SLUD::Z::LUstructInit(m, n, lu);
769#endif
770#endif
771 }
772
773 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
774 {
775#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
776 SLUD::Z::zDestroy_LU(m, grid, lu);
777#else
778 SLUD::Z::Destroy_LU(m, grid, lu);
779#endif
780 }
781
782 static void LUstructFree(type_map::LUstruct_t* lu)
783 {
784#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
785 SLUD::Z::zLUstructFree(lu);
786#else
787 SLUD::Z::LUstructFree(lu);
788#endif
789 }
790
791 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
792 type_map::SOLVEstruct_t* solve_struct)
793 {
794 SLUD::Z::zSolveFinalize(options, solve_struct);
795 }
796
797 static int ldperm_dist(int job, int n, SLUD::int_t nnz, SLUD::int_t colptr[], SLUD::int_t adjncy[],
798 SLUD::Z::doublecomplex nzval[], SLUD::int_t *perm, double u[], double v[])
799 {
800 return SLUD::Z::zldperm_dist(job, n, nnz, colptr, adjncy, nzval, perm, u, v);
801 }
802 };
803#endif // HAVE_TEUCHOS_COMPLEX
804
805} // end namespace Amesos2
806
807
808#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.
Amesos2 interface to the distributed memory version of SuperLU.
Definition Amesos2_Superludist_decl.hpp:91
Passes functions to TPL functions based on type.
Definition Amesos2_FunctionMap.hpp:77