Kernel launches are compiled for Vararg{Any} and dispatched at run time
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #687 di @maleadt — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- compilers, performance
Direzione di ricerca
Start with code_typed on a kernel call to confirm the Vararg{Any} specialization in src/oneAPIKernels.jl (around line 119) and src/compiler/execution.jl (around line 403). Then look at zefunction (lines 287-323), device() in src/context.jl, and setindex! in lib/level-zero/module.jl. Done means the changes infer fully and precompile timing drops for a new signature, which needs an Intel GPU to verify launches.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
JuliaGPU/Metal.jl#1014 cut the host-side compilation needed to launch a kernel with a new argument signature by 4-10x on Metal. I checked which of the causes found there also apply to oneAPI.jl; several do, and here they also make every launch go through dynamic dispatch.
I don't have an Intel GPU, so this is based on code_typed and on timing precompile of a function launching a new kernel signature, with the changes below prototyped by redefining the functions.
(obj::KA.Kernel{oneAPIBackend})(args...; ndrange, workgroupsize)(src/oneAPIKernels.jl:119) and(kernel::HostKernel)(args...; kwargs...)(src/compiler/execution.jl:403) are compiled forVararg{Any}, e.g.(..., ::oneArray{Float32,...}, ::Vararg{Any}), even when called from concretely typed code: Julia doesn't specialize a method on varargs it only passes on. That includes the@oneapimacro expansion. Everything after that point is dispatched at run time (map(kernel_convert, ...),zefunction,call,launch_configuration), so each new signature gets compiled piecemeal during its first launch, and every launch pays for the dispatches. Metal.jl fixed this withargs::Vararg{Any,N} ... where N.zefunction(src/compiler/execution.jl:287-323) compiles its whole body for every kernel.device()(src/context.jl:74-78) infers asAny, which makescompiler_config, the comparisons,hashand the conversion dynamic. Theget!(_kernel_instances, h) do HostKernel{F,tt}(f, fun) endclosure has a new type for every kernel, soget!is compiled per kernel as well, even though aHostKernelis only(f, fun)and needs no cache. Splitting it likecufunctionandcufunction_linkin CUDA.jl, withdevice()::ZeDevice, leaves no dynamic calls on the@oneapipath.setindex!(::ZeKernelArgumentList, value, i)(lib/level-zero/module.jl:208-211) is compiled per argument type with the@checked zeKernelSetArgumentValuewrapper inlined. Computing the size and address per type and calling an unspecialized@noinlinesetter saves ~13 ms per new signature.launch_configuration(src/compiler/execution.jl:246) returnsUnion{Missing,Int}, because checkingkernel_props.maxGroupSize !== missingdoesn't narrow a later field access. As a resultthreads_to_workgroupsizereturnsTuple{Any}, and the finalkernel(ctx, args...; items, groups)in the KernelAbstractions launch is a dynamic call. Binding the field to a local first fixes that.
With the first three changes the whole path is inferred, and precompile puts a new signature at ~50 ms (Julia 1.12) / ~44 ms (1.13) for @oneapi and ~31 ms through KernelAbstractions. I can't give a meaningful number for the current code without a GPU, because most of its launch path is only compiled during the launch itself.
- Lingua principale
- Julia
- Stelle
- 218
- Fork
- 36
- Merge medio
- 1g 4h
- PR unite (30g)
- 54
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/oneAPI.jl
-
Make host-to-device uploads non-blocking via a host-USM staging poolForse già presa @maleadt l’ha presa oggi. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Products with a Symmetric/Hermitian oneMKL sparse matrix ignore the wrapperForse già presa @maleadt l’ha presa oggi. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
libraries upstream
Difficoltà 4/5 1-2 giorni Idoneità per principianti 22/100
JuliaGPU/oneAPI.jl#703 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
ci
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
JuliaGPU/oneAPI.jl#663 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di JuliaGPU/oneAPI.jl
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
JuliaGeometry/Meshes.jl#1469 ·
I maintainer di solito rispondono entro 1 giorno
-
distributed 🕸️
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
CliMA/Oceananigans.jl#6295 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CI: two jobs fail on the new ubuntu-latest (Ubuntu 26.04) runner imageForse già presa @bjarthur l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
mojaie/MolecularGraph.jl#151 ·