Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier Clang Integration, Type Analysis Updates, & Primitive Cuda support #75

Merged
merged 4 commits into from
Oct 15, 2020

Conversation

wsmoses
Copy link
Member

@wsmoses wsmoses commented Oct 15, 2020

This introduces a ClangEnzyme.so for loading directly into clang (necessary for ease of use with GPU backend). Introduces primitive support for PTX backend among various type and activity analysis updates. Also fixes pre and post Enzyme optimizations to work across various LLVM versions

@wsmoses wsmoses requested a review from vchuravy October 15, 2020 02:20
@wsmoses wsmoses marked this pull request as draft October 15, 2020 02:20
@wsmoses wsmoses changed the title [WIP] Cuda support Easier Clang Integration, Type Analysis Updates, & Primitive Cuda support Oct 15, 2020
@wsmoses wsmoses marked this pull request as ready for review October 15, 2020 06:17
void HandleAutoDiff(CallInst *CI, TargetLibraryInfo &TLI, AAResults &AA) {
llvm::cl::opt<bool>
EnzymePostOpt("enzmye-postopt", cl::init(false), cl::Hidden,
cl::desc("Run enzymepostprocessing optimizations"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cl::desc("Run enzymepostprocessing optimizations"));
cl::desc("Run enzyme postprocessing optimizations"));

enzyme/Enzyme/Enzyme.cpp Show resolved Hide resolved
++i;
res = CI->getArgOperand(i);
} else if (MS == "enzyme_out") {
llvm::errs() << "saw metadata for diffe_out\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these LLVM_DEBUG?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

enzyme/Enzyme/FunctionUtils.cpp Show resolved Hide resolved
GVN().run(*NewF, AM);
SROA().run(*NewF, AM);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -692,18 +684,15 @@ void optimizeIntermediate(GradientUtils *gutils, bool topLevel, Function *F) {

// TODO function attributes
// PostOrderFunctionAttrsPass().run(*F, AM);
#if LLVM_VERSION_MAJOR <= 7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if LLVM_VERSION_MAJOR <= 7
#if LLVM_VERSION_MAJOR <= 7

InstSimplifyPass().run(*F, AM);
#endif
CorrelatedValuePropagationPass().run(*F, AM);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif

llvm_unreachable("unhandled atomic add");
}
} else {
#if LLVM_VERSION_MAJOR >= 9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if LLVM_VERSION_MAJOR >= 9
#if LLVM_VERSION_MAJOR >= 9

#if LLVM_VERSION_MAJOR >= 9
AtomicRMWInst::BinOp op = AtomicRMWInst::FAdd;
AtomicRMWInst* rmw = BuilderM.CreateAtomicRMW (op, ptr, dif, AtomicOrdering::Monotonic, SyncScope::System);
#if LLVM_VERSION_MAJOR >= 11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if LLVM_VERSION_MAJOR >= 11
#if LLVM_VERSION_MAJOR >= 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants