Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions enzyme/Enzyme/GradientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringMap.h"

#include "llvm/Support/AMDGPUMetadata.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TimeProfiler.h"

#define DEBUG_TYPE "enzyme"

STATISTIC(NumValuesCached, "Number of values cached for the reverse pass");
STATISTIC(NumValuesRecomputed,
"Number of values recomputed instead of cached");

#if LLVM_VERSION_MAJOR >= 14
#define addAttribute addAttributeAtIndex
#define hasAttribute hasAttributeAtIndex
Expand Down Expand Up @@ -8492,6 +8499,7 @@ void GradientUtils::computeMinCache() {

if (oneneed || shadowOneNeed) {
knownRecomputeHeuristic[&I] = false;
++NumValuesCached;

CountTrackedPointers T(I.getType());
assert(!T.derived);
Expand Down Expand Up @@ -8569,6 +8577,10 @@ void GradientUtils::computeMinCache() {

for (auto V : Intermediates) {
knownRecomputeHeuristic[V] = !MinReq.count(V);
if (MinReq.count(V))
++NumValuesCached;
else
++NumValuesRecomputed;
if (!MinReq.count(V) && NeedGraph.count(V)) {
if (auto CI = dyn_cast<CallInst>(V))
if (getFuncNameFromCall(CI) == "julia.call")
Expand Down