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

Move the TBR analysis in DiffRequest and provide an interface to query it. #971

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

vgvassilev
Copy link
Owner

The idea of this change is to separate the analysis steps from the building step. That would help us detect unsupported cases and provide useful diagnostics without crashing. The centralization will help with enabling the future activity analysis in other modes, too.

Partially addresses #721.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -224,7 +224,7 @@ class TBRAnalyzer : public clang::RecursiveASTVisitor<TBRAnalyzer> {
enum Mode { kMarkingMode = 1, kNonLinearMode = 2 };
/// Tells if the variable at a given location is required to store. Basically,
/// is the result of analysis.
std::set<clang::SourceLocation> m_TBRLocs;
std::set<clang::SourceLocation>& m_TBRLocs;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member 'm_TBRLocs' of type 'std::setclang::SourceLocation &' is a reference [cppcoreguidelines-avoid-const-or-ref-data-members]

  std::set<clang::SourceLocation>& m_TBRLocs;
                                   ^

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is bogus. cppcoreguidelines-avoid-const-or-ref-data-members says "his check warns when structs or classes that are copyable or movable, and have const-qualified or reference (lvalue or rvalue) data members.". The TBRAnalyzer has deleted copy and move operations but the complain is still on. I suspect there is a bug in clang-tidy...

@vgvassilev
Copy link
Owner Author

@PetroZarytskyi, this change triggers

Unexpectedly Passed Tests (1):
  clad :: Gradient/PointersWithTBR.C

Do you have a clue why that happens?

assert(EnableTBRAnalysis && "TBR not enabled!");

if (!isa<DeclRefExpr>(E) || !isa<ArraySubscriptExpr>(E) ||
!isa<MemberExpr>(E))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the condition should be !isa<DeclRefExpr>(E) && !isa<ArraySubscriptExpr>(E) && !isa<MemberExpr>(E).
DeclRefExpr, ArraySubscriptExpr, and MemberExpr are different expression types so at least one of the three conditions !isa<... will always be true. Because of this, the function always returns true here. This is why we get the Unexpectedly Passed check (TBR analysis is essentially turned off).

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ah, yeah, good catch!

@PetroZarytskyi
Copy link
Collaborator

Other than my last comment, the PR looks good to me.

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.90%. Comparing base (e04d04e) to head (017ae76).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #971      +/-   ##
==========================================
- Coverage   93.98%   93.90%   -0.08%     
==========================================
  Files          55       55              
  Lines        8012     8013       +1     
==========================================
- Hits         7530     7525       -5     
- Misses        482      488       +6     
Files Coverage Δ
include/clad/Differentiator/DiffPlanner.h 69.56% <100.00%> (+1.38%) ⬆️
lib/Differentiator/DiffPlanner.cpp 98.71% <100.00%> (+0.04%) ⬆️
lib/Differentiator/ReverseModeVisitor.cpp 97.29% <100.00%> (-0.02%) ⬇️
lib/Differentiator/TBRAnalyzer.h 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Files Coverage Δ
include/clad/Differentiator/DiffPlanner.h 69.56% <100.00%> (+1.38%) ⬆️
lib/Differentiator/DiffPlanner.cpp 98.71% <100.00%> (+0.04%) ⬆️
lib/Differentiator/ReverseModeVisitor.cpp 97.29% <100.00%> (-0.02%) ⬇️
lib/Differentiator/TBRAnalyzer.h 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

…y it.

The idea of this change is to separate the analysis steps from the building step.
That would help us detect unsupported cases and provide useful diagnostics
without crashing. The centralization will help with enabling the future activity
analysis in other modes, too.

Partially addresses #721.
Copy link
Collaborator

@PetroZarytskyi PetroZarytskyi left a comment

Choose a reason for hiding this comment

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

LGTM!

@vgvassilev
Copy link
Owner Author

The failure on the ubuntu llvm-18 bot is due to some apt-get problem. I do not understand why codecov is not happy with the test coverage and at the same time it complains about reduced coverage. Maybe if we removed code the coverage computation goes wrong...

@vgvassilev vgvassilev merged commit 8fc2d5d into master Jul 18, 2024
87 of 89 checks passed
@vgvassilev vgvassilev deleted the move-tbr branch July 18, 2024 12:17
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.

2 participants