Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Superlumt_FunctionMap.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Amesos2: Templated Direct Sparse Solver Package
4 //
5 // Copyright 2011 NTESS and the Amesos2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
19 #ifndef AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP
20 #define AMESOS2_SUPERLUMT_FUNCTIONMAP_HPP
21 
22 #ifdef HAVE_TEUCHOS_COMPLEX
23 #include <complex>
24 #endif
25 
26 #include "Amesos2_FunctionMap.hpp"
27 #include "Amesos2_MatrixAdapter.hpp"
29 
30 
31 // External definitions of the SuperLU_MT functions
32 namespace SLUMT {
33 extern "C" {
34 
35 typedef int int_t;
36 
37 #include "slu_mt_util.h"
38 #include "pxgstrf_synch.h" // preemptive inclusion
39 
40 namespace S {
41 #include "pssp_defs.h" // single-precision real definitions
42 }
43 
44 namespace D {
45 #include "pdsp_defs.h" // double-precision real definitions
46 }
47 
48 #ifdef HAVE_TEUCHOS_COMPLEX
49 namespace C {
50 #include "pcsp_defs.h" // single-precision complex definitions
51 }
52 
53 namespace Z {
54 #include "pzsp_defs.h" // double-precision complex definitions
55 }
56 #endif // HAVE_TEUCHOS_COMPLEX
57 
58 } // end extern "C"
59 
60 } // end namespace SLUMT
61 
62 namespace Amesos2 {
63 
64  template <class Matrix, class Vector> class Superlumt;
65 
66  /* ==================== Specializations ====================
67  *
68  * \cond SuperLU_MT_function_specializations
69  */
70 
71  /*
72  * Note that we don't need any generic declarations of the
73  * SuperLU_MT functions that throw error in case the scalar type is
74  * not supported. This check is already performed in the factory
75  * create method. Just go straight for the specializations.
76  */
77 
100  template <>
101  struct FunctionMap<Superlumt,float>
102  {
103  typedef TypeMap<Superlumt,float> type_map;
104 
108  static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
109  int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C,
110  SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
111  SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth,
112  float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage,
113  SLUMT::Gstat_t* stat, int* info)
114  {
115  options->etree = etree;
116  options->perm_c = perm_c;
117  options->perm_r = perm_r;
118 
119  options->work = work;
120  options->lwork = lwork;
121 
122  SLUMT::S::psgssvx(options->nprocs, options, A, perm_c, perm_r,
123  equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
124  berr, mem_usage, info);
125  }
126 
130  static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
131  SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
132  SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
133  {
134  SLUMT::S::sgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
135  }
136 
154  static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
155  int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
156  SLUMT::Gstat_t* stat, int* info)
157  {
158  SLUMT::S::psgstrf(options, A, perm_r, L, U, stat, info);
159  }
160 
174  static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
175  type_map::type* nzval, int* rowind, int* colptr,
176  SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
177  {
178  SLUMT::S::sCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
179  stype, dtype, mtype);
180  }
181 
193  static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
194  type_map::type* x, int ldx, SLUMT::Stype_t stype,
195  SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
196  {
197  SLUMT::S::sCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
198  }
199 
206  static void gsequ(SLUMT::SuperMatrix* A,
207  type_map::magnitude_type* r,
208  type_map::magnitude_type* c,
209  type_map::magnitude_type* rowcnd,
210  type_map::magnitude_type* colcnd,
211  type_map::magnitude_type* amax,
212  int* info)
213  {
214  SLUMT::S::sgsequ(A, r, c, rowcnd, colcnd, amax, info);
215  }
216 
225  static void laqgs(SLUMT::SuperMatrix* A,
226  type_map::magnitude_type* r,
227  type_map::magnitude_type* c,
228  type_map::magnitude_type rowcnd,
229  type_map::magnitude_type colcnd,
230  type_map::magnitude_type amax,
231  SLUMT::equed_t* equed)
232  {
233  SLUMT::S::slaqgs(A, r, c, rowcnd, colcnd, amax, equed);
234  }
235  };
236 
237 
238  template <>
239  struct FunctionMap<Superlumt,double>
240  {
241  typedef TypeMap<Superlumt,double> type_map;
242 
243  static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
244  int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C,
245  SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
246  SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth,
247  double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage,
248  SLUMT::Gstat_t* stat, int* info)
249  {
250  options->etree = etree;
251  options->perm_c = perm_c;
252  options->perm_r = perm_r;
253 
254  options->work = work;
255  options->lwork = lwork;
256 
257  SLUMT::D::pdgssvx(options->nprocs, options, A, perm_c, perm_r,
258  equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
259  berr, mem_usage, info);
260  }
261 
262  static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
263  SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
264  SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
265  {
266  SLUMT::D::dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
267  }
268 
269  static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
270  int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
271  SLUMT::Gstat_t* stat, int* info)
272  {
273  SLUMT::D::pdgstrf(options, A, perm_r, L, U, stat, info);
274  }
275 
276  static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
277  type_map::type* nzval, int* rowind, int* colptr,
278  SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
279  {
280  SLUMT::D::dCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
281  stype, dtype, mtype);
282  }
283 
284  static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
285  type_map::type* x, int ldx, SLUMT::Stype_t stype,
286  SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
287  {
288  SLUMT::D::dCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
289  }
290 
291  static void gsequ(SLUMT::SuperMatrix* A,
292  type_map::magnitude_type* r,
293  type_map::magnitude_type* c,
294  type_map::magnitude_type* rowcnd,
295  type_map::magnitude_type* colcnd,
296  type_map::magnitude_type* amax,
297  int* info)
298  {
299  SLUMT::D::dgsequ(A, r, c, rowcnd, colcnd, amax, info);
300  }
301 
302  static void laqgs(SLUMT::SuperMatrix* A,
303  type_map::magnitude_type* r,
304  type_map::magnitude_type* c,
305  type_map::magnitude_type rowcnd,
306  type_map::magnitude_type colcnd,
307  type_map::magnitude_type amax,
308  SLUMT::equed_t* equed)
309  {
310  SLUMT::D::dlaqgs(A, r, c, rowcnd, colcnd, amax, equed);
311  }
312  };
313 
314 
315 #ifdef HAVE_TEUCHOS_COMPLEX
316  /* The specializations for Teuchos::as<> for SLUMT::complex and
317  * SLUMT::doublecomplex are provided in Amesos2_Superlumt_TypeMap.hpp
318  */
319  template <>
320  struct FunctionMap<Superlumt,SLUMT::C::complex>
321  {
322  typedef TypeMap<Superlumt,SLUMT::C::complex> type_map;
323 
324  static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
325  int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, float* R, float* C,
326  SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
327  SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, float* recip_pivot_growth,
328  float* rcond, float* ferr, float* berr, SLUMT::superlu_memusage_t* mem_usage,
329  SLUMT::Gstat_t* stat, int* info)
330  {
331  options->etree = etree;
332  options->perm_c = perm_c;
333  options->perm_r = perm_r;
334 
335  options->work = work;
336  options->lwork = lwork;
337 
338  SLUMT::C::pcgssvx(options->nprocs, options, A, perm_c, perm_r,
339  equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
340  berr, mem_usage, info);
341  }
342 
343  static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
344  SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
345  SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
346  {
347  SLUMT::C::cgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
348  }
349 
350  static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
351  int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
352  SLUMT::Gstat_t* stat, int* info)
353  {
354  SLUMT::C::pcgstrf(options, A, perm_r, L, U, stat, info);
355  }
356 
357  static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
358  type_map::type* nzval, int* rowind, int* colptr,
359  SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
360  {
361  SLUMT::C::cCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
362  stype, dtype, mtype);
363  }
364 
365  static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
366  type_map::type* x, int ldx, SLUMT::Stype_t stype,
367  SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
368  {
369  SLUMT::C::cCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
370  }
371 
372  static void gsequ(SLUMT::SuperMatrix* A, float* r, float* c,
373  float* rowcnd, float* colcnd, float* amax, int* info)
374  {
375  SLUMT::C::cgsequ(A, r, c, rowcnd, colcnd, amax, info);
376  }
377 
378  static void laqgs(SLUMT::SuperMatrix* A, float* r, float* c, float rowcnd,
379  float colcnd, float amax, SLUMT::equed_t* equed)
380  {
381  SLUMT::C::claqgs(A, r, c, rowcnd, colcnd, amax, equed);
382  }
383  };
384 
385 
386  template <>
387  struct FunctionMap<Superlumt,SLUMT::Z::doublecomplex>
388  {
389  typedef TypeMap<Superlumt,SLUMT::Z::doublecomplex> type_map;
390 
391  static void gssvx(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
392  int* perm_c, int* perm_r, int* etree, SLUMT::equed_t* equed, double* R, double* C,
393  SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U, void* work, int lwork,
394  SLUMT::SuperMatrix* B, SLUMT::SuperMatrix* X, double* recip_pivot_growth,
395  double* rcond, double* ferr, double* berr, SLUMT::superlu_memusage_t* mem_usage,
396  SLUMT::Gstat_t* stat, int* info)
397  {
398  options->etree = etree;
399  options->perm_c = perm_c;
400  options->perm_r = perm_r;
401 
402  options->work = work;
403  options->lwork = lwork;
404 
405  SLUMT::Z::pzgssvx(options->nprocs, options, A, perm_c, perm_r,
406  equed, R, C, L, U, B, X, recip_pivot_growth, rcond, ferr,
407  berr, mem_usage, info);
408  }
409 
410  static void gstrs(SLUMT::trans_t trans, SLUMT::SuperMatrix* L,
411  SLUMT::SuperMatrix* U, int* perm_r, int* perm_c,
412  SLUMT::SuperMatrix* B, SLUMT::Gstat_t* Gstat, int* info)
413  {
414  SLUMT::Z::zgstrs(trans, L, U, perm_r, perm_c, B, Gstat, info);
415  }
416 
417  static void gstrf(SLUMT::superlumt_options_t* options, SLUMT::SuperMatrix* A,
418  int* perm_r, SLUMT::SuperMatrix* L, SLUMT::SuperMatrix* U,
419  SLUMT::Gstat_t* stat, int* info)
420  {
421  SLUMT::Z::pzgstrf(options, A, perm_r, L, U, stat, info);
422  }
423 
424  static void create_CompCol_Matrix(SLUMT::SuperMatrix* A, int m, int n, int nnz,
425  type_map::type* nzval, int* rowind, int* colptr,
426  SLUMT::Stype_t stype, SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
427  {
428  SLUMT::Z::zCreate_CompCol_Matrix(A, m, n, nnz, nzval, rowind, colptr,
429  stype, dtype, mtype);
430  }
431 
432  static void create_Dense_Matrix(SLUMT::SuperMatrix* X, int m, int n,
433  type_map::type* x, int ldx, SLUMT::Stype_t stype,
434  SLUMT::Dtype_t dtype, SLUMT::Mtype_t mtype)
435  {
436  SLUMT::Z::zCreate_Dense_Matrix(X, m, n, x, ldx, stype, dtype, mtype);
437  }
438 
439  static void gsequ(SLUMT::SuperMatrix* A, double* r, double* c,
440  double* rowcnd, double* colcnd, double* amax, int* info)
441  {
442  SLUMT::Z::zgsequ(A, r, c, rowcnd, colcnd, amax, info);
443  }
444 
445  static void laqgs(SLUMT::SuperMatrix* A, double* r, double* c, double rowcnd,
446  double colcnd, double amax, SLUMT::equed_t* equed)
447  {
448  SLUMT::Z::zlaqgs(A, r, c, rowcnd, colcnd, amax, equed);
449  }
450  };
451 #endif // HAVE_TEUCHOS_COMPLEX
452 
453  /* \endcond SuperLU_MT_function_specializations */
454 
455 } // end namespace Amesos2
456 
457 
458 #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.