-
Notifications
You must be signed in to change notification settings - Fork 82
use a local cache for activity reg #2612
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
base: revert-2594-acache
Are you sure you want to change the base?
Conversation
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/analyses/activity.jl b/src/analyses/activity.jl
index 23f59d8..56c6eb6 100644
--- a/src/analyses/activity.jl
+++ b/src/analyses/activity.jl
@@ -382,9 +382,9 @@ Base.@nospecializeinfer @inline function active_reg_inner(
return ty
end
-function active_reg_cached(ctx::EnzymeContext, @nospecialize(ST::Type); justActive=false, UnionSret = false, AbstractIsMixed = false)
+function active_reg_cached(ctx::EnzymeContext, @nospecialize(ST::Type); justActive = false, UnionSret = false, AbstractIsMixed = false)
key = (ST, justActive, UnionSret, AbstractIsMixed)
- get!(ctx.activity_cache, key) do
+ return get!(ctx.activity_cache, key) do
set = Base.IdSet{Type}()
active_reg_inner(ST, set, ctx.world, justActive, UnionSret, AbstractIsMixed)
end
diff --git a/src/compiler.jl b/src/compiler.jl
index 48b7b72..ab87a1d 100644
--- a/src/compiler.jl
+++ b/src/compiler.jl
@@ -50,14 +50,14 @@ using Printf
end
@inline function Base.:|(a1::ActivityState, a2::ActivityState)
- ActivityState(Int(a1) | Int(a2))
+ return ActivityState(Int(a1) | Int(a2))
end
mutable struct EnzymeContext
world::UInt
- activity_cache::Dict{Tuple{Type,Bool,Bool,Bool},ActivityState}
+ activity_cache::Dict{Tuple{Type, Bool, Bool, Bool}, ActivityState}
function EnzymeContext(world)
- new(world, Dict{Tuple{Type,Bool,Bool,Bool},ActivityState}())
+ return new(world, Dict{Tuple{Type, Bool, Bool, Bool}, ActivityState}())
end
end
@@ -3301,7 +3301,7 @@ function create_abi_wrapper(
# 3 is index of shadow
if existed[3] != 0 &&
sret_union &&
- active_reg_cached(interp.context, pactualRetType; justActive=true, UnionSret=true) == ActiveState
+ active_reg_cached(interp.context, pactualRetType; justActive = true, UnionSret = true) == ActiveState
rewrite_union_returns_as_ref(enzymefn, data[3], world, width)
end
returnNum = 0
diff --git a/src/compiler/interpreter.jl b/src/compiler/interpreter.jl
index f6f8a4d..d571cd2 100644
--- a/src/compiler/interpreter.jl
+++ b/src/compiler/interpreter.jl
@@ -281,8 +281,9 @@ function EnzymeInterpreter(interp::EnzymeInterpreter;
inactive_rules = interp.inactive_rules,
broadcast_rewrite = interp.broadcast_rewrite,
within_autodiff_rewrite = interp.within_autodiff_rewrite,
- handler = interp.handler,
- context = interp.context,)
+ handler = interp.handler,
+ context = interp.context,
+ )
@assert context.world == world
return EnzymeInterpreter(
cache_or_token, |
Benchmark Results
Benchmark PlotsA plot of the benchmark results has been uploaded as an artifact at https://github.com/EnzymeAD/Enzyme.jl/actions/runs/17927360724/artifacts/4076307285. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## revert-2594-acache #2612 +/- ##
===================================================
Coverage 75.20% 75.20%
===================================================
Files 56 56
Lines 17711 17719 +8
===================================================
+ Hits 13319 13326 +7
- Misses 4392 4393 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cffa09d to
162179a
Compare
d15d98d to
1b3477b
Compare
No description provided.