JuliaCI / BenchmarkTools.jl

A benchmarking framework for the Julia language
Other
604 stars 97 forks source link

@benchmark creates new symbol for each interpolation of a symbol #329

Open omlins opened 10 months ago

omlins commented 10 months ago

It should instead create only one new symbol per interpolated symbol and reuse it for multiple interpolations of the same symbol.

The current situation can lead to errors in subsequent code generation as for example here:

julia> @benchmark @parallel ∇=($A->$Ā, $B->$B̄) f!($A, $B, $a) # automatic differentiation of f!
ERROR: LoadError: KeywordArgumentError: variable ##A#440 in ((var"##A#440"->begin
            #= REPL[18]:1 =#
            var"##Ā#441"
        end), (var"##B#442"->begin
            #= REPL[18]:1 =#
            var"##B̄#443"
        end)) is not a positional argument of the kernel call f!(var"##A#444", var"##B#445", var"##a#446").

@benchmark should generate the following in this case (reuse var"##A#440" and var"##B#442"):

@parallel ∇=(var"##A#440"->var"##Ā#441", var"##B#442"->var"##B̄#443") f!(var"##A#440", var"##B#442", var"##a#443")
gdalle commented 9 months ago

Hey @omlins, thanks for the issue. Do you have any idea how to fix it? I'm a little out of my depth with macros here

gdalle commented 9 months ago

Also, a complete MWE would be lovely if you can provide one

willow-ahrens commented 2 months ago

Does anyone know if this is related to https://github.com/JuliaCI/BenchmarkTools.jl/issues/339?