Skip to content

Commit

Permalink
renaming legacy macro
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrantq committed Jan 18, 2025
1 parent 953ac4f commit d62bda8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND ENZYME_SRC TypeAnalysis/TypeTree.cpp TypeAnalysis/TypeAnalysis.cpp TypeAnalysis/TypeAnalysisPrinter.cpp TypeAnalysis/RustDebugInfo.cpp)

# set(ENZYME_LINK_TARGETS)
set(ENZYME_ENABLE_HERBIE 0 CACHE BOOL "Enable Herbie")
set(ENZYME_ENABLE_FPOPT 0 CACHE BOOL "Enable FPOpt")

if(ENZYME_ENABLE_HERBIE)
if(ENZYME_ENABLE_FPOPT)
include(ExternalProject)
ExternalProject_Add(herbie
GIT_REPOSITORY https://github.com/herbie-fp/herbie
Expand All @@ -66,7 +66,7 @@ if(ENZYME_ENABLE_HERBIE)
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/herbie-prefix/src/herbie/herbie ${CMAKE_CURRENT_BINARY_DIR}/herbie/install/herbie
)
list(APPEND ENZYME_SRC Herbie.cpp)
add_compile_definitions(ENZYME_ENABLE_HERBIE=1)
add_compile_definitions(ENZYME_ENABLE_FPOPT=1)
set_source_files_properties(Herbie.cpp PROPERTIES COMPILE_DEFINITIONS HERBIE_BINARY="${CMAKE_CURRENT_BINARY_DIR}/herbie/install/herbie")
endif()

Expand Down
2 changes: 2 additions & 0 deletions enzyme/Enzyme/DifferentialUseAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ inline bool is_value_needed_in_reverse(
}
}
}
#ifdef ENZYME_ENABLE_FPOPT
if ((getLogFunction(gutils->oldFunc->getParent(), "enzymeLogValue") ||
gutils->mode == DerivativeMode::ForwardModeError) &&
!gutils->isConstantValue(const_cast<Value *>(inst))) {
Expand All @@ -132,6 +133,7 @@ inline bool is_value_needed_in_reverse(
<< " in reverse as forward mode error always needs result\n";
return seen[idx] = true;
}
#endif
}

if (auto CI = dyn_cast<CallInst>(inst)) {
Expand Down
6 changes: 3 additions & 3 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3272,7 +3272,7 @@ AnalysisKey EnzymeNewPM::Key;
#include "ActivityAnalysisPrinter.h"
#include "JLInstSimplify.h"
#include "PreserveNVVM.h"
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
#include "Herbie.h"
#endif
#include "TypeAnalysis/TypeAnalysisPrinter.h"
Expand Down Expand Up @@ -3388,7 +3388,7 @@ void augmentPassBuilder(llvm::PassBuilder &PB) {
OptimizerPM.addPass(llvm::SROAPass());
#endif
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizerPM)));
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
if (EnzymeEnableFPOpt)
MPM.addPass(FPOptNewPM());
#endif
Expand Down Expand Up @@ -3676,7 +3676,7 @@ void registerEnzyme(llvm::PassBuilder &PB) {
MPM.addPass(EnzymeNewPM());
return true;
}
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
if (Name == "fp-opt") {
MPM.addPass(FPOptNewPM());
return true;
Expand Down
4 changes: 2 additions & 2 deletions enzyme/Enzyme/FunctionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

#include "CacheUtility.h"

#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
#include "Herbie.h"
#endif

Expand Down Expand Up @@ -1422,7 +1422,7 @@ Function *PreProcessCache::preprocessForClone(Function *F,
/*ModuleLevelChanges*/ CloneFunctionChangeType::LocalChangesOnly,
Returns, "", nullptr);
}
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
if (getLogFunction(F->getParent(), "enzymeLogError") ||
getLogFunction(F->getParent(), "enzymeLogValue") ||
getLogFunction(F->getParent(), "enzymeLogGrad")) {
Expand Down
4 changes: 2 additions & 2 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

#include "LibraryFuncs.h"

#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
#include "Herbie.h"
#endif

Expand Down Expand Up @@ -3703,7 +3703,7 @@ std::string getLogIdentifier(llvm::Instruction &I) {
std::to_string(instIdx);
}

#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
void attachFPOptMetadata(llvm::Instruction *After,
const llvm::Instruction *Before) {
if (EnzymePrintFPOpt)
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static inline DIFFE_TYPE whatType(llvm::Type *arg, DerivativeMode mode,
}

llvm::Value *get1ULP(llvm::IRBuilder<> &builder, llvm::Value *res);
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
llvm::Function *getLogFunction(llvm::Module *M, llvm::StringRef demangledName);
std::string getLogIdentifier(llvm::Instruction &I);
void attachFPOptMetadata(llvm::Instruction *After,
Expand Down
6 changes: 3 additions & 3 deletions enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ static void emitDerivatives(const RecordKeeper &recordKeeper, raw_ostream &os,
else
os << " gutils->eraseIfUnused(" << origName << ");\n";

#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
if (intrinsic != MLIRDerivatives) {
os << " if (auto *logFunc = getLogFunction(" << origName
<< ".getModule(), \"enzymeLogValue\")) {\n"
Expand Down Expand Up @@ -2400,7 +2400,7 @@ static void emitDerivatives(const RecordKeeper &recordKeeper, raw_ostream &os,

os << " assert(res);\n";

#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
// Insert logging function call (optional)
os << " if (auto *logFunc = getLogFunction(" << origName
<< ".getModule(), \"enzymeLogError\")) {\n"
Expand Down Expand Up @@ -2437,7 +2437,7 @@ static void emitDerivatives(const RecordKeeper &recordKeeper, raw_ostream &os,
emitReverseCommon(os, pattern, tree, intrinsic, origName, argOps);

if (intrinsic != MLIRDerivatives) {
#ifdef ENZYME_ENABLE_HERBIE
#ifdef ENZYME_ENABLE_FPOPT
os << " if (auto *logFunc = getLogFunction(" << origName
<< ".getModule(), \"enzymeLogGrad\")) {\n"
<< " std::string idStr = getLogIdentifier(" << origName
Expand Down

0 comments on commit d62bda8

Please sign in to comment.