Repository navigation
Conversation
The oneMKL wrappers submit without dependencies and discard the returned events, relying on the SYCL queue to execute their work in submission order. The queue was created without the in_order property; that went unnoticed because every wrapper waits for the queue before returning. Without an async handler, an asynchronous error would also have reached DPC++'s default handler, which terminates the process. Create the queue in order, with a handler that records errors. The SYCL queue now lives on the task's stream rather than in task-local storage, so that the points that wait for oneMKL work (the next Julia submission, host accesses, synchronize) can wait for the SYCL queue and report what it recorded as a SYCLError. The next oneMKL call also reports them.
Every generated wrapper waited for the queue after submitting its work, which made each call a host round trip: back-to-back gemm! calls on 32x32 matrices took 75 µs each on an Arc A770. The wait dates from before oneAPI.jl ordered oneMKL work with the rest: today, memory passed as a ZePtr records the task's stream as its user, so host accesses, other tasks and the next Julia submission wait for the oneMKL work as needed. The generator now only keeps the wait where that tracking doesn't cover the call: bindings that pass host pointers (the scalar results of dot and nrm2, the parameter arrays of grouped batch routines, and other bindings without ZePtr types), the sparse routines, whose matrix handles refer to memory the call doesn't see, and potrf, getrf and sytrf, whose info is returned to LinearAlgebra. Scratchpad size queries and the hand-written batch wrappers no longer wait before the call. The FFT wrappers keep waiting. Two cases relied on the wait for ordering. An FFT plan executes on the queue of the task that created it, so a plan used by another task now first waits for that task's oneMKL work. And the BLAS wrappers submit to the device of their arguments, while the memory records the selected device's stream as its user; when the two differ, the call is now ordered after that stream's work, and waiting for that stream also waits for the call. Small gemm!, syrk! and trsm! calls now take 10-17 µs. With oneMKL 2026.1 on the A770, the factorizations that report info (potrf, getrf, geqrf, syevd, gesvd, ...) wait for the GPU internally and throw from the call, while potrs, getrs, getri and trtrs report nothing either way, so skipping the wait loses no error reporting.
Contributor
|
Documentation preview: https://juliagpu.github.io/oneAPI.jl/previews/PR791/ |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every oneMKL wrapper in the support library waited for the queue after submitting its work, so each call was a host round trip and a sequence of small calls couldn't overlap (point 3 of #766). The wait was added in #518 to fix
normreturning 0, before oneAPI.jl ordered oneMKL work with the rest of its operations. Today memory passed to oneMKL as aZePtrrecords the task's stream as its user, so host reads, other tasks and the next kernel already wait for the oneMKL work they depend on.The generated wrappers now return once their work is submitted. The wait stays where that tracking doesn't apply: bindings that pass host memory (the scalar results of
dotandnrm2, the parameter arrays of the grouped batch routines, and other bindings withoutZePtrargument types), the sparse routines, whose matrix handles refer to memory the call doesn't see, the FFTs, whose plans use the queue of the task that created them, andpotrf/getrf/sytrf, which returninfotocholesky,luandbunchkaufman. The generator decides from the binding types inres/support.toml, so a newly wrapped routine waits until its binding passes device memory asZePtr. Two ordering gaps that the wait used to hide are closed: an FFT plan used by another task than the one that created it executes on the creator's queue, so it now first waits for the using task's oneMKL work; and a call submitted to the device of its arguments rather than the selected one (as the BLAS wrappers do since #534) is now ordered with, and waited for through, the selected device's stream, which is where its memory records its user.Because calls are no longer serialized by the wait, the SYCL queue is now created
in_order(the wrappers submit without dependencies). It also gets an async handler: errors that oneMKL reports after a call returned are thrown as aSYCLErrorby the next oneMKL call or by whatever waits for the work (synchronize, a host read, the next kernel). Without a handler, DPC++'s default one would have terminated the process.Per call, back-to-back on an Arc A770,
Float32, best of 5 × 500 calls with onesynchronizeat the end (the reproducer from #766):gemm!m=32 / 64 / 256syrk!m=32 / 64 / 256trsm!m=32 / 64 / 256potrs!n=32 / 256potrf!n=32 / 256potrf!doesn't change because oneMKL itself waits for the GPU insidepotrf, as it does ingetrf,geqrf,ormqr,orgqr,potri,syevd,gesvdandgebrd. That is also why there is nocheckkeyword like the one in JuliaGPU/CUDA.jl#3639 and JuliaGPU/AMDGPU.jl#1220: oneMKL reportsinfoby throwing from the call, never at the wait.potrs,getrs,getriandtrtrsreturn early and never report a singular matrix, waiting or not. So skipping the wait loses no error reporting, and a keyword to restore it would change nothing (measured on the A770 with oneMKL 2026.1; I couldn't check PVC).The new tests keep the queue busy with large products and check that
gemm!,mul!,syrk!,trsm!andpotrs!return before it drains (they fail with the old library), thatdotandpotrf!still wait, that a chain of dependent calls reads back correctly from this task and from another one, and thatcholeskystill throwsPosDefExceptionbehind queued work. The oneMKL, FFT and SYCL tests and the full suite pass locally. This changesdeps/src, so CI builds the support library from source, and oneAPI_Support_jll needs a new build before a release.