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

adding rust ADBench version #1797

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9770ceb
adding gmm
ZuseZ4 Mar 19, 2024
9f05ff8
working C too
ZuseZ4 Mar 25, 2024
4da9910
Delete enzyme/benchmarks/ReverseMode/gmmrs/src/main.rs2
ZuseZ4 Mar 26, 2024
0f68ce8
rust setup
wsmoses Mar 28, 2024
7995eb3
add files
wsmoses Mar 28, 2024
069e3cb
improve makefile and fix c ffi
ZuseZ4 Mar 29, 2024
be54358
maybe needed? pthread for cmake
ZuseZ4 Mar 30, 2024
4423222
bench gmm: use path relative to Makefile
jedbrown Mar 30, 2024
7b5a24c
Fix byref issue for rust abi
wsmoses Mar 31, 2024
ea03750
Add primal bench/test
wsmoses Mar 31, 2024
77a130f
fix math
ZuseZ4 Mar 31, 2024
4abf2bf
write into return var
ZuseZ4 Mar 31, 2024
5cde3d7
Cleanup gmm config
wsmoses Mar 31, 2024
af6583d
bench gmm: make cmath::lgamma with libm as an optional feature
jedbrown Mar 31, 2024
48c2e1f
oxidize - more noalias
ZuseZ4 Mar 31, 2024
ba75484
reduce caching
ZuseZ4 Mar 31, 2024
9394028
bench gmm: makefile dep on Cargo.toml, split targets
jedbrown Mar 31, 2024
814eb62
revert cmake pthread since only needed for Rust
ZuseZ4 Mar 31, 2024
41157fa
bench gmm: fix primal (sqnorm length matters)
jedbrown Mar 31, 2024
114f236
bench gmm: quash rust warnings
jedbrown Mar 31, 2024
012cf4c
adding ba benchmark
ZuseZ4 Mar 31, 2024
0430e44
Benchmark ba
wsmoses Apr 1, 2024
4b0062b
fix ba primal
ZuseZ4 Apr 2, 2024
1f27479
adding unsafe gmm version
ZuseZ4 Apr 4, 2024
af3e078
Add FFT and LSTM benchmark for Rust Enzyme
bytesnake Apr 4, 2024
c8bcfe9
adding unsafe Rust fft version (how to run?)
ZuseZ4 Apr 4, 2024
cad4221
imprv safe rus tto work like c++
ZuseZ4 Apr 4, 2024
f0bf16b
unsafe version not crashing
ZuseZ4 Apr 4, 2024
12e9a4a
fix lstm makefile
ZuseZ4 Apr 4, 2024
688721d
adding unsafe rust lstm version
ZuseZ4 Apr 4, 2024
7ca8092
run full fft tests
ZuseZ4 Apr 4, 2024
73f8075
Delete enzyme/benchmarks/ReverseMode/lstm/src/main.rs
ZuseZ4 Apr 5, 2024
ba3aa5d
cleanup and correctness
ZuseZ4 Apr 6, 2024
2737734
initial (compiling) rust ode version
ZuseZ4 May 6, 2024
1ffbaaa
cleanups
ZuseZ4 May 6, 2024
8bd316a
fix ba bench
ZuseZ4 May 22, 2024
c769dac
bench gmm: move allocation of scratch space outside AD'd function
jedbrown May 23, 2024
c5e1f19
bench gmm: switch scratch from Const to Duplicated
jedbrown May 23, 2024
947852c
bench gmm: match C++ performance by asserting sizes of work slices
jedbrown May 23, 2024
cb9d403
bench gmm: shed unused import (warning)
jedbrown May 23, 2024
dbffef6
bench lstm: optimize using length assertions
jedbrown May 23, 2024
0174227
adding unsafe ba version
ZuseZ4 May 24, 2024
629f87c
smaller perf improvements
ZuseZ4 Jun 2, 2024
c6f44b3
small improvment
ZuseZ4 Jun 2, 2024
fb6df5b
clean up ode-real example (not building)
ZuseZ4 Jun 3, 2024
a6d4a7c
add ba.cpp version without restrict
ZuseZ4 Jul 20, 2024
d08142b
add gmm version without restrict
ZuseZ4 Jul 20, 2024
d6b35b3
add lstm version without restrict
ZuseZ4 Jul 20, 2024
55a76b9
Revert "smaller perf improvements"
ZuseZ4 Jul 22, 2024
de87081
adding lstm primal cxx overhead benchmark
ZuseZ4 Jul 22, 2024
5d9b026
Merge branch 'main' into rust-bench
ZuseZ4 Sep 18, 2024
7d70dc5
fix ode-real example, correct results, faster than c++, without dupno…
ZuseZ4 Sep 19, 2024
fdb0d09
remove boost leftovers
ZuseZ4 Sep 19, 2024
747e4f9
fix makefiles to use new rustflags
ZuseZ4 Oct 1, 2024
05d3e87
add tanh support for llvm19+
ZuseZ4 Oct 2, 2024
1fe64c0
fix safe fft performance
ZuseZ4 Oct 2, 2024
7f26f43
fix (mostly) safe lstm perf
ZuseZ4 Oct 2, 2024
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
5 changes: 5 additions & 0 deletions enzyme/Enzyme/FunctionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,11 @@ bool guaranteedDataDependent(Value *z) {
case Intrinsic::sqrt:
case Intrinsic::sin:
case Intrinsic::cos:
#if LLVM_VERSION_MAJOR >= 19
case Intrinsic::sinh:
case Intrinsic::cosh:
case Intrinsic::tanh:
#endif
return guaranteedDataDependent(II->getArgOperand(0));
default:
break;
Expand Down
5 changes: 5 additions & 0 deletions enzyme/Enzyme/GradientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,11 @@ bool GradientUtils::shouldRecompute(const Value *val,
case Intrinsic::sin:
case Intrinsic::cos:
case Intrinsic::exp:
#if LLVM_VERSION_MAJOR >= 19
case Intrinsic::tanh:
case Intrinsic::cosh:
case Intrinsic::sinh:
#endif
case Intrinsic::log:
case Intrinsic::nvvm_ldu_global_i:
case Intrinsic::nvvm_ldu_global_p:
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/InstructionDerivatives.td
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,6 @@ def : CallPattern<(Op $x, $y),
[ReadNone, NoUnwind]
>;

def : CallPattern<(Op $x),
["tanh"],
[(FDiv (DiffeRet), (FMul(Call<(SameTypesFunc<"cosh">), [ReadNone,NoUnwind]> $x):$c, $c))],
(ForwardFromSummedReverse),
[ReadNone, NoUnwind]
>;
def : CallPattern<(Op $x),
["tanhf"],
[(FDiv (DiffeRet), (FMul(Call<(SameTypesFunc<"coshf">), [ReadNone,NoUnwind]> $x):$c, $c))],
Expand Down Expand Up @@ -872,6 +866,12 @@ def : CallPattern<(Op (Op $x, $y):$z),
[ReadNone, NoUnwind]
>;

def : IntrPattern<(Op $x),
[["tanh"]],
[(FDiv (DiffeRet), (FMul(Intrinsic<"cosh"> $x):$c, $c))],
(ForwardFromSummedReverse)
>;

def : IntrPattern<(Op $x),
[["sin"]],
[(FMul (DiffeRet), (Intrinsic<"cos"> $x))] ,
Expand Down
11 changes: 11 additions & 0 deletions enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ const llvm::StringMap<llvm::Intrinsic::ID> LIBM_FUNCTIONS = {
{"atan", Intrinsic::not_intrinsic},
{"atan2", Intrinsic::not_intrinsic},
{"__nv_atan2", Intrinsic::not_intrinsic},
#if LLVM_VERSION_MAJOR >= 19
{"cosh", Intrinsic::cosh},
{"sinh", Intrinsic::sinh},
{"tanh", Intrinsic::tanh},
#else
{"cosh", Intrinsic::not_intrinsic},
{"sinh", Intrinsic::not_intrinsic},
{"tanh", Intrinsic::not_intrinsic},
#endif
{"acosh", Intrinsic::not_intrinsic},
{"asinh", Intrinsic::not_intrinsic},
{"atanh", Intrinsic::not_intrinsic},
Expand Down Expand Up @@ -3849,6 +3855,11 @@ void TypeAnalyzer::visitIntrinsicInst(llvm::IntrinsicInst &I) {
case Intrinsic::exp2:
case Intrinsic::sin:
case Intrinsic::cos:
#if LLVM_VERSION_MAJOR >= 19
case Intrinsic::sinh:
case Intrinsic::cosh:
case Intrinsic::tanh:
#endif
case Intrinsic::floor:
case Intrinsic::ceil:
case Intrinsic::trunc:
Expand Down
5 changes: 5 additions & 0 deletions enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,11 @@ static inline bool isNoEscapingAllocation(const llvm::Function *F) {
case Intrinsic::exp:
case Intrinsic::cos:
case Intrinsic::sin:
#if LLVM_VERSION_MAJOR >= 19
case Intrinsic::tanh:
case Intrinsic::cosh:
case Intrinsic::sinh:
#endif
case Intrinsic::copysign:
case Intrinsic::fabs:
return true;
Expand Down
Loading
Loading