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