Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Superlumt_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_SUPERLUMT_FUNCTIONMAP_HPP
54#define AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP
55
56#ifdef HAVE_TEUCHOS_COMPLEX
57#include <complex>
58#endif
59
61#include "Amesos2_MatrixAdapter.hpp"
63
64
65// External definitions of the SuperLU_MT functions
66namespace SLUMT {
67extern "C" {
68
69typedef int int_t;
70
71#include "slu_mt_util.h"
72#include "pxgstrf_synch.h" // preemptive inclusion
73
74namespace S {
75#include "pssp_defs.h" // single-precision real definitions
76}
77
78namespace D {
79#include "pdsp_defs.h" // double-precision real definitions
80}
81
82#ifdef HAVE_TEUCHOS_COMPLEX
83namespace C {
84#include "pcsp_defs.h" // single-precision complex definitions
85}
86
87namespace Z {
88#include "pzsp_defs.h" // double-precision complex definitions
89}
90#endif // HAVE_TEUCHOS_COMPLEX
91
92} // end extern "C"
93
94} // end namespace SLUMT
95
96namespace Amesos2 {
97
98 template <class Matrix, class Vector> class Superlumt;
99
100 /* ==================== Specializations ====================
101 *
102 * \cond SuperLU_MT_function_specializations
103 */
104
105 /*
106 * Note that we don't need any generic declarations of the
107 * SuperLU_MT functions that throw error in case the scalar type is
108 * not supported. This check is already performed in the factory
109 * create method. Just go straight for the specializations.
110 */
111
134 template <>
135 struct FunctionMap<Superlumt,float>
136 {
137 typedef TypeMap<Superlumt,float> type_map;
138
142 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
143 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C,
144 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
145 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth,
146 float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage,
147 SLUMT::Gstat_t* stat, int* info)
148 {
149 options->etree = etree;
150 options->perm_c = perm_c;
151 options->perm_r = perm_r;
152
153 options->work = work;
154 options->lwork = lwork;
155
156 SLUMT::S::psgssvx(options->nprocs, options, A, perm_c, perm_r,
157 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
158 berr, mem_usage, info);
159 }
160
164 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
165 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
166 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
167 {
168 SLUMT::S::sgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
169 }
170
188 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
189 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
190 SLUMT::Gstat_t* stat, int* info)
191 {
192 SLUMT::S::psgstrf(options, A, perm_r, L, U, stat, info);
193 }
194
208 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
209 type_map::type* nzval, int* rowind, int* colptr,
210 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
211 {
212 SLUMT::S::sCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
213 stype, dtype, mtype);
214 }
215
227 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
228 type_map::type* x, int ldx, SLUMT::Stype_t stype,
229 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
230 {
231 SLUMT::S::sCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
232 }
233
240 static void gsequ(SLUMT::SuperMatrix* A,
241 type_map::magnitude_type* r,
242 type_map::magnitude_type* c,
243 type_map::magnitude_type* rowcnd,
244 type_map::magnitude_type* colcnd,
245 type_map::magnitude_type* amax,
246 int* info)
247 {
248 SLUMT::S::sgsequ(A, r, c, rowcnd, colcnd, amax, info);
249 }
250
259 static void laqgs(SLUMT::SuperMatrix* A,
260 type_map::magnitude_type* r,
261 type_map::magnitude_type* c,
262 type_map::magnitude_type rowcnd,
263 type_map::magnitude_type colcnd,
264 type_map::magnitude_type amax,
265 SLUMT::equed_t* equed)
266 {
267 SLUMT::S::slaqgs(A, r, c, rowcnd, colcnd, amax, equed);
268 }
269 };
270
271
272 template <>
273 struct FunctionMap<Superlumt,double>
274 {
275 typedef TypeMap<Superlumt,double> type_map;
276
277 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
278 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C,
279 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
280 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth,
281 double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage,
282 SLUMT::Gstat_t* stat, int* info)
283 {
284 options->etree = etree;
285 options->perm_c = perm_c;
286 options->perm_r = perm_r;
287
288 options->work = work;
289 options->lwork = lwork;
290
291 SLUMT::D::pdgssvx(options->nprocs, options, A, perm_c, perm_r,
292 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
293 berr, mem_usage, info);
294 }
295
296 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
297 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
298 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
299 {
300 SLUMT::D::dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
301 }
302
303 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
304 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
305 SLUMT::Gstat_t* stat, int* info)
306 {
307 SLUMT::D::pdgstrf(options, A, perm_r, L, U, stat, info);
308 }
309
310 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
311 type_map::type* nzval, int* rowind, int* colptr,
312 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
313 {
314 SLUMT::D::dCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
315 stype, dtype, mtype);
316 }
317
318 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
319 type_map::type* x, int ldx, SLUMT::Stype_t stype,
320 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
321 {
322 SLUMT::D::dCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
323 }
324
325 static void gsequ(SLUMT::SuperMatrix* A,
326 type_map::magnitude_type* r,
327 type_map::magnitude_type* c,
328 type_map::magnitude_type* rowcnd,
329 type_map::magnitude_type* colcnd,
330 type_map::magnitude_type* amax,
331 int* info)
332 {
333 SLUMT::D::dgsequ(A, r, c, rowcnd, colcnd, amax, info);
334 }
335
336 static void laqgs(SLUMT::SuperMatrix* A,
337 type_map::magnitude_type* r,
338 type_map::magnitude_type* c,
339 type_map::magnitude_type rowcnd,
340 type_map::magnitude_type colcnd,
341 type_map::magnitude_type amax,
342 SLUMT::equed_t* equed)
343 {
344 SLUMT::D::dlaqgs(A, r, c, rowcnd, colcnd, amax, equed);
345 }
346 };
347
348
349#ifdef HAVE_TEUCHOS_COMPLEX
350 /* The specializations for Teuchos::as<> for SLUMT::complex and
351 * SLUMT::doublecomplex are provided in Amesos2_Superlumt_TypeMap.hpp
352 */
353 template <>
354 struct FunctionMap<Superlumt,SLUMT::C::complex>
355 {
356 typedef TypeMap<Superlumt,SLUMT::C::complex> type_map;
357
358 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
359 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C,
360 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
361 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth,
362 float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage,
363 SLUMT::Gstat_t* stat, int* info)
364 {
365 options->etree = etree;
366 options->perm_c = perm_c;
367 options->perm_r = perm_r;
368
369 options->work = work;
370 options->lwork = lwork;
371
372 SLUMT::C::pcgssvx(options->nprocs, options, A, perm_c, perm_r,
373 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
374 berr, mem_usage, info);
375 }
376
377 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
378 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
379 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
380 {
381 SLUMT::C::cgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
382 }
383
384 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
385 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
386 SLUMT::Gstat_t* stat, int* info)
387 {
388 SLUMT::C::pcgstrf(options, A, perm_r, L, U, stat, info);
389 }
390
391 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
392 type_map::type* nzval, int* rowind, int* colptr,
393 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
394 {
395 SLUMT::C::cCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
396 stype, dtype, mtype);
397 }
398
399 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
400 type_map::type* x, int ldx, SLUMT::Stype_t stype,
401 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
402 {
403 SLUMT::C::cCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
404 }
405
406 static void gsequ(SLUMT::SuperMatrix* A, float* r, float* c,
407 float* rowcnd, float* colcnd, float* amax, int* info)
408 {
409 SLUMT::C::cgsequ(A, r, c, rowcnd, colcnd, amax, info);
410 }
411
412 static void laqgs(SLUMT::SuperMatrix* A, float* r, float* c, float rowcnd,
413 float colcnd, float amax, SLUMT::equed_t* equed)
414 {
415 SLUMT::C::claqgs(A, r, c, rowcnd, colcnd, amax, equed);
416 }
417 };
418
419
420 template <>
421 struct FunctionMap<Superlumt,SLUMT::Z::doublecomplex>
422 {
423 typedef TypeMap<Superlumt,SLUMT::Z::doublecomplex> type_map;
424
425 static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
426 int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C,
427 SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
428 SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth,
429 double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage,
430 SLUMT::Gstat_t* stat, int* info)
431 {
432 options->etree = etree;
433 options->perm_c = perm_c;
434 options->perm_r = perm_r;
435
436 options->work = work;
437 options->lwork = lwork;
438
439 SLUMT::Z::pzgssvx(options->nprocs, options, A, perm_c, perm_r,
440 equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
441 berr, mem_usage, info);
442 }
443
444 static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
445 SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
446 SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
447 {
448 SLUMT::Z::zgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
449 }
450
451 static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
452 int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
453 SLUMT::Gstat_t* stat, int* info)
454 {
455 SLUMT::Z::pzgstrf(options, A, perm_r, L, U, stat, info);
456 }
457
458 static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
459 type_map::type* nzval, int* rowind, int* colptr,
460 SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
461 {
462 SLUMT::Z::zCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
463 stype, dtype, mtype);
464 }
465
466 static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
467 type_map::type* x, int ldx, SLUMT::Stype_t stype,
468 SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
469 {
470 SLUMT::Z::zCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
471 }
472
473 static void gsequ(SLUMT::SuperMatrix* A, double* r, double* c,
474 double* rowcnd, double* colcnd, double* amax, int* info)
475 {
476 SLUMT::Z::zgsequ(A, r, c, rowcnd, colcnd, amax, info);
477 }
478
479 static void laqgs(SLUMT::SuperMatrix* A, double* r, double* c, double rowcnd,
480 double colcnd, double amax, SLUMT::equed_t* equed)
481 {
482 SLUMT::Z::zlaqgs(A, r, c, rowcnd, colcnd, amax, equed);
483 }
484 };
485#endif // HAVE_TEUCHOS_COMPLEX
486
487 /* \endcond SuperLU_MT_function_specializations */
488
489} // end namespace Amesos2
490
491
492#endif // AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP
Declaration of Function mapping class for Amesos2.
Provides definition of SuperLU_MT types as well as conversions and type traits.