// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Désiré Nuentsa-Wakam // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "spbenchstyle.h" #ifdef STORMEIGEN_METIS_SUPPORT #include #endif #ifdef STORMEIGEN_CHOLMOD_SUPPORT #include #endif #ifdef STORMEIGEN_UMFPACK_SUPPORT #include #endif #ifdef STORMEIGEN_PARDISO_SUPPORT #include #endif #ifdef STORMEIGEN_SUPERLU_SUPPORT #include #endif #ifdef STORMEIGEN_PASTIX_SUPPORT #include #endif // CONSTANTS #define STORMEIGEN_UMFPACK 10 #define STORMEIGEN_SUPERLU 20 #define STORMEIGEN_PASTIX 30 #define STORMEIGEN_PARDISO 40 #define STORMEIGEN_SPARSELU_COLAMD 50 #define STORMEIGEN_SPARSELU_METIS 51 #define STORMEIGEN_BICGSTAB 60 #define STORMEIGEN_BICGSTAB_ILUT 61 #define STORMEIGEN_GMRES 70 #define STORMEIGEN_GMRES_ILUT 71 #define STORMEIGEN_SIMPLICIAL_LDLT 80 #define STORMEIGEN_CHOLMOD_LDLT 90 #define STORMEIGEN_PASTIX_LDLT 100 #define STORMEIGEN_PARDISO_LDLT 110 #define STORMEIGEN_SIMPLICIAL_LLT 120 #define STORMEIGEN_CHOLMOD_SUPERNODAL_LLT 130 #define STORMEIGEN_CHOLMOD_SIMPLICIAL_LLT 140 #define STORMEIGEN_PASTIX_LLT 150 #define STORMEIGEN_PARDISO_LLT 160 #define STORMEIGEN_CG 170 #define STORMEIGEN_CG_PRECOND 180 using namespace StormEigen; using namespace std; // Global variables for input parameters int MaximumIters; // Maximum number of iterations double RelErr; // Relative error of the computed solution double best_time_val; // Current best time overall solvers int best_time_id; // id of the best solver for the current system template inline typename NumTraits::Real test_precision() { return NumTraits::dummy_precision(); } template<> inline float test_precision() { return 1e-3f; } template<> inline double test_precision() { return 1e-6; } template<> inline float test_precision >() { return test_precision(); } template<> inline double test_precision >() { return test_precision(); } void printStatheader(std::ofstream& out) { // Print XML header // NOTE It would have been much easier to write these XML documents using external libraries like tinyXML or Xerces-C++. out << " \n"; out << " \n"; out << "\n]>"; out << "\n\n\n"; out << "\n \n" ; //root XML element // Print the xsl style section printBenchStyle(out); // List all available solvers out << " \n"; #ifdef STORMEIGEN_UMFPACK_SUPPORT out <<" \n"; out << " LU \n"; out << " UMFPACK \n"; out << " \n"; #endif #ifdef STORMEIGEN_SUPERLU_SUPPORT out <<" \n"; out << " LU \n"; out << " SUPERLU \n"; out << " \n"; #endif #ifdef STORMEIGEN_CHOLMOD_SUPPORT out <<" \n"; out << " LLT SP \n"; out << " CHOLMOD \n"; out << " \n"; out <<" \n"; out << " LLT \n"; out << " CHOLMOD \n"; out << " \n"; out <<" \n"; out << " LDLT \n"; out << " CHOLMOD \n"; out << " \n"; #endif #ifdef STORMEIGEN_PARDISO_SUPPORT out <<" \n"; out << " LU \n"; out << " PARDISO \n"; out << " \n"; out <<" \n"; out << " LLT \n"; out << " PARDISO \n"; out << " \n"; out <<" \n"; out << " LDLT \n"; out << " PARDISO \n"; out << " \n"; #endif #ifdef STORMEIGEN_PASTIX_SUPPORT out <<" \n"; out << " LU \n"; out << " PASTIX \n"; out << " \n"; out <<" \n"; out << " LLT \n"; out << " PASTIX \n"; out << " \n"; out <<" \n"; out << " LDLT \n"; out << " PASTIX \n"; out << " \n"; #endif out <<" \n"; out << " BICGSTAB \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " BICGSTAB_ILUT \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " GMRES_ILUT \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " LDLT \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " LLT \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " CG \n"; out << " STORMEIGEN \n"; out << " \n"; out <<" \n"; out << " LU_COLAMD \n"; out << " STORMEIGEN \n"; out << " \n"; #ifdef STORMEIGEN_METIS_SUPPORT out <<" \n"; out << " LU_METIS \n"; out << " STORMEIGEN \n"; out << " \n"; #endif out << " \n"; } template void call_solver(Solver &solver, const int solver_id, const typename Solver::MatrixType& A, const Matrix& b, const Matrix& refX,std::ofstream& statbuf) { double total_time; double compute_time; double solve_time; double rel_error; Matrix x; BenchTimer timer; timer.reset(); timer.start(); solver.compute(A); if (solver.info() != Success) { std::cerr << "Solver failed ... \n"; return; } timer.stop(); compute_time = timer.value(); statbuf << "