Skip to content

Commit

Permalink
Non-power of two cache switch (#2204)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Dec 23, 2024
1 parent f5767ef commit 79ac406
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ llvm::cl::opt<bool> EnzymeMemmoveWarning(
llvm::cl::opt<bool> EnzymeRuntimeError(
"enzyme-runtime-error", cl::init(false), cl::Hidden,
cl::desc("Emit Runtime errors instead of compile time ones"));

llvm::cl::opt<bool> EnzymeNonPower2Cache(
"enzyme-non-power2-cache", cl::init(false), cl::Hidden,
cl::desc("Disable caching of integers which are not a power of 2"));
}

void ZeroMemory(llvm::IRBuilder<> &Builder, llvm::Type *T, llvm::Value *obj,
Expand Down
5 changes: 5 additions & 0 deletions enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum class ErrorType {
extern "C" {
/// Print additional debug info relevant to performance
extern llvm::cl::opt<bool> EnzymePrintPerf;
extern llvm::cl::opt<bool> EnzymeNonPower2Cache;
extern llvm::cl::opt<bool> EnzymeStrongZero;
extern llvm::cl::opt<bool> EnzymeBlasCopy;
extern llvm::cl::opt<bool> EnzymeLapackCopy;
Expand Down Expand Up @@ -1194,6 +1195,10 @@ static inline bool hasNoCache(llvm::Value *op) {
}
}
}
if (auto IT = dyn_cast<IntegerType>(op->getType()))
if (!isPowerOf2_64(IT->getBitWidth()) && !EnzymeNonPower2Cache)
return true;

return false;
}

Expand Down

0 comments on commit 79ac406

Please sign in to comment.