Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Superlumt_decl.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_DECL_HPP
54 #define AMESOS2_SUPERLUMT_DECL_HPP
55 
56 #include "Amesos2_SolverTraits.hpp"
59 
60 
61 namespace Amesos2 {
62 
63 
75 template <class Matrix,
76  class Vector>
77 class Superlumt : public SolverCore<Amesos2::Superlumt, Matrix, Vector>
78 {
79  friend class SolverCore<Amesos2::Superlumt,Matrix,Vector>; // Give our base access
80  // to our private
81  // implementation funcs
82 public:
83 
85  static const char* name; // declaration. Initialization outside.
86 
87  typedef Superlumt<Matrix,Vector> type;
88  typedef SolverCore<Amesos2::Superlumt,Matrix,Vector> super_type;
89 
90  // Since typedef's are not inheritted, go grab them
91  typedef typename super_type::scalar_type scalar_type;
92  typedef typename super_type::local_ordinal_type local_ordinal_type;
93  typedef typename super_type::global_ordinal_type global_ordinal_type;
94  typedef typename super_type::global_size_type global_size_type;
95 
96  typedef TypeMap<Amesos2::Superlumt,scalar_type> type_map;
97 
98  typedef typename type_map::type slu_type;
99  typedef typename type_map::magnitude_type magnitude_type;
100 
101  typedef FunctionMap<Amesos2::Superlumt,slu_type> function_map;
102 
103 
105 
106 
113  Superlumt(Teuchos::RCP<const Matrix> A,
114  Teuchos::RCP<Vector> X,
115  Teuchos::RCP<const Vector> B);
116 
117 
119  ~Superlumt( );
120 
122 
123 private:
124 
131  int preOrdering_impl();
132 
133 
142 
143 
154 
155 
167  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
168  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
169 
170 
176  bool matrixShapeOK_impl() const;
177 
178 
216  void setParameters_impl(
217  const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
218  /* Parameters to support in the future:
219  *
220  * <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA"
221  * }. Specifies whether to perform iterative refinement, and in
222  * what precision to compute the residual. (Not currently supported)</li>
223  */
224 
231  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
232 
233 
242  bool loadA_impl(EPhase current_phase);
243 
244 
245  // struct holds all data necessary to make a superlu factorization or solve call
246  mutable struct SLUData {
247  SLUMT::SuperMatrix A, BX, L, U;
248  SLUMT::SuperMatrix AC;
249 
250  SLUMT::superlumt_options_t options;
251  SLUMT::superlu_memusage_t mem_usage;
252  SLUMT::Gstat_t stat;
253 
254  Teuchos::Array<magnitude_type> berr;
255  Teuchos::Array<magnitude_type> ferr;
256  Teuchos::Array<int> perm_r;
257  Teuchos::Array<int> perm_c;
258  Teuchos::Array<magnitude_type> R;
259  Teuchos::Array<magnitude_type> C;
260 
261  // in contrast to SuperLU, memory for etree will be allocated by
262  // pxgssvx and the pointer will be stored in `options'
263 
264  SLUMT::equed_t equed;
265  bool rowequ, colequ;
266  } data_;
267 
268  // The following Arrays are persisting storage arrays for A, X, and B
270  Teuchos::Array<typename TypeMap<Amesos2::Superlumt,scalar_type>::type> nzvals_;
272  Teuchos::Array<int> rowind_;
274  Teuchos::Array<int> colptr_;
275 
276  /* Note: In the above, must use "Amesos2::Superlumt" rather than
277  * "Superlumt" because otherwise the compiler references the
278  * specialized type of the class, and not the templated type that is
279  * required for Amesos2::TypeMap
280  */
281 
282  /* SuperLU can accept input in either compressed-row or
283  * compressed-column storage. We will store and pass matrices in
284  * *compressed-row* format because that is the format Amesos used.
285  */
286 
287  bool is_contiguous_;
288 
289 }; // End class Superlumt
290 
291 
292 // Specialize the solver_traits struct for SuperLU_MT
293 template <>
294 struct solver_traits<Superlumt> {
295 #ifdef HAVE_TEUCHOS_COMPLEX
296  typedef Meta::make_list6<float,
297  double,
298  std::complex<float>,
299  std::complex<double>,
300  SLUMT::C::complex,
301  SLUMT::Z::doublecomplex> supported_scalars;
302 #else
303  typedef Meta::make_list2<float, double> supported_scalars;
304 #endif
305 };
306 
307 } // end namespace Amesos2
308 
309 #endif // AMESOS2_SUPERLUMT_DECL_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Superlumt_def.hpp:445
Amesos2 interface to the Multi-threaded version of SuperLU.
Definition: Amesos2_Superlumt_decl.hpp:77
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
SuperLU_MT specific solve.
Definition: Amesos2_Superlumt_def.hpp:331
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
Teuchos::Array< int > colptr_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Superlumt_decl.hpp:274
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using SuperLU_MT.
Definition: Amesos2_Superlumt_def.hpp:202
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Superlumt_def.hpp:510
Templated core-functionality class for Amesos2 solvers.
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Superlumt_def.hpp:182
Provides a mechanism to map function calls to the correct Solver function based on the scalar type of...
std::string name() const override
Return the name of this solver.
Definition: Amesos2_SolverCore_def.hpp:759
int numericFactorization_impl()
SuperLU_MT specific numeric factorization.
Definition: Amesos2_Superlumt_def.hpp:227
Interface to Amesos2 solver objects.
Definition: Amesos2_Solver_decl.hpp:78
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_Superlumt_def.hpp:456
Teuchos::Array< typename TypeMap< Amesos2::Superlumt, scalar_type >::type > nzvals_
Stores the values of the nonzero entries for SuperLU.
Definition: Amesos2_Superlumt_decl.hpp:270
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:76
Provides access to interesting solver traits.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Superlumt_def.hpp:599
Teuchos::Array< int > rowind_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Superlumt_decl.hpp:272