SciML / SciML/RuntimeGeneratedFunctions.jl
Scary error when generating large number of RuntimeGeneratedFunctions
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 112
- Forks
- 19
- Avg merge
- 6h 11m
- Merged PRs (30d)
- 9
Description
The MWE fills an array with simple generated functions and calls them in a loop. Works for me when n=50_000, but not when n=65535.
julia> using RuntimeGeneratedFunctions
RuntimeGeneratedFunctions.init(@__MODULE__)
function genfuncs(n)
fs = Any[]
for i=1:n
a = rand()
ex = :(function f(x)
return x * $a
end)
f = @RuntimeGeneratedFunction(ex)
push!(fs, f)
end
return fs
end
function calc(fs)
sum = 0.0
for i = eachindex(fs)
sum += fs[i](42.0)
end
return sum
end
fs = genfuncs(100_000)
calc(fs)
ERROR: UndefVarError: mul_float not defined
Stacktrace:
[1] * at ./float.jl:405 [inlined]
[2] macro expansion at ./REPL[1]:9 [inlined]
[3] macro expansion at /home/krisztian/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:80 [inlined]
[4] macro expansion at ./none:0 [inlined]
[5] generated_callfunc at ./none:0 [inlined]
[6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{var"#_RuntimeGeneratedFunctions_ModTag",(0x92, 0xb5, 0xf6, 0xed, 0xbb, 0x56, 0xdf, 0xe8, 0x21, 0x03, 0xee, 0xa3, 0xe5, 0x65, 0x4c, 0xf8, 0x80, 0xb3, 0xe2, 0x57, 0x59, 0x5a, 0x10, 0x91, 0xd3, 0x39, 0xc9, 0xe2, 0x7b, 0xc5, 0x09, 0xcd, 0xbf, 0xa5, 0xcd, 0x04, 0xa1, 0x99, 0xac, 0x0d, 0xf0, 0x49, 0x08, 0x53, 0xf3, 0x01, 0x0e, 0xff, 0x94, 0x1e, 0x19, 0x76, 0xd1, 0x78, 0xe1, 0x43, 0xc3, 0xa5, 0x47, 0xc1, 0xda, 0x0b, 0x8a, 0xf4),(:x,)})(::Float64) at /home/krisztian/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:68
[7] calc(::Array{Any,1}) at ./REPL[1]:20
[8] top-level scope at REPL[1]:26
julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported genfuncs and calc MWE with Julia 1.5.2, then inspect the generated_callfunc stack frames and src/RuntimeGeneratedFunctions.jl around lines 68 and 80. Trace why the generated functions fail at large counts with UndefVarError: mul_float, and add a regression test showing the MWE completes without that error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100