|
Amesos2 - Direct Sparse Solver Interfaces
Version of the Day
|
00001 // @HEADER 00002 // 00003 // *********************************************************************** 00004 // 00005 // Amesos2: Templated Direct Sparse Solver Package 00006 // Copyright 2011 Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // 00042 // @HEADER 00043 00053 #ifndef AMESOS2_SUPERLUDIST_DECL_HPP 00054 #define AMESOS2_SUPERLUDIST_DECL_HPP 00055 00056 #include "Amesos2_SolverTraits.hpp" 00057 #include "Amesos2_SolverCore.hpp" 00058 #include "Amesos2_Superludist_FunctionMap.hpp" 00059 00060 namespace Amesos2 { 00061 00062 00088 template <class Matrix, 00089 class Vector> 00090 class Superludist : public SolverCore<Amesos2::Superludist, Matrix, Vector> 00091 { 00092 friend class SolverCore<Amesos2::Superludist,Matrix,Vector>; // Give our base access 00093 // to our private 00094 // implementation funcs 00095 public: 00096 00098 static const char* name; // declaration. Initialization outside. 00099 00100 typedef Superludist<Matrix,Vector> type; 00101 typedef SolverCore<Amesos2::Superludist,Matrix,Vector> super_type; 00102 00103 typedef Matrix matrix_type; 00104 typedef Vector vector_type; 00105 00106 // Since typedef's are not inheritted, go grab them 00107 typedef typename super_type::scalar_type scalar_type; 00108 typedef typename super_type::local_ordinal_type local_ordinal_type; 00109 typedef typename super_type::global_ordinal_type global_ordinal_type; 00110 typedef typename super_type::global_size_type global_size_type; 00111 typedef typename super_type::node_type node_type; 00112 00113 typedef TypeMap<Amesos2::Superludist,scalar_type> type_map; 00114 00115 typedef typename type_map::type slu_type; 00116 typedef typename type_map::magnitude_type magnitude_type; 00117 00118 typedef FunctionMap<Amesos2::Superludist,slu_type> function_map; 00119 00120 00122 00123 00130 Superludist(Teuchos::RCP<const Matrix> A, 00131 Teuchos::RCP<Vector> X, 00132 Teuchos::RCP<const Vector> B); 00133 00134 00136 ~Superludist( ); 00137 00139 00140 private: 00141 00148 int preOrdering_impl(); 00149 00150 00158 int symbolicFactorization_impl(); 00159 00160 00170 int numericFactorization_impl(); 00171 00172 00184 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X, 00185 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const; 00186 00187 00193 bool matrixShapeOK_impl() const; 00194 00195 00217 /* 00218 * The following options could be supported in the future: 00219 * 00220 * <li> \c "Equil" : { \c "YES" | \c "NO" } or, equivalently, { \c true | \c false }. 00221 * Specifies whether the solver to equilibrate the matrix before solving.</li> 00222 * <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA" 00223 * }. Specifies whether to perform iterative refinement, and in 00224 * what precision to compute the residual. (Not currently supported)</li> 00225 */ 00226 void setParameters_impl( 00227 const Teuchos::RCP<Teuchos::ParameterList> & parameterList ); 00228 00229 00236 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const; 00237 00238 00251 void get_default_grid_size(int nprocs, SLUD::int_t& nprow, SLUD::int_t& npcol) const; 00252 00253 00268 bool loadA_impl(EPhase current_phase); 00269 00270 00271 // struct holds all data necessary to make a superlu factorization or solve call 00272 mutable struct SLUData { 00273 SLUD::SuperMatrix A; 00274 SLUD::SuperMatrix AC; 00275 typename type_map::LUstruct_t LU; 00276 SLUD::Glu_freeable_t glu_freeable; 00277 00281 int domains; 00282 MPI_Comm symb_comm; 00283 SLUD::int_t *sizes, *fstVtxSep; // memory allocated by get_perm_c_parmetis 00284 SLUD::Pslu_freeable_t pslu_freeable; 00285 00286 SLUD::superlu_options_t options; 00287 SLUD::mem_usage_t mem_usage; 00288 SLUD::gridinfo_t grid; 00289 MPI_Comm mat_comm; 00290 typename type_map::LUstruct_t lu; 00291 SLUD::SuperLUStat_t stat; 00292 typename type_map::SOLVEstruct_t solve_struct; 00293 00294 Teuchos::Array<magnitude_type> berr; 00295 Teuchos::Array<magnitude_type> ferr; 00296 00297 SLUD::ScalePermstruct_t scale_perm; // R, C, perm_r, and perm_c found in here 00298 Teuchos::Array<magnitude_type> R, C; // equilibration scalings 00299 Teuchos::Array<magnitude_type> R1, C1; // row-permutation scalings 00300 Teuchos::Array<SLUD::int_t> perm_r, perm_c; 00301 00302 SLUD::DiagScale_t equed; 00303 bool rowequ, colequ; 00304 magnitude_type rowcnd, colcnd, amax; 00305 } data_; 00306 00307 // The following Arrays are persisting storage arrays for A, X, and B 00309 Teuchos::Array<slu_type> nzvals_; 00311 Teuchos::Array<int> colind_; 00313 Teuchos::Array<int> rowptr_; 00315 mutable Teuchos::Array<slu_type> bvals_; 00317 mutable Teuchos::Array<slu_type> xvals_; 00318 00320 bool in_grid_; 00321 bool same_symbolic_; 00322 mutable bool same_solve_struct_; // may be modified in solve_impl, but still `logically const' 00323 00325 Teuchos::RCP<const Tpetra::Map<local_ordinal_type, 00326 global_ordinal_type, 00327 node_type> > superlu_rowmap_; 00328 00329 }; // End class Superludist 00330 00331 00332 // Specialize the solver_traits template for SuperLU_DIST 00333 template <> 00334 struct solver_traits<Superludist> { 00335 #ifdef HAVE_TEUCHOS_COMPLEX 00336 typedef Meta::make_list3<double, std::complex<double>, SLUD::Z::doublecomplex> supported_scalars; 00337 #else 00338 typedef Meta::make_list1<double> supported_scalars; 00339 #endif 00340 }; 00341 00342 } // end namespace Amesos2 00343 00344 #endif // AMESOS2_SUPERLUDIST_DECL_HPP
1.7.6.1