Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#211: Belos: Provide Tpetra versions of all BlockGmres tests #212

Conversation

cwschilly
Copy link
Collaborator

Fixes #211

@cwschilly cwschilly self-assigned this Sep 22, 2023
@cwschilly cwschilly linked an issue Sep 22, 2023 that may be closed by this pull request
@cwschilly cwschilly marked this pull request as draft September 22, 2023 18:59
@github-actions
Copy link

github-actions bot commented Sep 22, 2023

⚡ Code quality check ⚡


🔴 clang-tidy found 174 issues! Click here to see details.

int run(int argc, char *argv[]) {
using ST = typename Tpetra::CrsMatrix<ScalarType>::scalar_type;
using LO = typename Tpetra::CrsMatrix<>::local_ordinal_type;
using GO = typename Tpetra::CrsMatrix<>::global_ordinal_type;
using NT = typename Tpetra::CrsMatrix<>::node_type;

!Line: 66 - warning: function 'run' has cognitive complexity of 59 (threshold 25) [readability-function-cognitive-complexity]
!Line: 123 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 126 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 129 - note: +1
!Line: 140 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 151 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 154 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 157 - note: +1, nesting level increased to 1
!Line: 174 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 175 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 192 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 204 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 206 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 209 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 213 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 213 - note: +1
!Line: 214 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 228 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 241 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 242 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 263 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 264 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 271 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 280 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 289 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 301 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 303 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 306 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 309 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 309 - note: +1
!Line: 311 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 313 - note: +1, nesting level increased to 1
!Line: 315 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 319 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 319 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 319 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 319 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 319 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 319 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 319 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 321 - note: +1, including nesting penalty of 0, nesting level increased to 1

int run(int argc, char *argv[]) {
using ST = typename Tpetra::CrsMatrix<ScalarType>::scalar_type;
using LO = typename Tpetra::CrsMatrix<>::local_ordinal_type;
using GO = typename Tpetra::CrsMatrix<>::global_ordinal_type;
using NT = typename Tpetra::CrsMatrix<>::node_type;

!Line: 66 - warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays]

Teuchos::GlobalMPISession session(&argc, &argv, nullptr);
bool verbose = false;
bool success = true;
try {

!Line: 85 - warning: variable 'session' of type 'Teuchos::GlobalMPISession' can be declared 'const' [misc-const-correctness]

int maxRestarts = 15; // number of restarts allowed
int length = 100;
int initBlockSize = 2;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 1; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed
std::string filename("orsirr1.hb");

!Line: 100 - warning: 15 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

int length = 100;
int initBlockSize = 2;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 1; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed
std::string filename("orsirr1.hb");
MT tol = 1.0e-5; // relative residual tolerance

!Line: 101 - warning: 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

MT tol = 1.0e-5; // relative residual tolerance
MT aug_tol = 1.0e-5; // relative residual tolerance for augmented system
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("use-shift", "no-shift", &useShift, "Whether shift should be used.");

!Line: 106 - warning: variable 'tol' is not initialized [cppcoreguidelines-init-variables]

MT aug_tol = 1.0e-5; // relative residual tolerance for augmented system
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("use-shift", "no-shift", &useShift, "Whether shift should be used.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");

!Line: 107 - warning: variable 'aug_tol' is not initialized [cppcoreguidelines-init-variables]

Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("use-shift", "no-shift", &useShift, "Whether shift should be used.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");

!Line: 109 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("aug-tol",&aug_tol,"Relative residual tolerance used by GMRES solver for augmented systems.");
cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");

!Line: 112 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("aug-tol",&aug_tol,"Relative residual tolerance used by GMRES solver for augmented systems.");
cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");

!Line: 113 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");

!Line: 116 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");

!Line: 117 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {

!Line: 118 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;

!Line: 119 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}

!Line: 120 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose) {

!Line: 121 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose) {
frequency = -1; // reset frequency if test is not verbose

!Line: 122 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose) {
frequency = -1; // reset frequency if test is not verbose
}

!Line: 123 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

Belos::Tpetra::HarwellBoeingReader<tcrsmatrix_t> reader( comm );
RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 132 - warning: variable 'reader' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 133 - warning: variable 'A' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 133 - warning: variable name 'A' is too short, expected at least 3 characters [readability-identifier-length]

RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************
const int numGlobalElements = Map->getGlobalNumElements();

!Line: 134 - warning: variable 'Map' is not initialized [cppcoreguidelines-init-variables]

if (maxIters == -1)
maxIters = numGlobalElements - 1; // maximum number of iterations to run
ParameterList belosList;
belosList.set( "Num Blocks", length ); // Maximum number of blocks in Krylov factorization
belosList.set( "Block Size", initBlockSize ); // Blocksize to be used by iterative solver

!Line: 140 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (frequency > 0)
belosList.set( "Output Frequency", frequency );
}
else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );

!Line: 154 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );
// *****Construct solution std::vector and random right-hand-sides *****
RCP<MV> initX = rcp( new MV(Map, initNumRHS) );
RCP<MV> initB = rcp( new MV(Map, initNumRHS) );

!Line: 157 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP<MV> initX = rcp( new MV(Map, initNumRHS) );
RCP<MV> initB = rcp( new MV(Map, initNumRHS) );
Belos::LinearMultiShiftProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");
initProblem.setShift( useShift );

!Line: 161 - warning: variable 'initX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> initB = rcp( new MV(Map, initNumRHS) );
Belos::LinearMultiShiftProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");
initProblem.setShift( useShift );
bool set = initProblem.setProblem();

!Line: 162 - warning: variable 'initB' is not initialized [cppcoreguidelines-init-variables]

Belos::LinearMultiShiftProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");
initProblem.setShift( useShift );
bool set = initProblem.setProblem();
MVT::MvRandom( *initX );

!Line: 164 - warning: variable 'initProblem' is not initialized [cppcoreguidelines-init-variables]

MVT::MvRandom( *initX );
initProblem.applyOp( *initX, *initB );
initX->putScalar( 0.0 );
set = initProblem.setProblem( initX, initB );
if (set == false) {

!Line: 169 - warning: variable 'initX' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Initial Belos::LinearMultiShiftProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 174 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Initial Belos::LinearMultiShiftProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 175 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP< Belos::SolverManager<ST,MV,OP> > initSolver
= rcp( new Belos::PseudoBlockGmresSolMgr<ST,MV,OP>( rcp(&initProblem,false), rcp(&belosList,false) ) );
// Perform solve
Belos::ReturnType ret = initSolver->solve();

!Line: 184 - warning: variable 'initSolver' is not initialized [cppcoreguidelines-init-variables]

std::vector<int> initIndex( initNumRHS );
for (int i=0; i<initNumRHS; ++i)
initIndex[i] = i;
initProblem.setLSIndex( initIndex );
bool badRes = false;

!Line: 191 - warning: variable 'initIndex' is not initialized [cppcoreguidelines-init-variables]

for (int i=0; i<initNumRHS; ++i)
initIndex[i] = i;
initProblem.setLSIndex( initIndex );
bool badRes = false;
std::vector<ST> actualResids( initNumRHS );

!Line: 192 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

for (int i=0; i<initNumRHS; ++i)
initIndex[i] = i;
initProblem.setLSIndex( initIndex );
bool badRes = false;
std::vector<ST> actualResids( initNumRHS );

!Line: 192 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

std::vector<ST> actualResids( initNumRHS );
std::vector<ST> rhsNorm( initNumRHS );
MV initR( Map, initNumRHS );
initProblem.applyOp( *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );

!Line: 197 - warning: variable 'actualResids' is not initialized [cppcoreguidelines-init-variables]

std::vector<ST> rhsNorm( initNumRHS );
MV initR( Map, initNumRHS );
initProblem.applyOp( *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );
MVT::MvNorm( *initB, rhsNorm );

!Line: 198 - warning: variable 'rhsNorm' is not initialized [cppcoreguidelines-init-variables]

MV initR( Map, initNumRHS );
initProblem.applyOp( *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );
MVT::MvNorm( *initB, rhsNorm );
if (procVerbose) {

!Line: 199 - warning: variable 'initR' is not initialized [cppcoreguidelines-init-variables]

for (int i=0; i<initNumRHS; i++) {
ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol) badRes = true;
}
}

!Line: 206 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol) badRes = true;
}
}

!Line: 207 - warning: variable 'actRes' is not initialized [cppcoreguidelines-init-variables]

if (actRes > tol) badRes = true;
}
}
if (ret != Belos::Converged || badRes==true) {
if (procVerbose)

!Line: 209 - warning: statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements]

if (ret != Belos::Converged || badRes==true) {
if (procVerbose)
std::cout << std::endl << "ERROR: Initial solve did not converge to solution!" << std::endl;
return -1;
}

!Line: 213 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Initial solve did not converge to solution!" << std::endl;
return -1;
}
// ***************Construct augmented linear system****************

!Line: 214 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP<MV> augX = rcp( new MV(Map, initNumRHS+augNumRHS) );
RCP<MV> augB = rcp( new MV(Map, initNumRHS+augNumRHS) );
Belos::LinearMultiShiftProblem<ST,MV,OP> augProblem( A, augX, augB );
augProblem.setLabel("Belos Aug");
augProblem.setShift( useShift );
set = augProblem.setProblem();

!Line: 221 - warning: variable 'augX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> augB = rcp( new MV(Map, initNumRHS+augNumRHS) );
Belos::LinearMultiShiftProblem<ST,MV,OP> augProblem( A, augX, augB );
augProblem.setLabel("Belos Aug");
augProblem.setShift( useShift );
set = augProblem.setProblem();

!Line: 222 - warning: variable 'augB' is not initialized [cppcoreguidelines-init-variables]

Belos::LinearMultiShiftProblem<ST,MV,OP> augProblem( A, augX, augB );
augProblem.setLabel("Belos Aug");
augProblem.setShift( useShift );
set = augProblem.setProblem();
if (augNumRHS) {

!Line: 223 - warning: variable 'augProblem' is not initialized [cppcoreguidelines-init-variables]

MVT::MvRandom( *augX );
augProblem.applyOp( *augX, *augB );
augX->putScalar( 0.0 );
}
// Copy previous linear system into

!Line: 229 - warning: variable 'augX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> tmpX = rcp( new MV( *augX ) );
RCP<MV> tmpB = rcp( new MV( *augB ) );
tmpX->scale( 1.0, *augX );
tmpB->scale( 1.0, *augB );
set = augProblem.setProblem( augX, augB );

!Line: 235 - warning: variable 'tmpX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> tmpB = rcp( new MV( *augB ) );
tmpX->scale( 1.0, *augX );
tmpB->scale( 1.0, *augB );
set = augProblem.setProblem( augX, augB );
if (set == false) {

!Line: 236 - warning: variable 'tmpB' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Augmented Belos::LinearMultiShiftProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 241 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Augmented Belos::LinearMultiShiftProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 242 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP< Belos::SolverManager<ST,MV,OP> > augSolver
= rcp( new Belos::PseudoBlockGmresSolMgr<ST,MV,OP>( rcp(&augProblem,false), rcp(&belosList,false) ) );
// Perform solve
ret = augSolver->solve();

!Line: 257 - warning: variable 'augSolver' is not initialized [cppcoreguidelines-init-variables]

if (procVerbose)
std::cout << std::endl << "ERROR: Augmented solver did not converge to solution!" << std::endl;
return -1;
}
// **********Print out information about problem*******************

!Line: 264 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

std::vector<int> totalIndex( totalNumRHS );
for (int i=0; i<totalNumRHS; ++i)
totalIndex[i] = i;
augProblem.setLSIndex( totalIndex );
badRes = false;

!Line: 288 - warning: variable 'totalIndex' is not initialized [cppcoreguidelines-init-variables]

for (int i=0; i<totalNumRHS; ++i)
totalIndex[i] = i;
augProblem.setLSIndex( totalIndex );
badRes = false;
actualResids.resize( totalNumRHS );

!Line: 289 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

for (int i=0; i<totalNumRHS; ++i)
totalIndex[i] = i;
augProblem.setLSIndex( totalIndex );
badRes = false;
actualResids.resize( totalNumRHS );

!Line: 289 - warning: backward branch (for loop) is ID-dependent due to variable reference to 'totalNumRHS' and may cause performance degradation [altera-id-dependent-backward-branch]

for (int i=0; i<totalNumRHS; ++i)
totalIndex[i] = i;
augProblem.setLSIndex( totalIndex );
badRes = false;
actualResids.resize( totalNumRHS );

!Line: 289 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

MV augR( Map, totalNumRHS );
augProblem.apply( *augX, augR );
MVT::MvAddMv( -1.0, augR, 1.0, *augB, augR );
MVT::MvNorm( augR, actualResids );
MVT::MvNorm( *augB, rhsNorm );
if (procVerbose) {

!Line: 296 - warning: variable 'augR' is not initialized [cppcoreguidelines-init-variables]
!Line: 287 - note: inferred assignment of ID-dependent value from ID-dependent  [altera-id-dependent-backward-branch]

for ( int i=0; i<totalNumRHS; i++) {
ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol ) badRes = true;
}
}

!Line: 303 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

for ( int i=0; i<totalNumRHS; i++) {
ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol ) badRes = true;
}
}

!Line: 303 - warning: backward branch (for loop) is ID-dependent due to variable reference to 'totalNumRHS' and may cause performance degradation [altera-id-dependent-backward-branch]

ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol ) badRes = true;
}
}
if (ret!=Belos::Converged || badRes==true) {

!Line: 304 - warning: variable 'actRes' is not initialized [cppcoreguidelines-init-variables]

if (actRes > tol ) badRes = true;
}
}
if (ret!=Belos::Converged || badRes==true) {
success = false;
if (procVerbose)

!Line: 306 - warning: statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements]

if (ret!=Belos::Converged || badRes==true) {
success = false;
if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
} else {
success = true;

!Line: 309 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
} else {
success = true;
if (procVerbose)
std::cout << "End Result: TEST PASSED" << std::endl;

!Line: 311 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (procVerbose)
std::cout << "End Result: TEST PASSED" << std::endl;
}
}
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose,std::cerr,success);

!Line: 315 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

int run(int argc, char *argv[]) {
//
Teuchos::GlobalMPISession session(&argc, &argv, nullptr);
//
using ST = typename Tpetra::Vector<ScalarType>::scalar_type;
using LO = typename Tpetra::Vector<>::local_ordinal_type;

!Line: 62 - warning: function 'run' has cognitive complexity of 81 (threshold 25) [readability-function-cognitive-complexity]
!Line: 116 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 119 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 122 - note: +1
!Line: 141 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 151 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 154 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 157 - note: +1, nesting level increased to 1
!Line: 163 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 164 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 182 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 183 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 200 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 202 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 221 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 222 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 236 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 238 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 240 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 253 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 254 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 267 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 268 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 280 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 282 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 284 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 310 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 311 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 323 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 325 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 327 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 343 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 344 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 364 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 365 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 367 - note: +1, nesting level increased to 2
!Line: 391 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 393 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 395 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 403 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 413 - note: +1
!Line: 415 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 416 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 418 - note: +1, nesting level increased to 1
!Line: 419 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 423 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 423 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 423 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 423 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 423 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 423 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 423 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 425 - note: +1, including nesting penalty of 0, nesting level increased to 1

int run(int argc, char *argv[]) {
//
Teuchos::GlobalMPISession session(&argc, &argv, nullptr);
//
using ST = typename Tpetra::Vector<ScalarType>::scalar_type;
using LO = typename Tpetra::Vector<>::local_ordinal_type;

!Line: 62 - warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays]

Teuchos::GlobalMPISession session(&argc, &argv, nullptr);
//
using ST = typename Tpetra::Vector<ScalarType>::scalar_type;
using LO = typename Tpetra::Vector<>::local_ordinal_type;
using GO = typename Tpetra::Vector<>::global_ordinal_type;
using NT = typename Tpetra::Vector<>::node_type;

!Line: 64 - warning: variable 'session' of type 'Teuchos::GlobalMPISession' can be declared 'const' [misc-const-correctness]

int numrhs = 1;
int maxRestarts = 15; // number of restarts allowed
int maxIters = -1; // maximum number of iterations allowed per linear system
std::string filename("orsirr1.hb");
std::string ortho("DGKS");
MT tol = 1.0e-5; // relative residual tolerance

!Line: 99 - warning: variable 'numrhs' of type 'int' can be declared 'const' [misc-const-correctness]

int maxRestarts = 15; // number of restarts allowed
int maxIters = -1; // maximum number of iterations allowed per linear system
std::string filename("orsirr1.hb");
std::string ortho("DGKS");
MT tol = 1.0e-5; // relative residual tolerance

!Line: 100 - warning: 15 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

MT tol = 1.0e-5; // relative residual tolerance
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("pseudo","regular",&pseudo,"Use pseudo-block Gmres to solve the linear systems.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");

!Line: 104 - warning: variable 'tol' is not initialized [cppcoreguidelines-init-variables]

Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("pseudo","regular",&pseudo,"Use pseudo-block Gmres to solve the linear systems.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("ortho",&ortho,"Orthogonalization routine used by Gmres solver.");

!Line: 106 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("ortho",&ortho,"Orthogonalization routine used by Gmres solver.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by Gmres solver.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for Gmres solver.");
cmdp.setOption("blockSize",&blockSize,"Block size used by Gmres.");

!Line: 109 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("ortho",&ortho,"Orthogonalization routine used by Gmres solver.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by Gmres solver.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for Gmres solver.");
cmdp.setOption("blockSize",&blockSize,"Block size used by Gmres.");
cmdp.setOption("maxIters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");

!Line: 110 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("ortho",&ortho,"Orthogonalization routine used by Gmres solver.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by Gmres solver.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for Gmres solver.");
cmdp.setOption("blockSize",&blockSize,"Block size used by Gmres.");
cmdp.setOption("maxIters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {

!Line: 111 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for Gmres solver.");
cmdp.setOption("blockSize",&blockSize,"Block size used by Gmres.");
cmdp.setOption("maxIters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}

!Line: 113 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("blockSize",&blockSize,"Block size used by Gmres.");
cmdp.setOption("maxIters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)

!Line: 114 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("maxIters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)
frequency = -1; // reset frequency if test is not verbose

!Line: 115 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)
frequency = -1; // reset frequency if test is not verbose

!Line: 116 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

if (!verbose)
frequency = -1; // reset frequency if test is not verbose
procVerbose = ( verbose && (myPID==0) );
// Get the problem

!Line: 119 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

Belos::Tpetra::HarwellBoeingReader<tcrsmatrix_t> reader( comm );
RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

!Line: 125 - warning: variable 'reader' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;
X = rcp( new MV(Map,numrhs) );

!Line: 126 - warning: variable 'A' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;
X = rcp( new MV(Map,numrhs) );

!Line: 126 - warning: variable name 'A' is too short, expected at least 3 characters [readability-identifier-length]

RCP<const tmap_t> Map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;
X = rcp( new MV(Map,numrhs) );
MVT::MvRandom( *X );

!Line: 127 - warning: variable 'Map' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> B, X;
X = rcp( new MV(Map,numrhs) );
MVT::MvRandom( *X );
B = rcp( new MV(Map,numrhs) );
OPT::Apply( *A, *X, *B );
MVT::MvInit( *X, 0.0 );

!Line: 130 - warning: variable 'B' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> B, X;
X = rcp( new MV(Map,numrhs) );
MVT::MvRandom( *X );
B = rcp( new MV(Map,numrhs) );
OPT::Apply( *A, *X, *B );
MVT::MvInit( *X, 0.0 );

!Line: 130 - warning: variable name 'B' is too short, expected at least 3 characters [readability-identifier-length]

MVT::MvRandom( *X );
B = rcp( new MV(Map,numrhs) );
OPT::Apply( *A, *X, *B );
MVT::MvInit( *X, 0.0 );
// ********Other information used by block solver***********

!Line: 132 - warning: variable 'X' is not initialized [cppcoreguidelines-init-variables]

MVT::MvRandom( *X );
B = rcp( new MV(Map,numrhs) );
OPT::Apply( *A, *X, *B );
MVT::MvInit( *X, 0.0 );
// ********Other information used by block solver***********

!Line: 132 - warning: variable name 'X' is too short, expected at least 3 characters [readability-identifier-length]

if (maxIters == -1)
maxIters = NumGlobalElements/blockSize - 1; // maximum number of iterations to run
ParameterList belosList;
belosList.set( "Num Blocks", maxIters ); // Maximum number of blocks in Krylov factorization
belosList.set( "Block Size", blockSize ); // Blocksize to be used by iterative solver

!Line: 141 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (frequency > 0)
belosList.set( "Output Frequency", frequency );
}
else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );

!Line: 154 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );
// Construct an unpreconditioned linear problem instance.
Belos::LinearProblem<ST,MV,OP> problem( A, X, B );
bool set = problem.setProblem();

!Line: 157 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

Belos::LinearProblem<ST,MV,OP> problem( A, X, B );
bool set = problem.setProblem();
if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;

!Line: 161 - warning: variable 'problem' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 163 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 164 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP< Belos::SolverManager<ST,MV,OP> > solver;
if (pseudo)
solver = rcp( new Belos::PseudoBlockGmresSolMgr<ST,MV,OP>( rcp(&problem,false), rcp(&belosList,false) ) );
else
solver = rcp( new Belos::BlockGmresSolMgr<ST,MV,OP>( rcp(&problem,false), rcp(&belosList,false) ) );

!Line: 173 - warning: variable 'solver' is not initialized [cppcoreguidelines-init-variables]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
return -1;
}
// Get the number of iterations for this solve.

!Line: 183 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

std::vector<ST> actual_resids( numrhs );
std::vector<ST> rhs_norm( numrhs );
MV resid(Map, numrhs);
OPT::Apply( *A, *X, resid );
MVT::MvAddMv( -1.0, resid, 1.0, *B, resid );
MVT::MvNorm( resid, actual_resids );

!Line: 193 - warning: variable 'actual_resids' is not initialized [cppcoreguidelines-init-variables]

std::vector<ST> rhs_norm( numrhs );
MV resid(Map, numrhs);
OPT::Apply( *A, *X, resid );
MVT::MvAddMv( -1.0, resid, 1.0, *B, resid );
MVT::MvNorm( resid, actual_resids );
MVT::MvNorm( *B, rhs_norm );

!Line: 194 - warning: variable 'rhs_norm' is not initialized [cppcoreguidelines-init-variables]

MV resid(Map, numrhs);
OPT::Apply( *A, *X, resid );
MVT::MvAddMv( -1.0, resid, 1.0, *B, resid );
MVT::MvNorm( resid, actual_resids );
MVT::MvNorm( *B, rhs_norm );
if (procVerbose) {

!Line: 195 - warning: variable 'resid' is not initialized [cppcoreguidelines-init-variables]

for ( int i=0; i<numrhs; i++) {
std::cout<<"Problem "<<i<<" : \t"<< actual_resids[i]/rhs_norm[i] <<std::endl;
}
}
// -----------------------------------------------------------------

!Line: 202 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
return -1;
}
// Compute actual residuals.

!Line: 222 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

std::vector<ST> actual_resids2( numrhs );
MV resid2(Map, numrhs);
OPT::Apply( *A, *X, resid2 );
MVT::MvAddMv( -1.0, resid2, 1.0, *B, resid2 );
MVT::MvNorm( resid2, actual_resids );
MVT::MvAddMv( -1.0, resid2, 1.0, resid, resid2 );

!Line: 228 - warning: variable 'actual_resids2' is not initialized [cppcoreguidelines-init-variables]

MV resid2(Map, numrhs);
OPT::Apply( *A, *X, resid2 );
MVT::MvAddMv( -1.0, resid2, 1.0, *B, resid2 );
MVT::MvNorm( resid2, actual_resids );
MVT::MvAddMv( -1.0, resid2, 1.0, resid, resid2 );
MVT::MvNorm( resid2, actual_resids2 );

!Line: 229 - warning: variable 'resid2' is not initialized [cppcoreguidelines-init-variables]

for ( int i=0; i<numrhs; i++) {
std::cout<<"Problem "<<i<<" : \t"<< actual_resids[i]/rhs_norm[i] <<std::endl;
if ( actual_resids2[i] > SCT::prec() ) {
badRes = true;
std::cout << "Resolve residual vector is too different from first solve residual vector: " << actual_resids2[i] << std::endl;
}

!Line: 238 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
solver->setProblem( rcp(&problem,false) );

!Line: 253 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
solver->setProblem( rcp(&problem,false) );

!Line: 254 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
return -1;
}
// Compute actual residuals.

!Line: 268 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

for ( int i=0; i<numrhs; i++) {
std::cout<<"Problem "<<i<<" : \t"<< actual_resids[i]/rhs_norm[i] <<std::endl;
if ( actual_resids2[i] > SCT::prec() ) {
badRes = true;
std::cout << "Resolve residual vector is too different from first solve residual vector: " << actual_resids2[i] << std::endl;
}

!Line: 282 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
return -1;
}
// Compute actual residuals.

!Line: 311 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

for ( int i=0; i<numrhs; i++) {
std::cout<<"Problem "<<i<<" : \t"<< actual_resids[i]/rhs_norm[i] <<std::endl;
if ( actual_resids2[i] > SCT::prec() ) {
badRes = true;
std::cout << "Resolve residual vector is too different from first solve residual vector: " << actual_resids2[i] << std::endl;
}

!Line: 325 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

RCP<MV> X2 = MVT::Clone(*X, numrhs);
MVT::MvInit( *X2, 0.0 );
Belos::LinearProblem<ST,MV,OP> problem2( A, X2, B );
problem2.setLabel("Belos Resolve");
set = problem2.setProblem();
if (set == false) {

!Line: 338 - warning: variable 'X2' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> X2 = MVT::Clone(*X, numrhs);
MVT::MvInit( *X2, 0.0 );
Belos::LinearProblem<ST,MV,OP> problem2( A, X2, B );
problem2.setLabel("Belos Resolve");
set = problem2.setProblem();
if (set == false) {

!Line: 338 - warning: variable name 'X2' is too short, expected at least 3 characters [readability-identifier-length]

Belos::LinearProblem<ST,MV,OP> problem2( A, X2, B );
problem2.setLabel("Belos Resolve");
set = problem2.setProblem();
if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;

!Line: 340 - warning: variable 'problem2' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 343 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 344 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (pseudo)
std::cout << std::endl << "Valid parameters from the pseudo-block Gmres solver manager:" << std::endl;
else
std::cout << std::endl << "Valid parameters from the block Gmres solver manager:" << std::endl;
std::cout << *validList << std::endl;

!Line: 365 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

else
std::cout << std::endl << "Valid parameters from the block Gmres solver manager:" << std::endl;
std::cout << *validList << std::endl;
}

!Line: 367 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

for ( int i=0; i<numrhs; i++) {
std::cout<<"Problem "<<i<<" : \t"<< actual_resids[i]/rhs_norm[i] <<std::endl;
if ( actual_resids2[i] > SCT::prec() ) {
badRes = true;
std::cout << "Resolve residual vector is too different from first solve residual vector: " << actual_resids2[i] << std::endl;
}

!Line: 393 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

if (procVerbose)
std::cout << "End Result: TEST PASSED" << std::endl;
} else {
if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
}

!Line: 416 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (procVerbose)
std::cout << "End Result: TEST FAILED" << std::endl;
}
}
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);

!Line: 419 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

int run(int argc, char *argv[]) {
using ST = typename Tpetra::CrsMatrix<ScalarType>::scalar_type;
using LO = typename Tpetra::CrsMatrix<>::local_ordinal_type;
using GO = typename Tpetra::CrsMatrix<>::global_ordinal_type;
using NT = typename Tpetra::CrsMatrix<>::node_type;

!Line: 67 - warning: function 'run' has cognitive complexity of 57 (threshold 25) [readability-function-cognitive-complexity]
!Line: 124 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 127 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 130 - note: +1
!Line: 141 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 152 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 155 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 158 - note: +1, nesting level increased to 1
!Line: 173 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 174 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 198 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 200 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 203 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 207 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 207 - note: +1
!Line: 208 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 217 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 233 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 234 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 255 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 256 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 263 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 272 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 287 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 289 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 292 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 295 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 295 - note: +1
!Line: 297 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 299 - note: +1, nesting level increased to 1
!Line: 301 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 305 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 305 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 305 - note: +3, including nesting penalty of 2, nesting level increased to 3
!Line: 305 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 305 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 305 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 305 - note: +2, including nesting penalty of 1, nesting level increased to 2
!Line: 307 - note: +1, including nesting penalty of 0, nesting level increased to 1

int run(int argc, char *argv[]) {
using ST = typename Tpetra::CrsMatrix<ScalarType>::scalar_type;
using LO = typename Tpetra::CrsMatrix<>::local_ordinal_type;
using GO = typename Tpetra::CrsMatrix<>::global_ordinal_type;
using NT = typename Tpetra::CrsMatrix<>::node_type;

!Line: 67 - warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays]

Teuchos::GlobalMPISession session(&argc, &argv, nullptr);
bool verbose = false;
bool success = true;
try {

!Line: 88 - warning: variable 'session' of type 'Teuchos::GlobalMPISession' can be declared 'const' [misc-const-correctness]

int initNumRHS = 5; // how many right-hand sides get solved first
int augNumRHS = 10; // how many right-hand sides are augmented to the first group
int maxRestarts = 15; // number of restarts allowed
int length = 100;
int initBlockSize = 5;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 3; // blocksize used for the augmented pseudo-block GMRES solve

!Line: 100 - warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

int augNumRHS = 10; // how many right-hand sides are augmented to the first group
int maxRestarts = 15; // number of restarts allowed
int length = 100;
int initBlockSize = 5;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 3; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed

!Line: 101 - warning: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

int maxRestarts = 15; // number of restarts allowed
int length = 100;
int initBlockSize = 5;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 3; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed
std::string filename("orsirr1.hb");

!Line: 102 - warning: 15 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

int length = 100;
int initBlockSize = 5;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 3; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed
std::string filename("orsirr1.hb");
MT tol = 1.0e-5; // relative residual tolerance

!Line: 103 - warning: 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

int initBlockSize = 5;// blocksize used for the initial pseudo-block GMRES solve
int augBlockSize = 3; // blocksize used for the augmented pseudo-block GMRES solve
int maxIters = -1; // maximum iterations allowed
std::string filename("orsirr1.hb");
MT tol = 1.0e-5; // relative residual tolerance
MT aug_tol = 1.0e-5; // relative residual tolerance for augmented system

!Line: 104 - warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

MT tol = 1.0e-5; // relative residual tolerance
MT aug_tol = 1.0e-5; // relative residual tolerance for augmented system
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");

!Line: 108 - warning: variable 'tol' is not initialized [cppcoreguidelines-init-variables]

MT aug_tol = 1.0e-5; // relative residual tolerance for augmented system
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");

!Line: 109 - warning: variable 'aug_tol' is not initialized [cppcoreguidelines-init-variables]

Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("aug-tol",&aug_tol,"Relative residual tolerance used by GMRES solver for augmented systems.");

!Line: 111 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("frequency",&frequency,"Solvers frequency for printing residuals (#iters).");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("aug-tol",&aug_tol,"Relative residual tolerance used by GMRES solver for augmented systems.");
cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");

!Line: 113 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("aug-tol",&aug_tol,"Relative residual tolerance used by GMRES solver for augmented systems.");
cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");

!Line: 114 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("init-num-rhs",&initNumRHS,"Number of right-hand sides to be initially solved for.");
cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");

!Line: 117 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("aug-num-rhs",&augNumRHS,"Number of right-hand sides augmenting the initial solve.");
cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");

!Line: 118 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("max-restarts",&maxRestarts,"Maximum number of restarts allowed for GMRES solver.");
cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {

!Line: 119 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("block-size",&initBlockSize,"Block size used by GMRES for the initial solve.");
cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;

!Line: 120 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("aug-block-size",&augBlockSize,"Block size used by GMRES for the augmented solve.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}

!Line: 121 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)

!Line: 122 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

cmdp.setOption("subspace-size",&length,"Dimension of Krylov subspace used by GMRES.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)
frequency = -1; // reset frequency if test is not verbose

!Line: 123 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (!verbose)
frequency = -1; // reset frequency if test is not verbose

!Line: 124 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

if (!verbose)
frequency = -1; // reset frequency if test is not verbose
procVerbose = verbose && (myPID==0); /* Only print on zero processor */
// Get the problem

!Line: 127 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

Belos::Tpetra::HarwellBoeingReader<tcrsmatrix_t> reader( comm );
RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 133 - warning: variable 'reader' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 134 - warning: variable 'A' is not initialized [cppcoreguidelines-init-variables]

RCP<tcrsmatrix_t> A = reader.readFromFile( filename );
RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************

!Line: 134 - warning: variable name 'A' is too short, expected at least 3 characters [readability-identifier-length]

RCP<const tmap_t> Map = A->getDomainMap();
// ********Other information used by block solver***********
// *****************(can be user specified)******************
const int numGlobalElements = Map->getGlobalNumElements();

!Line: 135 - warning: variable 'Map' is not initialized [cppcoreguidelines-init-variables]

if (maxIters == -1)
maxIters = numGlobalElements - 1; // maximum number of iterations to run
ParameterList belosList;
belosList.set( "Num Blocks", length ); // Maximum number of blocks in Krylov factorization
belosList.set( "Block Size", initBlockSize ); // Blocksize to be used by iterative solver

!Line: 141 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (frequency > 0)
belosList.set( "Output Frequency", frequency );
}
else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );

!Line: 155 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

else
belosList.set( "Verbosity", Belos::Errors + Belos::Warnings );
// *****Construct solution std::vector and random right-hand-sides *****
RCP<MV> initX = rcp( new MV(Map, initNumRHS) );

!Line: 158 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP<MV> initX = rcp( new MV(Map, initNumRHS) );
RCP<MV> initB = rcp( new MV(Map, initNumRHS) );
MVT::MvRandom( *initX );
OPT::Apply( *A, *initX, *initB );
initX->putScalar( 0.0 );
Belos::LinearProblem<ST,MV,OP> initProblem( A, initX, initB );

!Line: 163 - warning: variable 'initX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> initB = rcp( new MV(Map, initNumRHS) );
MVT::MvRandom( *initX );
OPT::Apply( *A, *initX, *initB );
initX->putScalar( 0.0 );
Belos::LinearProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");

!Line: 164 - warning: variable 'initB' is not initialized [cppcoreguidelines-init-variables]

MVT::MvRandom( *initX );
OPT::Apply( *A, *initX, *initB );
initX->putScalar( 0.0 );
Belos::LinearProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");

!Line: 165 - warning: variable 'initX' is not initialized [cppcoreguidelines-init-variables]

Belos::LinearProblem<ST,MV,OP> initProblem( A, initX, initB );
initProblem.setLabel("Belos Init");
bool set = initProblem.setProblem();
if (set == false) {

!Line: 168 - warning: variable 'initProblem' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Initial Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 173 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Initial Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 174 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP< Belos::SolverManager<ST,MV,OP> > initSolver
= rcp( new Belos::PseudoBlockGmresSolMgr<ST,MV,OP>( rcp(&initProblem,false), rcp(&belosList,false) ) );
// Perform solve
Belos::ReturnType ret = initSolver->solve();

!Line: 183 - warning: variable 'initSolver' is not initialized [cppcoreguidelines-init-variables]

std::vector<ST> actualResids( initNumRHS );
std::vector<ST> rhsNorm( initNumRHS );
MV initR( Map, initNumRHS );
OPT::Apply( *A, *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );

!Line: 191 - warning: variable 'actualResids' is not initialized [cppcoreguidelines-init-variables]

std::vector<ST> rhsNorm( initNumRHS );
MV initR( Map, initNumRHS );
OPT::Apply( *A, *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );
MVT::MvNorm( *initB, rhsNorm );

!Line: 192 - warning: variable 'rhsNorm' is not initialized [cppcoreguidelines-init-variables]

MV initR( Map, initNumRHS );
OPT::Apply( *A, *initX, initR );
MVT::MvAddMv( -1.0, initR, 1.0, *initB, initR );
MVT::MvNorm( initR, actualResids );
MVT::MvNorm( *initB, rhsNorm );
if (procVerbose) {

!Line: 193 - warning: variable 'initR' is not initialized [cppcoreguidelines-init-variables]

for (int i=0; i<initNumRHS; i++) {
ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol) badRes = true;
}
}

!Line: 200 - warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]

ST actRes = actualResids[i]/rhsNorm[i];
std::cout<<"Problem "<<i<<" : \t"<< actRes <<std::endl;
if (actRes > tol) badRes = true;
}
}

!Line: 201 - warning: variable 'actRes' is not initialized [cppcoreguidelines-init-variables]

if (actRes > tol) badRes = true;
}
}
if (ret != Belos::Converged || badRes==true) {
if (procVerbose)

!Line: 203 - warning: statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements]

if (ret != Belos::Converged || badRes==true) {
if (procVerbose)
std::cout << std::endl << "ERROR: Initial solve did not converge to solution!" << std::endl;
return -1;
}

!Line: 207 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Initial solve did not converge to solution!" << std::endl;
return -1;
}
// ***************Construct augmented linear system****************

!Line: 208 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP<MV> augX = rcp( new MV(Map, initNumRHS+augNumRHS) );
RCP<MV> augB = rcp( new MV(Map, initNumRHS+augNumRHS) );
if (augNumRHS) {
MVT::MvRandom( *augX );
OPT::Apply( *A, *augX, *augB );
augX->putScalar( 0.0 );

!Line: 215 - warning: variable 'augX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> augB = rcp( new MV(Map, initNumRHS+augNumRHS) );
if (augNumRHS) {
MVT::MvRandom( *augX );
OPT::Apply( *A, *augX, *augB );
augX->putScalar( 0.0 );
}

!Line: 216 - warning: variable 'augB' is not initialized [cppcoreguidelines-init-variables]

MVT::MvRandom( *augX );
OPT::Apply( *A, *augX, *augB );
augX->putScalar( 0.0 );
}
// Copy previous linear system into

!Line: 218 - warning: variable 'augX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> tmpX = rcp( new MV( *augX ) );
RCP<MV> tmpB = rcp( new MV( *augB ) );
tmpX->scale( 1.0, *augX );
tmpB->scale( 1.0, *augB );
Belos::LinearProblem<ST,MV,OP> augProblem( A, augX, augB );

!Line: 224 - warning: variable 'tmpX' is not initialized [cppcoreguidelines-init-variables]

RCP<MV> tmpB = rcp( new MV( *augB ) );
tmpX->scale( 1.0, *augX );
tmpB->scale( 1.0, *augB );
Belos::LinearProblem<ST,MV,OP> augProblem( A, augX, augB );
augProblem.setLabel("Belos Aug");

!Line: 225 - warning: variable 'tmpB' is not initialized [cppcoreguidelines-init-variables]

Belos::LinearProblem<ST,MV,OP> augProblem( A, augX, augB );
augProblem.setLabel("Belos Aug");
set = augProblem.setProblem();
if (set == false) {
if (procVerbose)

!Line: 229 - warning: variable 'augProblem' is not initialized [cppcoreguidelines-init-variables]

if (set == false) {
if (procVerbose)
std::cout << std::endl << "ERROR: Augmented Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}

!Line: 233 - warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]

if (procVerbose)
std::cout << std::endl << "ERROR: Augmented Belos::LinearProblem failed to set up correctly!" << std::endl;
return -1;
}
// *******************************************************************

!Line: 234 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

RCP< Belos::SolverManager<ST,MV,OP> > augSolver
= rcp( new Belos::PseudoBlockGmresSolMgr<ST,MV,OP>( rcp(&augProblem,false), rcp(&belosList,false) ) );
// Perform solve
ret = augSolver->solve();

!Line: 249 - warning: variable 'augSolver' is not initialized [cppcoreguidelines-init-variables]

if (procVerbose)
std::cout << std::endl << "ERROR: Augmented solver did not converge to solution!" << std::endl;
return -1;
}
// **********Print out information about problem*******************

!Line: 256 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]


!Maximum character count per GitHub comment has been reached! Not all warnings/errors has been parsed!

@cwschilly cwschilly marked this pull request as ready for review September 22, 2023 20:03
@cwschilly cwschilly marked this pull request as draft September 22, 2023 20:10
@cwschilly
Copy link
Collaborator Author

I'm going to convert test_pseudo_gmres_multi_hb.cpp in this PR as well, rather than make a separate issue.

@cwschilly cwschilly marked this pull request as ready for review September 22, 2023 20:59
stmcgovern
stmcgovern previously approved these changes Sep 25, 2023
packages/belos/tpetra/test/MultiMatrixSolve/CMakeLists.txt Outdated Show resolved Hide resolved
@stmcgovern stmcgovern merged commit 34ddaba into NGA-FY23-develop Sep 25, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Belos: Provide Tpetra versions of all BlockGmres tests
2 participants