Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Superludist_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_SUPERLUDIST_DECL_HPP
54#define AMESOS2_SUPERLUDIST_DECL_HPP
55
57#include "Amesos2_SolverCore.hpp"
59
60namespace Amesos2 {
61
62
88template <class Matrix,
89 class Vector>
90class Superludist : public SolverCore<Amesos2::Superludist, Matrix, Vector>
91{
92 friend class SolverCore<Amesos2::Superludist,Matrix,Vector>; // Give our base access
93 // to our private
94 // implementation funcs
95public:
96
98 static const char* name; // declaration. Initialization outside.
99
100 typedef Superludist<Matrix,Vector> type;
101 typedef SolverCore<Amesos2::Superludist,Matrix,Vector> super_type;
102
103 typedef Matrix matrix_type;
104 typedef Vector vector_type;
105
106 // Since typedef's are not inheritted, go grab them
107 typedef typename super_type::scalar_type scalar_type;
108 typedef typename super_type::local_ordinal_type local_ordinal_type;
109 typedef typename super_type::global_ordinal_type global_ordinal_type;
110 typedef typename super_type::global_size_type global_size_type;
111 typedef typename super_type::node_type node_type;
112
113 typedef TypeMap<Amesos2::Superludist,scalar_type> type_map;
114
115 typedef typename type_map::type slu_type;
116 typedef typename type_map::magnitude_type magnitude_type;
117
118 typedef FunctionMap<Amesos2::Superludist,slu_type> function_map;
119
120 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
121 typedef Kokkos::View<SLUD::int_t*, HostExecSpaceType> host_size_type_array;
122 typedef Kokkos::View<SLUD::int_t*, HostExecSpaceType> host_ordinal_type_array;
123 typedef Kokkos::View<slu_type*, HostExecSpaceType> host_value_type_array;
124
126
127
134 Superludist(Teuchos::RCP<const Matrix> A,
135 Teuchos::RCP<Vector> X,
136 Teuchos::RCP<const Vector> B);
137
138
140 ~Superludist( );
141
143
144private:
145
152 int preOrdering_impl();
153
154
163
164
175
176
188 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
189 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
190
191
197 bool matrixShapeOK_impl() const;
198
199
221 /*
222 * The following options could be supported in the future:
223 *
224 * <li> \c "Equil" : { \c "YES" | \c "NO" } or, equivalently, { \c true | \c false }.
225 * Specifies whether the solver to equilibrate the matrix before solving.</li>
226 * <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA"
227 * }. Specifies whether to perform iterative refinement, and in
228 * what precision to compute the residual. (Not currently supported)</li>
229 */
231 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
232
233
240 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
241
242
255 void get_default_grid_size(int nprocs, SLUD::int_t& nprow, SLUD::int_t& npcol) const;
256
257
272 bool loadA_impl(EPhase current_phase);
273
274
275 // struct holds all data necessary to make a superlu factorization or solve call
276 mutable struct SLUData {
277 SLUD::SuperMatrix A;
278 SLUD::SuperMatrix AC;
279 typename type_map::LUstruct_t LU;
280 SLUD::Glu_freeable_t glu_freeable;
281
285 int domains;
286 MPI_Comm symb_comm;
287 SLUD::int_t *sizes, *fstVtxSep; // memory allocated by get_perm_c_parmetis
288 SLUD::Pslu_freeable_t pslu_freeable;
289
290 SLUD::amesos2_superlu_dist_options_t options;
291 SLUD::amesos2_superlu_dist_mem_usage_t mem_usage;
292 SLUD::gridinfo_t grid;
293 MPI_Comm mat_comm;
294 typename type_map::LUstruct_t lu;
295 SLUD::SuperLUStat_t stat;
296 typename type_map::SOLVEstruct_t solve_struct;
297
298 Teuchos::Array<magnitude_type> berr;
299 Teuchos::Array<magnitude_type> ferr;
300
301 // Pick up data type specific ScalePermstruct_t
302 typename type_map::ScalePermstruct_t scale_perm; // R, C, perm_r, and perm_c found in here
303
304 Teuchos::Array<magnitude_type> R, C; // equilibration scalings
305 Teuchos::Array<magnitude_type> R1, C1; // row-permutation scalings
306 Teuchos::Array<SLUD::int_t> perm_r, perm_c;
307
308 SLUD::DiagScale_t equed;
309 bool rowequ, colequ;
310 magnitude_type rowcnd, colcnd, amax;
311 } data_;
312
313 // The following Arrays are persisting storage arrays for A, X, and B
315 host_value_type_array nzvals_view_;
317 host_ordinal_type_array colind_view_;
319 host_size_type_array rowptr_view_;
321 mutable Teuchos::Array<slu_type> bvals_;
323 mutable Teuchos::Array<slu_type> xvals_;
324
327 bool same_symbolic_;
328 mutable bool same_solve_struct_; // may be modified in solve_impl, but still `logically const'
329
331 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,
332 global_ordinal_type,
333 node_type> > superlu_rowmap_;
334
335 bool is_contiguous_;
336
337}; // End class Superludist
338
339
340// Specialize the solver_traits template for SuperLU_DIST
341template <>
343#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
344 typedef Meta::make_list3<double, std::complex<double>, SLUD::Z::doublecomplex> supported_scalars;
345#else
346 typedef Meta::make_list1<double> supported_scalars;
347#endif
348};
349
350} // end namespace Amesos2
351
352#endif // AMESOS2_SUPERLUDIST_DECL_HPP
Provides access to interesting solver traits.
Provides a mechanism to map function calls to the correct Solver function based on the scalar type of...
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition: Amesos2_SolverCore_decl.hpp:106
Amesos2 interface to the distributed memory version of SuperLU.
Definition: Amesos2_Superludist_decl.hpp:91
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > superlu_rowmap_
Maps rows of the matrix to processors in the SuperLU_DIST processor grid.
Definition: Amesos2_Superludist_decl.hpp:333
bool in_grid_
true if this processor is in SuperLU_DISTS's 2D process grid
Definition: Amesos2_Superludist_decl.hpp:326
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Superludist_def.hpp:690
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_Superludist_def.hpp:699
static const char * name
Name of this solver interface.
Definition: Amesos2_Superludist_decl.hpp:98
int numericFactorization_impl()
SuperLU_DIST specific numeric factorization.
Definition: Amesos2_Superludist_def.hpp:426
host_ordinal_type_array colind_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Superludist_decl.hpp:317
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal solver structures.
Definition: Amesos2_Superludist_def.hpp:867
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for SuperLU_DIST.
Definition: Amesos2_Superludist_decl.hpp:315
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Superludist_def.hpp:328
Teuchos::Array< slu_type > bvals_
1D store for B values
Definition: Amesos2_Superludist_decl.hpp:321
host_size_type_array rowptr_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Superludist_decl.hpp:319
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
SuperLU_DIST specific solve.
Definition: Amesos2_Superludist_def.hpp:526
void get_default_grid_size(int nprocs, SLUD::int_t &nprow, SLUD::int_t &npcol) const
Definition: Amesos2_Superludist_def.hpp:842
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using SuperLU_DIST.
Definition: Amesos2_Superludist_def.hpp:383
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Superludist_def.hpp:772
Teuchos::Array< slu_type > xvals_
1D store for X values
Definition: Amesos2_Superludist_decl.hpp:323
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:77
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71