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

Try resolving issues discovered with -Wall -Werror #646

Closed

Conversation

tepperly
Copy link
Member

@tepperly tepperly commented Jul 26, 2023

I tried switching to C++ 17 and turning on -Wall -Werror during compile. This found a variety of issues.

It's hard for me as an outside to know when unused variables can be deleted versus just marking them as ``[[maybe_unused]]`. The key here is whether calculating the variable value has important side effects.

The main changes here involve:

  • ensuring that constructors initialize member variables in the order they're declared because that's the order that C++ will do them
  • fixing comparisons between int and size_t (unsigned long) in conditionals
  • removing or marking as [[maybe_unused]] variables that are never used
  • a few situations where = was used instead of == inside an assert
  • a destructor that needs to be virtual

@@ -142,7 +142,7 @@ class hiopInterfacePriDecProblem
const hiopVector& x0,
const std::string& mem_space);

~RecourseApproxEvaluator();
virtual ~RecourseApproxEvaluator();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this is an important change to ensure that the right destructor is called when delete evaluator is called from hiopAlgPrimalDecomp.cpp.

@@ -932,7 +925,7 @@ void hiopMatrixSparseCSRSeq::form_transpose_from_symbolic(const hiopMatrixSparse
}
//here row_starts_(==w) contains the row starts
}
assert(irowptr_[nrows_] = nnz_);
assert(irowptr_[nrows_] == nnz_);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also another non-trivial change from assignment to equality check.

@@ -1064,7 +1056,7 @@ void hiopMatrixSparseCSRSeq::form_transpose_from_symbolic(const hiopMatrixSparse
}
//here row_starts_(==w) contains the row starts
}
assert(irowptr_[nrows_] = nnz_);
assert(irowptr_[nrows_] == nnz_);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment to equality check!

@nychiang
Copy link
Collaborator

For those [[maybe_unused]] variables, should I correct them in this PR? Or do you prefer me merging this PR first and then I correct those issues in another PR? @tepperly

@nychiang nychiang requested review from nychiang and cnpetra July 26, 2023 16:49
@@ -106,23 +106,29 @@ DiscretizedFunction::DiscretizedFunction(Ex1Meshing1D* meshing)
}

// u'*v = u'*M*v, where u is 'this'
double DiscretizedFunction::dotProductWith( const DiscretizedFunction& v_ ) const
double DiscretizedFunction::dotProductWith( const hiopVector& v_ ) const
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to resolve this warning message:

hiop/src/Drivers/Dense/NlpDenseConsEx1.hpp:94:18: error: 'DiscretizedFunction::dotProductWith' hides overloaded virtual function [-Werror,-Woverloaded-virtual]
  virtual double dotProductWith( const DiscretizedFunction& v ) const;

This stack overflow question addresses this error message.

@tepperly
Copy link
Member Author

tepperly commented Jul 26, 2023

For those [[maybe_unused]] variables, should I correct them in this PR? Or do you prefer me merging this PR first and then I correct those issues in another PR? @tepperly

@nychiang Which ever you prefer. It's up to you. I had to make my changes on a fork of your repository. If you wanted to fix in this PR, I think you'll need to push your changes to my fork of your repo.

@tepperly
Copy link
Member Author

tepperly commented Aug 8, 2023

Is there something I can do to facilitate the review and merging of this PR?

@cnpetra
Copy link
Collaborator

cnpetra commented Aug 8, 2023

Is there something I can do to facilitate the review and merging of this PR?

it is in the works and on our to-do list for this week.

@cnpetra cnpetra requested a review from jwang125 August 8, 2023 19:03
@nychiang
Copy link
Collaborator

@tepperly, I just created one PR in your folk, to correct some additional files due to the issue discovered with -Wall -Werror. I have no problem to compile the code on my MAC, running with RAJA/MPI/HSL. All the unit test work fine.

However, I wonder if you could work on this PR in the LLNL folk, i.e., move tepperly:feature/headers-wall-werror-proof to LLNL:feature/headers-wall-werror-proof and then file this PR. If you file PR inside the LLNL folk, I believe all the pipeline test (CI) will start in LLNL and PNNL clusters.

I am not sure why all the CI tests do not work while your PR is initialized from an external folk.

@nychiang
Copy link
Collaborator

@tepperly With @cameronrutherford's help, the PNNL CI is working now. Once you file this PR within LLNL domain, we can get feedbacks from all the CI tests.

@tepperly
Copy link
Member Author

@tepperly With @cameronrutherford's help, the PNNL CI is working now. Once you file this PR within LLNL domain, we can get feedbacks from all the CI tests.

I think you need to give user @tepperly access to push to your repo. I forked because I can't push to a branch on git@github.com:LLNL/hiop.git.

$ git push origin feature/headers-wall-werror-proof
ERROR: Permission to LLNL/hiop.git denied to tepperly.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@nychiang
Copy link
Collaborator

@tepperly I just added you into the repository. You may receive an email for confirmation.

@cameronrutherford
Copy link
Collaborator

https://gitlab.pnnl.gov/exasgd/frameworks/exago/-/merge_requests/488 - recently did this in ExaGO FWIW so should be reasonably easy to add this to HiOp pipelines as well if you want

@nychiang
Copy link
Collaborator

@cnpetra Let's close this one. We filed another PR inside LLNL domain, to use the CI features. See #653

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.

4 participants