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

#210: Belos: replace hb reader tpetra #214

Draft
wants to merge 16 commits into
base: NGA-FY23-develop
Choose a base branch
from

Conversation

tlamonthezie
Copy link
Collaborator

@tlamonthezie tlamonthezie commented Sep 25, 2023

Fixes #210

IMPORTANT : Prerequities before requesting PR to trilinos/trilinos:develop

Because this PR is modifying previous PR's - and some are still i review on trilinos/trilinos:develop:

  • All Tpetra tests & examples developed for Belos must be first merged into trilinos/trilinos:develop
  • Then NexGenAnalytics/trilinos must be synced

@github-actions
Copy link

github-actions bot commented Sep 25, 2023

⚡ Code quality check ⚡


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

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by CG solver.");
cmdp.setOption("num-rhs",&numrhs,"Number of right-hand sides to be solved for.");
cmdp.setOption("block-size",&blockSize,"Block size used by CG.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {

!Line: 117 - 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 CG solver.");
cmdp.setOption("num-rhs",&numrhs,"Number of right-hand sides to be solved for.");
cmdp.setOption("block-size",&blockSize,"Block size used by CG.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {

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

RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;
X = rcp( new MV(map,numrhs) );

!Line: 133 - warning: variable 'map' is not initialized [cppcoreguidelines-init-variables]
!Line: 282 - note: +1
!Line: 155 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 159 - note: +1, including nesting penalty of 0, nesting level increased to 1
!Line: 167 - note: +1, nesting level increased to 1
!Line: 216 - note: +3, including nesting penalty of 2, nesting level increased to 3

cmdp.setOption("max-iters", &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: 124 - warning: calling a function that uses a default argument is disallowed [fuchsia-default-arguments-calls]

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

} 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: 167 - warning: statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements]

if (actRes > tol)
badRes = true;
}
}
success = ret == Belos::Converged && !badRes;

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

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("num-rhs",&numrhs,"Number of right-hand sides to be solved for.");
cmdp.setOption("block-size",&blockSize,"Block size used by GMRES.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("max-subspace",&maxsubspace,"Maximum number of blocks the solver can use for the subspace.");

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

!Line: 143 - 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: 145 - warning: variable 'map' 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, actualResids );
MVT::MvNorm( *B, rhsNorm );
if (procVerbose) {

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<Tpetra::CrsMatrix<ST>> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<Tpetra::CrsMatrix<ST>> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const Tpetra::Map<>> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("num-rhs",&numrhs,"Number of right-hand sides to be solved for.");
cmdp.setOption("max-iters",&maxiters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("max-subspace",&maxsubspace,"Maximum number of vectors in search space (including recycle space).");
cmdp.setOption("recycle",&recycle,"Number of vectors in recycle space.");

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, Comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, Comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

!Line: 142 - 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: 144 - warning: variable 'map' is not initialized [cppcoreguidelines-init-variables]

cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tol",&tol,"Relative residual tolerance used by GMRES solver.");
cmdp.setOption("num-rhs",&numrhs,"Number of right-hand sides to be solved for.");
cmdp.setOption("block-size",&blockSize,"Block size used by GMRES.");
cmdp.setOption("max-iters",&maxIters,"Maximum number of iterations per linear system (-1 = adapted to problem/block size).");
cmdp.setOption("max-subspace",&maxSubspace,"Maximum number of blocks the solver can use for the subspace.");

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

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

RCP<tcrsmatrix_t> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const tmap_t> map = A->getDomainMap();
// Create initial vectors
RCP<MV> B, X;

!Line: 139 - 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: 141 - warning: variable 'map' 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, actualResids );
MVT::MvNorm( *B, rhsNorm );
if (procVerbose) {

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

static void getCmdLineArgs(const Teuchos::Comm<int>& comm, int argc, char* argv[]) {
using Teuchos::CommandLineProcessor;
typedef Tpetra::MultiVector<>::scalar_type ST;
// Define a OrthoManagerFactory to use to get the names of valid
// orthogonalization manager types. We won't use this factory to

!Line: 90 - warning: function 'getCmdLineArgs' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]

static void getCmdLineArgs(const Teuchos::Comm<int>& comm, int argc, char* argv[]) {
using Teuchos::CommandLineProcessor;
typedef Tpetra::MultiVector<>::scalar_type ST;
// Define a OrthoManagerFactory to use to get the names of valid
// orthogonalization manager types. We won't use this factory to

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

cmdp.setOption("sizeS", &sizeS,
"Controls the number of columns of the "
"input multivector.");
cmdp.setOption("sizeX1", &sizeX1,
"Controls the number of columns of the "
"first basis.");

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

cmdp.setOption("sizeX1", &sizeX1,
"Controls the number of columns of the "
"first basis.");
cmdp.setOption("sizeX2", &sizeX2,
"Controls the number of columns of the "
"second basis. We require for simplicity of testing (the "

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

cmdp.setOption("sizeX2", &sizeX2,
"Controls the number of columns of the "
"second basis. We require for simplicity of testing (the "
"routines do not require it) that sizeX1 >= sizeX2.");
// Parse the command-line arguments.
{

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

const CommandLineProcessor::EParseCommandLineReturn parseResult = cmdp.parse(argc, argv);
// If the caller asks us to print the documentation, or does not
// provide the name of an OrthoManager subclass, we just keep
// going. Otherwise, we throw an exception.
TEUCHOS_TEST_FOR_EXCEPTION(parseResult != CommandLineProcessor::PARSE_SUCCESSFUL, std::invalid_argument,
"Failed to parse command-line arguments");

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

static void load(Teuchos::RCP<map_type>& map, Teuchos::RCP<matrix_type>& M,
const Teuchos::RCP<const Teuchos::Comm<int> >& comm, std::ostream& debugOut) {
TEUCHOS_TEST_FOR_EXCEPTION(filename != "", std::logic_error,
"Sorry, reading in a Harwell-Boeing "
"sparse matrix file for ScalarType="
<< Teuchos::TypeNameTraits<ScalarType>::name()

!Line: 208 - warning: parameter name 'M' is too short, expected at least 3 characters [readability-identifier-length]

const Teuchos::RCP<const Teuchos::Comm<int> >& comm, std::ostream& debugOut) {
TEUCHOS_TEST_FOR_EXCEPTION(filename != "", std::logic_error,
"Sorry, reading in a Harwell-Boeing "
"sparse matrix file for ScalarType="
<< Teuchos::TypeNameTraits<ScalarType>::name()
<< " is not yet "

!Line: 209 - warning: parameter 'debugOut' is unused [misc-unused-parameters]

static void load(Teuchos::RCP<map_type>& map, Teuchos::RCP<matrix_type>& M,
const Teuchos::RCP<const Teuchos::Comm<int> >& comm, std::ostream& debugOut) {
// If the sparse matrix is loaded successfully, this call will
// modify numRows to be the number of rows in the sparse matrix.
// Otherwise, it will leave numRows alone.
std::pair<Teuchos::RCP<map_type>, Teuchos::RCP<matrix_type> > results =

!Line: 229 - warning: parameter name 'M' is too short, expected at least 3 characters [readability-identifier-length]

RCP<MAT> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const MAP> map = A->getDomainMap();
// Initialize vectors
RCP<MV> vecB = rcp(new MV(map, numRHS));

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

RCP<MAT> A;
Tpetra::Utils::readHBMatrix(filename, comm, A);
RCP<const MAP> map = A->getDomainMap();
// Initialize vectors
RCP<MV> vecB = rcp(new MV(map, numRHS));

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


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Belos: replace Belos Tpetra HarwellBoeing reader usage by Tpetra::Utils::readHBMatrix
1 participant