|
Enzyme main
|
#include <cstdint>#include <deque>#include <llvm/Config/llvm-config.h>#include <memory>#include "llvm/ADT/ImmutableSet.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/StringMap.h"#include "llvm/ADT/StringSet.h"#include "llvm/ADT/STLExtras.h"#include "llvm/IR/Constants.h"#include "llvm/IR/Function.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/IR/InstIterator.h"#include "llvm/Support/TimeProfiler.h"#include "llvm/Support/raw_ostream.h"#include "llvm/IR/InlineAsm.h"#include "ActivityAnalysis.h"#include "Utils.h"#include "llvm/Demangle/Demangle.h"#include "FunctionUtils.h"#include "LibraryFuncs.h"#include "TypeAnalysis/TBAA.h"#include "llvm/Analysis/ValueTracking.h"#include <map>#include <set>#include <unordered_map>#include "ActivityAnalysis.h"#include "Interfaces/GradientUtils.h"#include "Interfaces/Utils.h"#include "mlir/Dialect/Func/IR/FuncOps.h"#include "mlir/Dialect/LLVMIR/LLVMDialect.h"#include "mlir/Dialect/LLVMIR/LLVMTypes.h"#include "mlir/Dialect/MemRef/IR/MemRef.h"#include "mlir/IR/BuiltinAttributes.h"#include "mlir/IR/Matchers.h"#include "mlir/IR/Region.h"#include "mlir/IR/RegionKindInterface.h"#include "mlir/IR/SymbolTable.h"#include "mlir/Interfaces/CallInterfaces.h"#include "mlir/Interfaces/CastInterfaces.h"#include "mlir/Interfaces/ControlFlowInterfaces.h"#include "mlir/Interfaces/SideEffectInterfaces.h"#include "llvm/IR/Intrinsics.h"#include "llvm/Support/ModRef.h"#include "Interfaces/AutoDiffOpInterface.h"
Go to the source code of this file.
Macros | |
| #define | addAttribute addAttributeAtIndex |
| #define | removeAttribute removeAttributeAtIndex |
| #define | getAttribute getAttributeAtIndex |
| #define | hasAttribute hasAttributeAtIndex |
Functions | |
| cl::opt< bool > | EnzymePrintActivity ("enzyme-print-activity", cl::init(false), cl::Hidden, cl::desc("Print activity analysis algorithm")) |
| cl::opt< bool > | EnzymeNonmarkedGlobalsInactive ("enzyme-globals-default-inactive", cl::init(false), cl::Hidden, cl::desc("Consider all nonmarked globals to be inactive")) |
| cl::opt< bool > | EnzymeEmptyFnInactive ("enzyme-emptyfn-inactive", cl::init(false), cl::Hidden, cl::desc("Empty functions are considered inactive")) |
| cl::opt< bool > | EnzymeGlobalActivity ("enzyme-global-activity", cl::init(false), cl::Hidden, cl::desc("Enable correct global activity analysis")) |
| cl::opt< bool > | EnzymeDisableActivityAnalysis ("enzyme-disable-activity-analysis", cl::init(false), cl::Hidden, cl::desc("Disable activity analysis")) |
| cl::opt< bool > | EnzymeEnableRecursiveHypotheses ("enzyme-enable-recursive-activity", cl::init(true), cl::Hidden, cl::desc("Enable re-evaluation of activity analysis from updated results")) |
| bool | isInactiveCall (CallBase &CI) |
| Return whether the call is always inactive by definition. | |
| bool | isInactiveCallInst (CallBase &CB, llvm::TargetLibraryInfo &TLI) |
| static void | propagateArgumentInformation (TargetLibraryInfo &TLI, CallInst &CI, llvm::function_ref< bool(Value *)> propagateFromOperand) |
| Call the function propagateFromOperand on all operands of CI that could impact the activity of the call instruction. | |
| bool | isValuePotentiallyUsedAsPointer (llvm::Value *val) |
| static Operation * | getFunctionFromCall (CallOpInterface iface) |
| static bool | isReadOnly (Operation *op) |
| static bool | isFunctionReturn (Operation *op) |
| static bool | isValuePotentiallyUsedAsPointer (Value val) |
| static Value | getUnderlyingObject (mlir::Value value, unsigned maxLookup) |
| static bool | mayAllocateMemory (Operation *op) |
| static bool | mayReadFromMemory (Operation *op) |
| static bool | mayWriteToMemory (Operation *op) |
| static FunctionOpInterface | getFunctionIfArgument (Value value) |
| static std::optional< SmallVector< Value > > | getPotentialTerminatorUsers (Operation *op, Value parent) |
| static SmallVector< Value > | getPotentialIncomingValues (OpResult res) |
| static SmallVector< Value > | getPotentialIncomingValues (BlockArgument arg) |
| static Operation * | getAncestorInRegion (Operation *op, Region *region) |
Return an ancestor of op that resides in the given region or nullptr if there is no such ancestor. | |
| static void | allFollowersOf (Operation *op, function_ref< WalkResult(Operation *)> f) |
Call f on all operations that may be executed after op. | |
Variables | |
| static const StringSet | InactiveGlobals |
| const llvm::StringMap< size_t > | MPIInactiveCommAllocators |
| static const char * | KnownInactiveFunctionsStartingWith [] |
| static const char * | KnownInactiveFunctionsContains [] |
| static const std::set< std::string > | InactiveGlobals |
| static const std::set< std::string > | KnownInactiveFunctionInsts |
| static const std::set< std::string > | KnownInactiveFunctions |
| static const char * | DemangledKnownInactiveFunctionsStartingWith [] |
| static const unsigned | constantIntrinsics [] |
| constexpr bool | EnzymePrintActivity = false |
| #define addAttribute addAttributeAtIndex |
| #define getAttribute getAttributeAtIndex |
| #define hasAttribute hasAttributeAtIndex |
| #define removeAttribute removeAttributeAtIndex |
|
static |
Call f on all operations that may be executed after op.
Definition at line 1219 of file ActivityAnalysis.cpp.
References getAncestorInRegion().
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
| cl::opt< bool > EnzymeDisableActivityAnalysis | ( | "enzyme-disable-activity-analysis" | , |
| cl::init(false) | , | ||
| cl::Hidden | , | ||
| cl::desc("Disable activity analysis") | ) |
| cl::opt< bool > EnzymeEmptyFnInactive | ( | "enzyme-emptyfn-inactive" | , |
| cl::init(false) | , | ||
| cl::Hidden | , | ||
| cl::desc("Empty functions are considered inactive") | ) |
| cl::opt< bool > EnzymeEnableRecursiveHypotheses | ( | "enzyme-enable-recursive-activity" | , |
| cl::init(true) | , | ||
| cl::Hidden | , | ||
| cl::desc("Enable re-evaluation of activity analysis from updated results") | ) |
| cl::opt< bool > EnzymeGlobalActivity | ( | "enzyme-global-activity" | , |
| cl::init(false) | , | ||
| cl::Hidden | , | ||
| cl::desc("Enable correct global activity analysis") | ) |
| cl::opt< bool > EnzymeNonmarkedGlobalsInactive | ( | "enzyme-globals-default-inactive" | , |
| cl::init(false) | , | ||
| cl::Hidden | , | ||
| cl::desc("Consider all nonmarked globals to be inactive") | ) |
| cl::opt< bool > EnzymePrintActivity | ( | "enzyme-print-activity" | , |
| cl::init(false) | , | ||
| cl::Hidden | , | ||
| cl::desc("Print activity analysis algorithm") | ) |
|
static |
Return an ancestor of op that resides in the given region or nullptr if there is no such ancestor.
Definition at line 1211 of file ActivityAnalysis.cpp.
Referenced by allFollowersOf().
|
static |
Definition at line 259 of file ActivityAnalysis.cpp.
Referenced by copy_lower_to_upper(), fixSparse_inner(), getOrInsertExponentialAllocator(), TraceGenerator::handleArbitraryCall(), isAllocationCall(), mlir::enzyme::ActivityAnalyzer::isConstantValue(), TraceUtils::isObserveCall(), isProduct(), TraceUtils::isSampleCall(), isSum(), mlir::enzyme::ActivityAnalyzer::isValueInactiveFromUsers(), propagateArgumentInformation(), TypeAnalyzer::run(), TypeAnalyzer::visitCallBase(), AdjointGenerator::visitCallInst(), InstructionBatcher::visitCallInst(), and TraceGenerator::visitCallInst().
|
static |
Definition at line 948 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 1095 of file ActivityAnalysis.cpp.
|
static |
Definition at line 1030 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 964 of file ActivityAnalysis.cpp.
References isFunctionReturn().
Referenced by mlir::enzyme::ActivityAnalyzer::isValueInactiveFromUsers().
|
static |
Definition at line 909 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 839 of file ActivityAnalysis.cpp.
Referenced by getPotentialTerminatorUsers(), mlir::enzyme::ActivityAnalyzer::isValueInactiveFromUsers(), and isValuePotentiallyUsedAsPointer().
| bool isInactiveCall | ( | CallBase & | CI | ) |
Return whether the call is always inactive by definition.
Definition at line 166 of file ActivityAnalysis.cpp.
| bool isInactiveCallInst | ( | CallBase & | CB, |
| llvm::TargetLibraryInfo & | TLI ) |
Definition at line 532 of file ActivityAnalysis.cpp.
|
static |
Definition at line 269 of file ActivityAnalysis.cpp.
References isReadOnly().
Referenced by DetectPointerArgOfFn(), fixSparse_inner(), fixSparseIndices(), isReadOnly(), mlir::enzyme::ActivityAnalyzer::isValueInactiveFromUsers(), and AdjointGenerator::recursivelyHandleSubfunction().
| bool isValuePotentiallyUsedAsPointer | ( | llvm::Value * | val | ) |
Definition at line 1087 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 845 of file ActivityAnalysis.cpp.
References EnzymePrintActivity, and isFunctionReturn().
|
static |
Definition at line 930 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 936 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 942 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
inlinestatic |
Call the function propagateFromOperand on all operands of CI that could impact the activity of the call instruction.
Only the first argument (magnitude) of copysign is active
Definition at line 661 of file ActivityAnalysis.cpp.
References getFunctionFromCall().
|
static |
Definition at line 214 of file ActivityAnalysis.cpp.
|
static |
Definition at line 170 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
constexpr |
Definition at line 267 of file ActivityAnalysis.cpp.
Referenced by PreProcessCache::CloneFunctionWithReturns(), ActivityAnalyzer::isConstantInstruction(), mlir::enzyme::ActivityAnalyzer::isConstantValue(), mlir::enzyme::ActivityAnalyzer::isValueActivelyStoredOrReturned(), mlir::enzyme::ActivityAnalyzer::isValueInactiveFromUsers(), and isValuePotentiallyUsedAsPointer().
|
static |
Definition at line 107 of file ActivityAnalysis.cpp.
|
static |
Definition at line 37 of file ActivityAnalysis.cpp.
|
static |
Definition at line 79 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 88 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 33 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
|
static |
Definition at line 24 of file ActivityAnalysis.cpp.
Referenced by mlir::enzyme::ActivityAnalyzer::isConstantValue().
| static const std::map< std::string, size_t > MPIInactiveCommAllocators |
Definition at line 148 of file ActivityAnalysis.cpp.
Referenced by AdjointGenerator::handleKnownCallDerivatives(), AdjointGenerator::handleMPI(), and mlir::enzyme::ActivityAnalyzer::isConstantValue().