signature_type_by_tt allocates on every launch on Julia 1.14
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #1025 di @maleadt — integrata
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- julia
- Ambito
- backend, performance
Direzione di ricerca
Start in the signature_type_by_tt implementation and compare its Julia 1.14 path with the pre-1.14 tuple splatting path. The reproducer in the issue measures allocations for sig_splat and sig_map; use it to verify the allocation difference and check behavior when dispatch_key changes type parameters. Done means avoiding the reported per-lookup allocations while preserving the needed dispatch behavior; pull request #1025 is already open.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
On Julia 1.14 (where Core.TypeEgal is defined), signature_type_by_tt builds the signature with map(dispatch_key, u.parameters):
@inline function signature_type_by_tt(ft::Type, tt::Type)
u = Base.unwrap_unionall(tt)::DataType
return Base.rewrap_unionall(Tuple{dispatch_key(ft), map(dispatch_key, u.parameters)...}, tt)
end
Unlike Tuple{ft, u.parameters...}, which the pre-1.14 branch uses and which is folded to a constant for a constant tt, map over the SimpleVector isn't folded: it allocates a Vector{Any} and constructs the tuple type at run time. Since methodinstance calls this on every lookup, every kernel launch through a cached cufunction/clfunction/... allocates, proportionally to the number of arguments.
This shows up in KernelAbstractions' POCL back-end, where a launch with 4 scalar arguments allocates 128 bytes more than on Julia 1.13 and one with 40 arguments 416 bytes more (Profile.Allocs: Memory{Any}, Vector{Any} and a CorruptType from signature_type_by_tt < methodinstance < clfunction), failing KA's "POCL launch with many arguments" test on nightly.
Reproducer without GPUCompiler (same results on 1.13 and 1.14.0-DEV):
@inline function dispatch_key(@nospecialize(t))
if Base.isType(t)
u = Base.type_parameter(t)
!Base.has_free_typevars(u) && return isdefined(Core, :TypeEgal) ? Core.TypeEgal{u} : Type{u}
end
return t
end
@inline sig_splat(ft::Type, tt::Type) = Tuple{ft, (tt::DataType).parameters...}
@inline sig_map(ft::Type, tt::Type) = Tuple{dispatch_key(ft), map(dispatch_key, (tt::DataType).parameters)...}
kern(args...) = nothing
const TT = Tuple{Vector{Int}, ntuple(_ -> Int, 40)...}
f_splat() = sig_splat(typeof(kern), TT)
f_map() = sig_map(typeof(kern), TT)
f_splat(); f_map()
@show @allocated(f_splat()) # 0
@show @allocated(f_map()) # 432
Taking the splatting path unless ft or one of the parameters is a Type{...} (the only case where dispatch_key changes anything) avoids the allocations.
- Lingua principale
- Julia
- Stelle
- 188
- Fork
- 71
- Merge medio
- 1g 14h
- PR unite (30g)
- 65
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di JuliaGPU/GPUCompiler.jl
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
JuliaGPU/GPUCompiler.jl#1008 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
JuliaGPU/GPUCompiler.jl#1019 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
JuliaGPU/GPUCompiler.jl#1014 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
JuliaGPU/GPUCompiler.jl#1011 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
JuliaGPU/GPUCompiler.jl#970 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di JuliaGPU/GPUCompiler.jl
Issue simili
-
_fit_phylo_binomial_xlv: default start calls undefined logit (UndefVarError without beta_init)Apertacode-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
OptimizationCUTEst jobs fail: gfortran not installed on the runnerForse già presa @ChrisRackauckas-Claude l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
SciML/SciMLBenchmarks.jl#1946 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
JuliaSmoothOptimizers/NCL.jl#101 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno