Skip to content

Commit

Permalink
Merge pull request #12209 from uliegecsm/amesos2-fixes
Browse files Browse the repository at this point in the history
amesos2: solve style and performance warnings
  • Loading branch information
ndellingwood authored Sep 19, 2023
2 parents fc97faa + 107a7fd commit f966e40
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/amesos2/src/Amesos2_Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace Amesos2 {
return query (solver);
}

bool query (const std::string solver_name) {
bool query (const std::string& solver_name) {
// Make the input name canonical by converting to lower case.
const std::string solverName = tolower (solver_name);
//
Expand Down
18 changes: 9 additions & 9 deletions packages/amesos2/src/Amesos2_Factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ namespace Amesos2 {
template < class Matrix,
class Vector >
Solver<Matrix,Vector>*
create(const std::string solverName, const Matrix* A, Vector* X, const Vector* B);
create(const std::string& solverName, const Matrix* A, Vector* X, const Vector* B);


/**
Expand All @@ -290,7 +290,7 @@ namespace Amesos2 {
template < class Matrix,
class Vector >
Teuchos::RCP<Solver<Matrix,Vector> >
create(const std::string solverName,
create(const std::string& solverName,
const Teuchos::RCP<const Matrix> A,
const Teuchos::RCP<Vector> X,
const Teuchos::RCP<const Vector> B);
Expand All @@ -317,7 +317,7 @@ namespace Amesos2 {
template < class Matrix,
class Vector >
Solver<Matrix,Vector>*
create(const std::string solverName, const Matrix* A);
create(const std::string& solverName, const Matrix* A);


/**
Expand All @@ -341,7 +341,7 @@ namespace Amesos2 {
template < class Matrix,
class Vector >
Teuchos::RCP<Solver<Matrix,Vector> >
create(const std::string solverName,
create(const std::string& solverName,
const Teuchos::RCP<const Matrix> A);


Expand Down Expand Up @@ -481,7 +481,7 @@ struct throw_no_matrix_support_exception {
*
* \relatesalso Amesos2::Solver
*/
bool query(const std::string solverName);
bool query(const std::string& solverName);


/////////////////
Expand Down Expand Up @@ -538,7 +538,7 @@ struct throw_no_matrix_support_exception {
template <class Matrix,
class Vector >
Solver<Matrix,Vector>*
create(const std::string solverName, const Matrix* A){
create(const std::string& solverName, const Matrix* A){
return( create(solverName, rcp(A,false),
Teuchos::RCP<Vector>(),
Teuchos::RCP<const Vector>()).getRawPtr() );
Expand All @@ -548,15 +548,15 @@ struct throw_no_matrix_support_exception {
template <class Matrix,
class Vector >
Teuchos::RCP<Solver<Matrix,Vector> >
create(const std::string solverName, const Teuchos::RCP<const Matrix> A){
create(const std::string& solverName, const Teuchos::RCP<const Matrix> A){
return( create(solverName, A, Teuchos::RCP<Vector>(), Teuchos::RCP<const Vector>()) );
}


template <class Matrix,
class Vector >
Teuchos::RCP<Solver<Matrix,Vector> >
create(const std::string solverName, const Matrix* A, Vector* X, const Vector* B)
create(const std::string& solverName, const Matrix* A, Vector* X, const Vector* B)
{
// Pass non-owning Teuchos::RCP objects to other factory method
return( create(solverName, rcp(A,false), rcp(X,false), rcp(B,false)) );
Expand All @@ -566,7 +566,7 @@ struct throw_no_matrix_support_exception {
template <class Matrix,
class Vector >
Teuchos::RCP<Solver<Matrix,Vector> >
create(const std::string solver_name,
create(const std::string& solver_name,
const Teuchos::RCP<const Matrix> A,
const Teuchos::RCP<Vector> X,
const Teuchos::RCP<const Vector> B)
Expand Down
4 changes: 2 additions & 2 deletions packages/amesos2/src/Amesos2_Kokkos_View_Copy_Assign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace Amesos2 {

// allocate dst size if necessary - 2 methods handle 1d and 2d
template<class dst_t, class src_t> // version for 1d view
typename std::enable_if<static_cast<int>(dst_t::Rank) == 1>::type
typename std::enable_if<static_cast<int>(dst_t::rank) == 1>::type
update_dst_size(dst_t & dst, const src_t & src) {
if(dst.extent(0) != src.extent(0)) { // templated just for 1D
dst = dst_t(Kokkos::ViewAllocateWithoutInitializing("dst"),
Expand All @@ -65,7 +65,7 @@ update_dst_size(dst_t & dst, const src_t & src) {
}

template<class dst_t, class src_t> // version for 2d view
typename std::enable_if<static_cast<int>(dst_t::Rank) == 2>::type
typename std::enable_if<static_cast<int>(dst_t::rank) == 2>::type
update_dst_size(dst_t & dst, const src_t & src) { // templated just for 2d
if(dst.extent(0) != src.extent(0) || dst.extent(1) != src.extent(1)) {
dst = dst_t(Kokkos::ViewAllocateWithoutInitializing("dst"),
Expand Down
52 changes: 26 additions & 26 deletions packages/amesos2/src/Amesos2_SolverCore_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace Amesos2 {
* \return a reference to \c this .
* \sa symbolicFactorization(), numericFactorization(), and solve()
*/
super_type& preOrdering();
super_type& preOrdering() override;


/**
Expand All @@ -183,7 +183,7 @@ namespace Amesos2 {
* \return a reference to \c this .
* \sa preOrdering(), numericFactorization(), and solve()
*/
super_type& symbolicFactorization();
super_type& symbolicFactorization() override;


/**
Expand All @@ -209,7 +209,7 @@ namespace Amesos2 {
* \return a reference to \c this
* \sa preOrdering(), symbolicFactorization(), and solve()
*/
super_type& numericFactorization();
super_type& numericFactorization() override;


/**
Expand All @@ -231,9 +231,9 @@ namespace Amesos2 {
*
* \sa preOrdering(), symbolicFactorization(), and numericFactorization()
*/
void solve();
void solve(const Teuchos::Ptr<Vector> X, const Teuchos::Ptr<const Vector> B) const;
void solve(Vector* X, const Vector* B) const;
void solve() override;
void solve(const Teuchos::Ptr<Vector> X, const Teuchos::Ptr<const Vector> B) const override;
void solve(Vector* X, const Vector* B) const override;

int solve_ir(const Teuchos::Ptr<Vector> X, const Teuchos::Ptr<const Vector> B,
const int maxNumIters, const bool verbose) const;
Expand All @@ -253,27 +253,27 @@ namespace Amesos2 {
* matrices. Classes that work only on symmetric matrices would
* return false for non-symmetric matrices. etc.
*/
bool matrixShapeOK();
bool matrixShapeOK() override;

void setA( const Teuchos::RCP<const Matrix> a, EPhase keep_phase = CLEAN );
void setA( const Teuchos::RCP<const Matrix> a, EPhase keep_phase = CLEAN ) override;

void setA( const Matrix* a, EPhase keep_phase = CLEAN ){ setA(Teuchos::rcp(a), keep_phase); }
void setA( const Matrix* a, EPhase keep_phase = CLEAN ) override { setA(Teuchos::rcp(a), keep_phase); }

void setX(const Teuchos::RCP<Vector> x){ multiVecX_ = x; }
void setX(const Teuchos::RCP<Vector> x) override { multiVecX_ = x; }

void setX(Vector* x){ multiVecX_ = Teuchos::rcp(x); }
void setX(Vector* x) override { multiVecX_ = Teuchos::rcp(x); }

const Teuchos::RCP<Vector> getX(){ return( multiVecX_ ); }
const Teuchos::RCP<Vector> getX() override { return( multiVecX_ ); }

Vector* getXRaw(){ return multiVecX_.getRawPtr(); }
Vector* getXRaw() override { return multiVecX_.getRawPtr(); }

void setB(const Teuchos::RCP<const Vector> b){ multiVecB_ = b; }
void setB(const Teuchos::RCP<const Vector> b) override { multiVecB_ = b; }

void setB(const Vector* b){ multiVecB_ = Teuchos::rcp(b); }
void setB(const Vector* b) override { multiVecB_ = Teuchos::rcp(b); }

const Teuchos::RCP<const Vector> getB(){ return( multiVecB_ ); }
const Teuchos::RCP<const Vector> getB() override { return( multiVecB_ ); }

const Vector* getBRaw(){ return multiVecB_.getRawPtr(); }
const Vector* getBRaw() override { return multiVecB_.getRawPtr(); }


/// \name Parameter methods
Expand Down Expand Up @@ -301,7 +301,7 @@ namespace Amesos2 {
* \return a reference to \c this
*/
super_type& setParameters(
const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
const Teuchos::RCP<Teuchos::ParameterList> & parameterList ) override;


/**
Expand All @@ -313,7 +313,7 @@ namespace Amesos2 {
* recognize multiple data types as arguments for a particular parameters
* (eg. recognizing \c "YES" and \c "NO" as well as \c true and \c false ).
*/
Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const override;


/**
Expand Down Expand Up @@ -360,27 +360,27 @@ namespace Amesos2 {
//@{

/// Returns a pointer to the Teuchos::Comm communicator with this operator.
Teuchos::RCP<const Teuchos::Comm<int> > getComm() const
Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override
{
return matrixA_->getComm();
}


/// Returns a reference to this solver's internal status object
inline Status& getStatus() const { return( status_ ); }
inline Status& getStatus() const override { return( status_ ); }


//@} End Accessor methods


/// Returns a short description of this Solver
std::string description() const;
std::string description() const override;


/// Prints the status information about the current solver with some level
/// of verbosity
void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override;


/**
Expand All @@ -401,7 +401,7 @@ namespace Amesos2 {
*/
void printTiming(
Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel) const;
const Teuchos::EVerbosityLevel verbLevel) const override;


/**
Expand All @@ -412,7 +412,7 @@ namespace Amesos2 {
* \param [out] timingParameterList Accepts timing information from the
* current solver
*/
void getTiming(Teuchos::ParameterList& timingParameterList) const;
void getTiming(Teuchos::ParameterList& timingParameterList) const override;


/**
Expand All @@ -422,7 +422,7 @@ namespace Amesos2 {
*
* \return A \c std::string which is the name of this solver
*/
std::string name() const;
std::string name() const override;

private:

Expand Down
2 changes: 1 addition & 1 deletion packages/amesos2/src/Amesos2_Superlu_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Superlu : public SolverCore<Amesos2::Superlu, Matrix, Vector>
//@}

/// Returns a short description of this Solver
std::string description() const;
std::string description() const override;

private:

Expand Down
2 changes: 1 addition & 1 deletion packages/amesos2/src/Amesos2_Tacho_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TachoSolver : public SolverCore<Amesos2::TachoSolver, Matrix, Vector>
//@}

/// Returns a short description of this Solver
std::string description() const;
std::string description() const override;

private:

Expand Down

0 comments on commit f966e40

Please sign in to comment.