Skip to content

Commit

Permalink
made member var
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadSpheroid committed Feb 25, 2024
1 parent c3165e1 commit e4c1f11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,14 @@ namespace clad {
} else {
// Only time the function when it is first encountered
if (WantTiming)
ctg.StartNewTimer("Timer for clad func", request.BaseFunctionName);
m_CTG.StartNewTimer("Timer for clad func",
request.BaseFunctionName);

auto deriveResult = m_DerivativeBuilder->Derive(request);
DerivativeDecl = deriveResult.derivative;
OverloadedDerivativeDecl = deriveResult.overload;
if (WantTiming)
ctg.StopTimer();
m_CTG.StopTimer();
}
}

Expand Down Expand Up @@ -314,12 +315,12 @@ namespace clad {
} // end namespace plugin

clad::CladTimerGroup::CladTimerGroup()
: Tg("Timers for Clad Funcs", "Timers for Clad Funcs") {}
: m_Tg("Timers for Clad Funcs", "Timers for Clad Funcs") {}

void clad::CladTimerGroup::StartNewTimer(const llvm::StringRef TimerName,
const llvm::StringRef TimerDesc) {
std::unique_ptr<llvm::Timer> tm =
std::make_unique<llvm::Timer>(TimerName, TimerDesc, Tg);
std::make_unique<llvm::Timer>(TimerName, TimerDesc, m_Tg);
Timers.push_back(std::move(tm));
Timers.back()->startTimer();
return;
Expand Down
5 changes: 3 additions & 2 deletions tools/ClangPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ namespace clad {
bool AlreadyExists(const DerivedFnInfo& DFI) const;
};
class CladTimerGroup {
llvm::TimerGroup Tg;
llvm::TimerGroup m_Tg;
std::vector<std::unique_ptr<llvm::Timer>> Timers;

public:
CladTimerGroup();
void StartNewTimer(const llvm::StringRef TimerName,
const llvm::StringRef TimerDesc);
void StopTimer();
} ctg;
};

namespace plugin {
struct DifferentiationOptions {
Expand Down Expand Up @@ -100,6 +100,7 @@ namespace clad {
bool m_HasRuntime = false;
bool m_PendingInstantiationsInFlight = false;
bool m_HandleTopLevelDeclInternal = false;
CladTimerGroup m_CTG;
DerivedFnCollector m_DFC;
public:
CladPlugin(clang::CompilerInstance& CI, DifferentiationOptions& DO);
Expand Down

0 comments on commit e4c1f11

Please sign in to comment.