LAMA
|
#include <LUSolver.hpp>
Data Structures | |
struct | lama_gemm |
struct | lama_swap |
struct | LUSolverRuntime |
Public Member Functions | |
LUSolver (const std::string &id) | |
Creates a solver with a given ID. | |
LUSolver (const std::string &id, LoggerPtr logger) | |
Create a gaussian solver with a given ID and a given logger. | |
LUSolver (const LUSolver &other) | |
Copy constructor that copies the status independent solver information. | |
virtual | ~LUSolver () |
LUSolver destructor. | |
virtual void | initialize (const Matrix &coefficients) |
Used to initialize a gaussian solver with a certain matrix A from A*u=f. | |
void | factorMatrixToLU (Matrix &matrix, std::vector< IndexType > &permutation) |
virtual void | solve (Vector &solution, const Vector &rhs) |
Solves the equation system based on the given rhs. | |
void | setTileSize (const IndexType tilesize) |
IndexType | getTileSize () |
virtual void | setDeviceNumber (const IndexType dev) |
virtual IndexType | getDeviceNumber () |
virtual LUSolverRuntime & | getRuntime () |
Returns the complete configuration of the derived class. | |
virtual const LUSolverRuntime & | getConstRuntime () const |
Returns the complete const configuration of the derived class. | |
virtual SolverPtr | copy () |
Copies the status independent solver informations to create a new instance of the same type. | |
virtual void | solveInit (Vector &solution, const Vector &rhs) |
Initializes the solver with rhs and solution. | |
virtual void | solveImpl ()=0 |
Solves the equation system. | |
virtual void | solveFinalize () |
Finalizes the solving process. | |
const std::string & | getId () const |
Returns the ID of this solver. | |
const Vector & | getResidual () const |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this. | |
const Matrix & | getCoefficients () const |
Gets the matrix A from A*u=f. | |
void | setLogger (LoggerPtr logger) |
Redefines mLogger. | |
void | setLogLevel (LogLevel::LogLevel level) |
Switches the loglevel of mLogger. | |
virtual void | setContext (ContextPtr context) |
Sets the context where this solver should be executed. | |
Protected Member Functions | |
virtual void | writeAt (std::ostream &stream) const |
Overrides Printable::writeAt with more useful stuff. | |
Protected Attributes | |
LUSolverRuntime | mLUSolverRuntime |
IndexType | mTilesize |
IndexType | mDev |
std::string | mId |
The ID of this solver. | |
LoggerPtr | mLogger |
The solver logger. | |
ContextPtr | mContext |
For forcing the context solver dependent. | |
Static Protected Attributes | |
static const double | epsilon = 1 + 1E-06 |
Private Member Functions | |
template<typename T > | |
void | computeLUFactorization (DenseMatrix< T > &matrix, std::vector< IndexType > &permutation) |
template<typename T > | |
void | pgetf2 (const IndexType numBlockRows, DenseStorage< T > **const A, IndexType *const ipiv, const PartitionId ROOT) |
template<typename T > | |
void | plaswp (DenseStorage< T > **const A, const PartitionId ROOT, const IndexType *const ipiv, const IndexType n, const lama_swap< T > swap) |
template<typename T > | |
IndexType | piamax_own (const IndexType numBlockCol, DenseStorage< T > **const local, const IndexType col, const IndexType locRow=0) |
template<typename T > | |
void | ptrsm (const enum CBLAS_UPLO uplo, const DenseMatrix< T > &matrix, DenseVector< T > &solution) |
IndexType | computeTilesize (IndexType m, IndexType n) |
void | initializeCommunicator () |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
CommunicatorPtr | mComm |
lama::LUSolver::LUSolver | ( | const std::string & | id | ) |
lama::LUSolver::LUSolver | ( | const std::string & | id, |
LoggerPtr | logger | ||
) |
Create a gaussian solver with a given ID and a given logger.
id | The ID of the solver. |
logger | The logger which shall be used by the solver |
lama::LUSolver::LUSolver | ( | const LUSolver & | other | ) |
Copy constructor that copies the status independent solver information.
lama::LUSolver::~LUSolver | ( | ) | [virtual] |
LUSolver destructor.
void lama::LUSolver::computeLUFactorization | ( | DenseMatrix< T > & | matrix, |
std::vector< IndexType > & | permutation | ||
) | [private] |
References lama::LUSolver::lama_gemm< T >::__queryCuda(), lama::LUSolver::lama_gemm< T >::__recordCuda(), lama::LUSolver::lama_gemm< T >::__synchronizeCuda(), lama::CblasLeft, lama::CblasLower, lama::CblasNoTrans, lama::CblasRowMajor, lama::CblasUnit, computeTilesize(), lama::LUSolver::lama_swap< T >::ctxt, lama::Context::CUDA, lama::LUSolver::lama_swap< T >::func, lama::LUSolver::lama_gemm< T >::func, lama::OpenMPBLAS3::gemm(), lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::Matrix::getColDistribution(), lama::CUDAContext::getComputeSyncToken(), lama::ContextFactory::getContext(), lama::DenseMatrix< T >::getCyclicLocalValues(), lama::DenseStorageView< T >::getData(), lama::Distributed::getDistribution(), lama::Matrix::getNumColumns(), lama::Matrix::getNumRows(), lama::OpenMPLAPACK::getrf(), lama::Context::Host, initializeCommunicator(), LAMA_ASSERT_ERROR, LAMA_CUDA_DRV_CALL, LAMA_REGION, LAMA_THROWEXCEPTION, lama::OpenMPLAPACK::laswp(), mComm, mDev, lama::min(), lama::_MatrixStorage::mNumColumns, lama::_MatrixStorage::mNumRows, mTilesize, pgetf2(), plaswp(), lama::LUSolver::lama_gemm< T >::query, lama::LUSolver::lama_gemm< T >::record, lama::WriteAccess< T >::release(), lama::CUDAHostContextManager::setAsCurrent(), lama::WriteAccess< T >::size(), lama::LUSolver::lama_gemm< T >::stream, lama::OpenMPBLAS1::swap(), lama::LUSolver::lama_gemm< T >::synchronize, and lama::OpenMPBLAS3::trsm().
Referenced by factorMatrixToLU(), and initialize().
IndexType lama::LUSolver::computeTilesize | ( | IndexType | m, |
IndexType | n | ||
) | [private] |
References lama::min(), and mTilesize.
Referenced by computeLUFactorization().
SolverPtr lama::LUSolver::copy | ( | ) | [virtual] |
Copies the status independent solver informations to create a new instance of the same type.
Implements lama::Solver.
References LUSolver().
Referenced by ptrsm().
void lama::LUSolver::factorMatrixToLU | ( | Matrix & | matrix, |
std::vector< IndexType > & | permutation | ||
) |
References computeLUFactorization(), and LAMA_THROWEXCEPTION.
const Matrix & lama::Solver::getCoefficients | ( | ) | const [inherited] |
Gets the matrix A from A*u=f.
References lama::Solver::getConstRuntime(), LAMA_ASSERT_DEBUG, and lama::Solver::SolverRuntime::mCoefficients.
Referenced by lama::InverseSolver::invert(), and piamax_own().
const LUSolver::LUSolverRuntime & lama::LUSolver::getConstRuntime | ( | ) | const [virtual] |
Returns the complete const configuration of the derived class.
Implements lama::Solver.
References mLUSolverRuntime.
IndexType lama::LUSolver::getDeviceNumber | ( | ) | [virtual] |
References mDev.
const std::string & lama::Solver::getId | ( | ) | const [inherited] |
Returns the ID of this solver.
References lama::Solver::mId.
Referenced by lama::IterativeSolver::criteriaAreSatisfied(), lama::IterativeSolver::solveImpl(), and lama::SolverConfigGrammar::SolverConfigGrammar().
const Vector & lama::Solver::getResidual | ( | ) | const [inherited] |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this.
Should be used internally only, because the three vectors mentioned above have to be initialized.
References lama::LogLevel::completeInformation, lama::Vector::create(), lama::SolutionProxy::getConstReference(), lama::Solver::getConstRuntime(), lama::SolutionProxy::isDirty(), LAMA_ASSERT_DEBUG, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::mLogger, lama::Solver::SolverRuntime::mResidual, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, and lama::SolutionProxy::setDirty().
Referenced by lama::ResidualStagnation::isSatisfied(), lama::ResidualThreshold::isSatisfied(), lama::CG::iterate(), lama::GMRES::iterate(), and lama::Logger::logResidual().
LUSolver::LUSolverRuntime & lama::LUSolver::getRuntime | ( | ) | [virtual] |
Returns the complete configuration of the derived class.
Implements lama::Solver.
References mLUSolverRuntime.
Referenced by initialize(), and solve().
References mTilesize.
void lama::LUSolver::initialize | ( | const Matrix & | coefficients | ) | [virtual] |
Used to initialize a gaussian solver with a certain matrix A from A*u=f.
This method initializes a gaussian solver with a certain coefficient- matrix. The given matrix will be overwritten by its lu-factorization.
coefficients | The matrix A from A*u=f. |
Reimplemented from lama::Solver.
References computeLUFactorization(), lama::Matrix::getNumRows(), getRuntime(), LAMA_REGION, lama::LUSolver::LUSolverRuntime::mLUfactorization, and lama::LUSolver::LUSolverRuntime::mPermutation.
void lama::LUSolver::initializeCommunicator | ( | ) | [inline, private] |
References lama::CommunicatorFactory::get(), and mComm.
Referenced by computeLUFactorization().
lama::LUSolver::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
Reimplemented from lama::Solver.
void lama::LUSolver::pgetf2 | ( | const IndexType | numBlockRows, |
DenseStorage< T > **const | A, | ||
IndexType *const | ipiv, | ||
const PartitionId | ROOT | ||
) | [private] |
References lama::CblasRowMajor, epsilon, lama::OpenMPBLAS2::ger(), lama::LAMAInterfaceRegistry::getInterface(), lama::LAMAInterface::getLAPACKInterface(), lama::LAMAInterfaceRegistry::getRegistry(), lama::Context::Host, LAMA_REGION, LAMA_THROWEXCEPTION, mComm, lama::_MatrixStorage::mNumRows, mTilesize, piamax_own(), lama::WriteAccess< T >::release(), lama::OpenMPBLAS1::scal(), lama::OpenMPBLAS1::swap(), and lama::zero.
Referenced by computeLUFactorization().
int lama::LUSolver::piamax_own | ( | const IndexType | numBlockCol, |
DenseStorage< T > **const | local, | ||
const IndexType | col, | ||
const IndexType | locRow = 0 |
||
) | [private] |
void lama::LUSolver::plaswp | ( | DenseStorage< T > **const | A, |
const PartitionId | ROOT, | ||
const IndexType *const | ipiv, | ||
const IndexType | n, | ||
const lama_swap< T > | swap | ||
) | [private] |
References lama::LUSolver::lama_swap< T >::ctxt, lama::LUSolver::lama_swap< T >::func, lama::WriteAccess< T >::get(), LAMA_REGION, mComm, and mTilesize.
Referenced by computeLUFactorization().
void lama::LUSolver::ptrsm | ( | const enum CBLAS_UPLO | uplo, |
const DenseMatrix< T > & | matrix, | ||
DenseVector< T > & | solution | ||
) | [private] |
References lama::CblasLeft, lama::CblasLower, lama::CblasNonUnit, lama::CblasNoTrans, lama::CblasRowMajor, lama::CblasUnit, copy(), lama::OpenMPBLAS2::gemv(), lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::DenseMatrix< T >::getCyclicLocalValues(), lama::DenseStorageView< T >::getData(), lama::DenseVector< T >::getLocalValues(), LAMA_REGION, lama::lowerFin(), lama::lowerInit(), mComm, lama::_MatrixStorage::mNumColumns, lama::_MatrixStorage::mNumRows, lama::OpenMPBLAS3::trsm(), lama::upperFin(), and lama::upperInit().
void lama::Solver::setContext | ( | ContextPtr | context | ) | [virtual, inherited] |
Sets the context where this solver should be executed.
Sets the context where this solver should be executed. Caution: This overrides the context of the coefficients matrix A from A * u = f used to inializ this solver.
[in] | context | the context where this solver should be executed. |
Reimplemented in lama::InverseSolver.
References lama::Solver::mContext.
Referenced by lama::GMRES::initialize().
void lama::LUSolver::setDeviceNumber | ( | const IndexType | dev | ) | [virtual] |
References mDev.
void lama::Solver::setLogger | ( | LoggerPtr | logger | ) | [inherited] |
Redefines mLogger.
References lama::Solver::mLogger.
void lama::Solver::setLogLevel | ( | LogLevel::LogLevel | level | ) | [inherited] |
void lama::LUSolver::setTileSize | ( | const IndexType | tilesize | ) |
References mTilesize.
void lama::LUSolver::solve | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual] |
Solves the equation system based on the given rhs.
The matrix A from A*u=f has to be initialized first! (call gaussianSolver::initialize(matrix) for example). This method uses the lu-factorization, computed in LUSolver::initialize( matrix ), to calculate the solution using forwards and backwards application.
rhs | The right hand side of A*u=f. |
solution | The solution from A*u=f. Mostly used as starting solution for an IterativeSolver. |
Reimplemented from lama::Solver.
References lama::CblasLower, lama::CblasNonUnit, lama::CblasNoTrans, lama::CblasRowMajor, lama::CblasUnit, lama::CblasUpper, lama::Matrix::getColDistribution(), lama::Distributed::getDistribution(), lama::DenseVector< T >::getLocalValues(), lama::Matrix::getNumColumns(), lama::Distribution::getNumPartitions(), lama::Matrix::getNumRows(), getRuntime(), LAMA_REGION, LAMA_THROWEXCEPTION, lama::LUSolver::LUSolverRuntime::mLUfactorization, lama::LUSolver::LUSolverRuntime::mPermutation, lama::WriteAccess< T >::resize(), and lama::OpenMPLAPACK::trtrs().
void lama::Solver::solveFinalize | ( | ) | [virtual, inherited] |
Finalizes the solving process.
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
Referenced by lama::Solver::solve().
virtual void lama::Solver::solveImpl | ( | ) | [pure virtual, inherited] |
Solves the equation system.
Rhs and starting solution have to be initialized first! (call solveInit( rhs, solution ) ). The solver needs to be initialized first with the matrix from the equation to solve, e.g. A from A*u=f (call solver::initialize(A) for example)
This method solves the equation system by using the given rhs and solution. For most solvers the solution-vector is used as a starting solution for the solve process. This class does not take responsibility for deleting the vectors after the solver! Make sure you do not delete the vectors during the solver process.
Implemented in lama::MetaSolver, lama::IterativeSolver, lama::InverseSolver, and lama::TrivialPreconditioner.
Referenced by lama::Solver::solve().
void lama::Solver::solveInit | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual, inherited] |
Initializes the solver with rhs and solution.
[in] | rhs | The right hand side of the system of equations |
[out] | solution | The allocated memory and starting solution for the system |
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
References lama::Matrix::getColDistribution(), lama::Distributed::getDistribution(), lama::Matrix::getNumColumns(), lama::Matrix::getNumRows(), lama::Solver::getRuntime(), LAMA_THROWEXCEPTION, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, lama::Solver::SolverRuntime::mSolveInit, and lama::Vector::size().
Referenced by lama::Solver::solve().
void lama::Solver::writeAt | ( | std::ostream & | stream | ) | const [protected, virtual, inherited] |
Overrides Printable::writeAt with more useful stuff.
Reimplemented from Printable.
References lama::Solver::mId.
const double lama::LUSolver::epsilon = 1 + 1E-06 [static, protected] |
Referenced by pgetf2().
CommunicatorPtr lama::LUSolver::mComm [private] |
Referenced by computeLUFactorization(), initializeCommunicator(), pgetf2(), plaswp(), and ptrsm().
ContextPtr lama::Solver::mContext [protected, inherited] |
For forcing the context solver dependent.
If the context for a solver is set, the context of the input matrix will be ignored
Referenced by lama::SpecializedJacobi::iterateTyped(), lama::InverseSolver::setContext(), and lama::Solver::setContext().
IndexType lama::LUSolver::mDev [protected] |
Referenced by computeLUFactorization(), getDeviceNumber(), and setDeviceNumber().
std::string lama::Solver::mId [protected, inherited] |
The ID of this solver.
Referenced by lama::Solver::getId(), lama::InverseSolver::InverseSolver(), lama::Solver::Solver(), lama::Solver::writeAt(), and lama::Solver::~Solver().
LoggerPtr lama::Solver::mLogger [protected, inherited] |
The solver logger.
May be the NullLogger if no logger has been specified.
Referenced by lama::Solver::getResidual(), lama::IterativeSolver::initialize(), lama::Solver::initialize(), lama::InverseSolver::logEndSolve(), lama::IterativeSolver::logEndSolve(), lama::IterativeSolver::logIterationEndAndResidual(), lama::IterativeSolver::logIterationStart(), lama::SimpleAMG::logSetupDetails(), lama::SimpleAMG::logSetupInfo(), lama::SimpleAMG::logSetupSettings(), lama::SimpleAMG::logSolverInfo(), lama::InverseSolver::logStartSolve(), lama::IterativeSolver::logStartSolve(), lama::MetaSolver::parseConfiguration(), lama::Solver::setLogger(), and lama::Solver::setLogLevel().
LUSolverRuntime lama::LUSolver::mLUSolverRuntime [protected] |
Referenced by getConstRuntime(), and getRuntime().
IndexType lama::LUSolver::mTilesize [protected] |
Referenced by computeLUFactorization(), computeTilesize(), getTileSize(), pgetf2(), plaswp(), and setTileSize().