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

Precompile first interpretation #348

Closed
mofeing opened this issue Dec 9, 2024 · 0 comments · Fixed by #353
Closed

Precompile first interpretation #348

mofeing opened this issue Dec 9, 2024 · 0 comments · Fixed by #353
Labels
good first issue Good for newcomers

Comments

@mofeing
Copy link
Collaborator

mofeing commented Dec 9, 2024

First time we trace over some code using our own custom AbstractInterpreter takes quite a while:

julia> a = ConcreteRArray(rand(2,2))
2×2 ConcreteRArray{Float64, 2}:
 0.33461   0.195871
 0.313405  0.31539

julia> b = ConcreteRArray(rand(2,2))
2×2 ConcreteRArray{Float64, 2}:
 0.89772   0.752033
 0.727069  0.470682

julia> @time @compile sum(a)
 46.769205 seconds (111.81 M allocations: 5.620 GiB, 2.84% gc time, 99.71% compilation time: <1% of which was recompilation)
Reactant.Compiler.Thunk{Symbol("##sum_reactant#478143")}()

julia> @time @compile sum(a)
  0.020059 seconds (3.32 k allocations: 154.555 KiB, 27.77% compilation time)
Reactant.Compiler.Thunk{Symbol("##sum_reactant#478157")}()

julia> @time @compile +(a,b)
  1.088363 seconds (2.17 M allocations: 111.751 MiB, 0.85% gc time, 98.53% compilation time: 3% of which was recompilation)
Reactant.Compiler.Thunk{Symbol("##+_reactant#481975")}()

julia> @time @compile +(a,b)
  0.029532 seconds (22.80 k allocations: 1.119 MiB, 60.21% compilation time)
Reactant.Compiler.Thunk{Symbol("##+_reactant#482083")}()

and it doesn't matter on the function

julia> a = ConcreteRArray(rand(2,2))
2×2 ConcreteRArray{Float64, 2}:
 0.185656  0.967931
 0.996481  0.958333

julia> b = ConcreteRArray(rand(2,2))
2×2 ConcreteRArray{Float64, 2}:
 0.47433   0.504905
 0.236917  0.134567

julia> @time @compile +(a,b)
 47.000538 seconds (109.53 M allocations: 5.509 GiB, 2.76% gc time, 99.96% compilation time: <1% of which was recompilation)
Reactant.Compiler.Thunk{Symbol("##+_reactant#470709")}()

julia> @time @compile +(a,b)
  0.028493 seconds (22.81 k allocations: 1.119 MiB, 61.25% compilation time)
Reactant.Compiler.Thunk{Symbol("##+_reactant#470817")}()

julia> @time @compile sum(a)
  1.933345 seconds (4.98 M allocations: 252.630 MiB, 7.10% gc time, 99.37% compilation time: 4% of which was recompilation)
Reactant.Compiler.Thunk{Symbol("##sum_reactant#482179")}()

julia> @time @compile sum(a)
  0.017443 seconds (3.26 k allocations: 152.430 KiB, 29.82% compilation time)
Reactant.Compiler.Thunk{Symbol("##sum_reactant#482193")}()

I think this could be solved with some precompile workload like Enzyme does

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

Successfully merging a pull request may close this issue.

1 participant