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
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
530
531#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
532 /* The specializations for Teuchos::as<> for SLUD::complex and
533 * SLUD::doublecomplex are provided in Amesos2_Superlu_Type.hpp
534 */
535 template <>
536 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
537 {
538 typedef TypeMap<Superludist,std::complex<double> > type_map;
539
540 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options, int m, int n, double anorm,
541 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
542 SLUD::SuperLUStat_t* stat, int* info)
543 {
544 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
545 }
546
547#if (SUPERLU_DIST_MAJOR_VERSION > 7)
548 static void gstrs(SLUD::amesos2_superlu_dist_options_t* options,
549 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
550 SLUD::Z::zScalePermstruct_t* scale_perm_struct,
551 SLUD::gridinfo_t* grid, type_map::type* B,
552 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
553 SLUD::int_t ldb, int nrhs,
554 type_map::SOLVEstruct_t* solve_struct,
555 SLUD::SuperLUStat_t* stat, int* info)
556#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
557 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
558 SLUD::Z::zScalePermstruct_t* scale_perm_struct,
559 SLUD::gridinfo_t* grid, type_map::type* B,
560 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
561 SLUD::int_t ldb, int nrhs,
562 type_map::SOLVEstruct_t* solve_struct,
563 SLUD::SuperLUStat_t* stat, int* info)
564#else
565 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
566 SLUD::ScalePermstruct_t* scale_perm_struct,
567 SLUD::gridinfo_t* grid, type_map::type* B,
568 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
569 SLUD::int_t ldb, int nrhs,
570 type_map::SOLVEstruct_t* solve_struct,
571#endif
572 {
573#if (SUPERLU_DIST_MAJOR_VERSION > 7)
574 SLUD::Z::pzgstrs(options, n, lu_struct, scale_perm_struct, grid, B, l_numrows,
575 fst_global_row, ldb, nrhs, solve_struct, stat, info);
576#else
577 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
578 fst_global_row, ldb, nrhs, solve_struct, stat, info);
579#endif
580 }
581
582#if (SUPERLU_DIST_MAJOR_VERSION > 7)
583 static void gstrs_Bglobal(SLUD::amesos2_superlu_dist_options_t* options,
584 SLUD::int_t n, type_map::LUstruct_t* lu_struct,
585 SLUD::gridinfo_t* grid, type_map::type* B,
586 SLUD::int_t ldb, int nrhs, SLUD::SuperLUStat_t* stat, int* info)
587 {
588 SLUD::Z::pzgstrs_Bglobal(options,n, lu_struct, grid, B, ldb, nrhs, stat, info);
589 }
590#else
591 static void gstrs_Bglobal(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(n, lu_struct, grid, B, ldb, nrhs, stat, info);
596 }
597#endif
598
599 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
600 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
601 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
602 type_map::type* nzval, SLUD::int_t* colind,
603 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
604 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
605 {
606 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
607 l_numrows, fst_global_row,
608 nzval, colind, rowptr,
609 storage_t, data_t, mat_t);
610 }
611
612 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
613 SLUD::int_t numcols, SLUD::int_t nnz,
614 type_map::type* nzval, SLUD::int_t* rowind,
615 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
616 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
617 {
618 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
619 nzval, rowind, colptr,
620 storage_t, data_t, mat_t);
621 }
622
623 static void create_Dense_Matrix(SLUD::SuperMatrix* X, int m, int n,
624 TypeMap<Superludist,std::complex<double> >::type* x, int ldx,
625 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
626 {
627 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
628 }
629
630 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
631 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
632 type_map::type* X, int ldx,
633 type_map::type* B, int ldb,
634 int nrhs, SLUD::gridinfo_t* grid)
635 {
636 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
637 X, ldx, B, ldb, nrhs, grid);
638 }
639
640 static void gsequ_loc(SLUD::SuperMatrix* A, double* r, double* c,
641 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info,
642 SLUD::gridinfo_t* grid)
643 {
644 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
645 }
646
647 static void gsequ(SLUD::SuperMatrix* A, double* r, double* c,
648 double* rowcnd, double* colcnd, double* amax, SLUD::int_t* info)
649 {
650 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
651 }
652
653 static void laqgs_loc(SLUD::SuperMatrix* A, double* r, double* c,
654 double rowcnd, double colcnd, double amax, SLUD::DiagScale_t* equed)
655 {
656 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
657 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
658 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
659 }
660
661 static void laqgs(SLUD::SuperMatrix* A, double* r, double* c,
662 double rowcnd, double colcnd, double amax, SLUD::DiagScale_t* equed)
663 {
664 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
665 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
666 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
667 }
668
669#if (SUPERLU_DIST_MAJOR_VERSION > 7)
670 static void distribute(SLUD::amesos2_superlu_dist_options_t* options,
671 SLUD::int_t n,
672 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
673 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
674 {
675 SLUD::Z::zdistribute(options, n, A, glu_freeable, lu, grid);
676 }
677#else
678 static void distribute(SLUD::fact_t fact, 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(fact, n, A, glu_freeable, lu, grid);
683 }
684#endif
685
686#if (SUPERLU_DIST_MAJOR_VERSION > 7)
687 static void pdistribute(SLUD::amesos2_superlu_dist_options_t* options,
688 SLUD::int_t n,
689 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
690 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
691 SLUD::gridinfo_t* grid)
692#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
693 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
694 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
695 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
696 SLUD::gridinfo_t* grid)
697#else
698 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
699 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
700 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
701 SLUD::gridinfo_t* grid)
702#endif
703 {
704#if (SUPERLU_DIST_MAJOR_VERSION > 7)
705 SLUD::Z::pzdistribute(options, n, A, scale_perm, glu_freeable, lu, grid);
706#else
707 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
708#endif
709 }
710
711#if (SUPERLU_DIST_MAJOR_VERSION > 7)
712 static void dist_psymbtonum(SLUD::amesos2_superlu_dist_options_t* options,
713 SLUD::int_t n,
714 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
715 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
716 SLUD::gridinfo_t* grid)
717#elif SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
718 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
719 SLUD::SuperMatrix* A, SLUD::Z::zScalePermstruct_t* scale_perm,
720 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
721 SLUD::gridinfo_t* grid)
722#else
723 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
724 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
725 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
726 SLUD::gridinfo_t* grid)
727#endif
728 {
729#if (SUPERLU_DIST_MAJOR_VERSION > 7)
730 SLUD::Z::zdist_psymbtonum(options, n, A, scale_perm, pslu_freeable, lu, grid);
731#else
732 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
733#endif
734 }
735
736 static double plangs(char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
737 {
738 return SLUD::Z::pzlangs(norm, A, grid);
739 }
740
741 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
742 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
743 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
744 type_map::SOLVEstruct_t* solve_struct)
745 {
746 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
747 }
748
749 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
750 {
753#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
754 SLUD::Z::zLUstructInit(n, lu);
755#elif defined(AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER)
756 SLUD::Z::LUstructInit(n, lu);
757#else
758#ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
759 SLUD::Z::LUstructInit(n, lu);
760#else
761 SLUD::Z::LUstructInit(m, n, lu);
762#endif
763#endif
764 }
765
766 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
767 {
768#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
769 SLUD::Z::zDestroy_LU(m, grid, lu);
770#else
771 SLUD::Z::Destroy_LU(m, grid, lu);
772#endif
773 }
774
775 static void LUstructFree(type_map::LUstruct_t* lu)
776 {
777#if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
778 SLUD::Z::zLUstructFree(lu);
779#else
780 SLUD::Z::LUstructFree(lu);
781#endif
782 }
783
784 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
785 type_map::SOLVEstruct_t* solve_struct)
786 {
787 SLUD::Z::zSolveFinalize(options, solve_struct);
788 }
789 };
790#endif // HAVE_TEUCHOS_COMPLEX
791
792} // end namespace Amesos2
793
794
795#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.