|
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 00044 00056 #ifndef AMESOS2_PARDISOMKL_DECL_HPP 00057 #define AMESOS2_PARDISOMKL_DECL_HPP 00058 00059 #include <map> 00060 00061 #include <Teuchos_StandardParameterEntryValidators.hpp> 00062 00063 #include "Amesos2_SolverTraits.hpp" 00064 #include "Amesos2_SolverCore.hpp" 00065 #include "Amesos2_PardisoMKL_FunctionMap.hpp" 00066 00067 00068 namespace Amesos2 { 00069 00070 00081 template <class Matrix, 00082 class Vector> 00083 class PardisoMKL : public SolverCore<Amesos2::PardisoMKL, Matrix, Vector> 00084 { 00085 friend class SolverCore<Amesos2::PardisoMKL,Matrix,Vector>; // Give our base access 00086 // to our private 00087 // implementation funcs 00088 public: 00089 00091 static const char* name; // declaration. Initialization outside. 00092 00093 typedef PardisoMKL<Matrix,Vector> type; 00094 typedef SolverCore<Amesos2::PardisoMKL,Matrix,Vector> super_type; 00095 00096 // Since typedef's are not inheritted, go grab them 00097 typedef typename super_type::scalar_type scalar_type; 00098 typedef typename super_type::local_ordinal_type local_ordinal_type; 00099 typedef typename super_type::global_ordinal_type global_ordinal_type; 00100 typedef typename super_type::global_size_type global_size_type; 00101 00102 typedef TypeMap<Amesos2::PardisoMKL,scalar_type> type_map; 00103 00104 typedef typename type_map::type solver_scalar_type; 00105 typedef typename type_map::magnitude_type solver_magnitude_type; 00106 00107 // This may be PMKL::_INTEGER_t or long long int depending on the 00108 // mapping and input ordinal 00109 typedef typename TypeMap<Amesos2::PardisoMKL,local_ordinal_type>::type int_t; 00110 00111 /* For PardisoMKL we dispatch based on the integer type instead of 00112 * the scalar type: 00113 * - _INTEGER_t => use the pardiso(...) method 00114 * - long long int => use the pardiso_64(...) method 00115 */ 00116 typedef FunctionMap<Amesos2::PardisoMKL,int_t> function_map; 00117 00118 00120 00121 00128 PardisoMKL(Teuchos::RCP<const Matrix> A, 00129 Teuchos::RCP<Vector> X, 00130 Teuchos::RCP<const Vector> B); 00131 00132 00134 ~PardisoMKL( ); 00135 00137 00138 private: 00139 00147 int preOrdering_impl(); 00148 00149 00157 int symbolicFactorization_impl(); 00158 00159 00165 int numericFactorization_impl(); 00166 00167 00178 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X, 00179 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const; 00180 00181 00187 bool matrixShapeOK_impl() const; 00188 00189 00207 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList ); 00208 00209 00214 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const; 00215 00216 00225 bool loadA_impl(EPhase current_phase); 00226 00227 00229 00250 void check_pardiso_mkl_error(EPhase phase, int_t error) const; 00251 00261 void set_pardiso_mkl_matrix_type(int_t mtype = 0); 00262 00263 00264 /* Declare private variables necessary for interaction with the 00265 * PardisoMKL TPL. 00266 * 00267 * For example, the following Arrays are persisting storage arrays 00268 * for A, X, and B that can be used with solvers expecting a 00269 * compressed-row representation of the matrix A. 00270 */ 00271 00273 Teuchos::Array<solver_scalar_type> nzvals_; 00275 Teuchos::Array<int_t> colind_; 00277 Teuchos::Array<int_t> rowptr_; 00279 mutable Teuchos::Array<solver_scalar_type> xvals_; 00281 mutable Teuchos::Array<solver_scalar_type> bvals_; 00282 00284 mutable void* pt_[64]; 00286 int_t mtype_; 00288 int_t n_; 00290 Teuchos::Array<int_t> perm_; 00292 mutable int_t nrhs_; 00293 00296 int_t iparm_[64]; 00297 00299 static const int_t msglvl_; 00300 00301 // We will deal with 1 factor at a time 00302 static const int_t maxfct_; 00303 static const int_t mnum_; 00304 00305 00306 static const bool complex_ 00307 = Meta::or_<Meta::is_same<solver_scalar_type, PMKL::_MKL_Complex8>::value, 00308 Meta::is_same<solver_scalar_type, PMKL::_DOUBLE_COMPLEX_t>::value>::value; 00309 00310 mutable std::map<int,Teuchos::RCP<Teuchos::StringToIntegralParameterEntryValidator<int> > > validators; 00311 00312 }; // End class PardisoMKL 00313 00314 00315 // Specialize the solver_traits struct for PardisoMKL. 00316 template <> 00317 struct solver_traits<PardisoMKL> { 00318 #ifdef HAVE_TEUCHOS_COMPLEX 00319 typedef Meta::make_list6<float, 00320 double, 00321 std::complex<float>, 00322 std::complex<double>, 00323 PMKL::_MKL_Complex8, 00324 PMKL::_DOUBLE_COMPLEX_t> supported_scalars; 00325 #else 00326 typedef Meta::make_list2<float, 00327 double> supported_scalars; 00328 #endif 00329 }; 00330 00331 } // end namespace Amesos 00332 00333 #endif // AMESOS2_PARDISOMKL_DECL_HPP
1.7.6.1