Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadSpheroid committed Feb 20, 2024
1 parent d3f12ca commit ec56e48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace clad {
};

CladPlugin::CladPlugin(CompilerInstance& CI, DifferentiationOptions& DO)
: m_CI(CI), m_DO(DO), m_HasRuntime(false), m_tg("Clad timers", "Timers for clad funcs"){
: m_CI(CI), m_DO(DO), m_HasRuntime(false), m_TG("Clad timers", "Timers for clad funcs"){
#if CLANG_VERSION_MAJOR > 8
const clang::CommentOptions::BlockCommandNamesTy cmdargs = m_CI.getCodeGenOpts().CommandLineArgs;
for(const std::string &arg: cmdargs){
Expand Down Expand Up @@ -165,7 +165,8 @@ namespace clad {
S.PerformPendingInstantiations();
m_PendingInstantiationsInFlight = false;
}
llvm::Timer dummy("Dummy timer", "Prevent premature printing of timings", m_tg);
// Necessary to prevent separate timing reports due to expired timers
llvm::Timer dummy("Dummy timer", "Prevent premature printing of timings", m_TG);
for (DiffRequest& request : requests)
ProcessDiffRequest(request);
return true; // Happiness
Expand Down Expand Up @@ -244,7 +245,8 @@ namespace clad {
OverloadedDerivativeDecl = DFI.OverloadedDerivedFn();
alreadyDerived = true;
} else {
llvm::Timer tm("Clad timer", request.BaseFunctionName, m_tg);
// Only time the function when it is first encountered
llvm::Timer tm("Clad timer", request.BaseFunctionName, m_TG);
if(m_PrintTimings && !tm.isRunning()){
tm.startTimer();
}
Expand Down
2 changes: 1 addition & 1 deletion tools/ClangPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace clad {
bool m_PendingInstantiationsInFlight = false;
bool m_HandleTopLevelDeclInternal = false;
bool m_PrintTimings = false;
llvm::TimerGroup m_tg;
llvm::TimerGroup m_TG;
DerivedFnCollector m_DFC;
public:
CladPlugin(clang::CompilerInstance& CI, DifferentiationOptions& DO);
Expand Down

0 comments on commit ec56e48

Please sign in to comment.