oneMKL Integration
oneAPI.jl provides bindings to the Intel oneMKL library, enabling high-performance linear algebra operations on Intel GPUs.
Dense Linear Algebra (BLAS/LAPACK)
Standard BLAS and LAPACK operations are automatically accelerated when using oneArray.
using oneAPI, LinearAlgebraA = oneArray(rand(Float32, 100, 100))B = oneArray(rand(Float32, 100, 100))# Matrix multiplication (GEMM)C = A * B# Linear solve (AX = B)X = A \ BLike kernels, most dense oneMKL calls return as soon as their work is submitted, and later operations wait for it as needed. Calls that produce a value on the host wait for it: dot, norm and the factorizations whose info cholesky, lu and bunchkaufman check. The sparse and FFT functions also wait. An error that oneMKL reports after a call returned is thrown as a SYCLError by the task's next oneMKL call, or by the next operation that waits for the call's work, such as synchronize() or copying its result to the host.
Sparse Linear Algebra
oneAPI.jl supports sparse matrix operations via oneMKL's sparse BLAS functionality. These integrate with Julia's SparseArrays standard library.
using oneAPI, oneAPI.oneMKL, SparseArrays, LinearAlgebra# Create a sparse matrix on CPUA = sprand(Float32, 100, 100, 0.1)# Move to GPU (converts to oneMKL format)dA = oneMKL.oneSparseMatrixCSR(A)# Create a dense vectorx = oneArray(rand(Float32, 100))# Sparse matrix-vector multiplicationy = dA * xThree storage formats are available: oneSparseMatrixCSR, oneSparseMatrixCSC and oneSparseMatrixCOO. They are subtypes of the corresponding GPUArrays.jl abstract types (AbstractGPUSparseMatrixCSR, AbstractGPUSparseMatrixCSC, AbstractGPUSparseMatrixCOO), so the generic sparse functionality of GPUArrays.jl is available: broadcasting (zero-preserving functions return a sparse matrix, others a dense oneArray), sum/mapreduce (also along a dimension), norm/opnorm, findnz, triu/tril/kron, iszero, and scalar indexing under GPUArrays.@allowscalar. Matrices can be converted between the three formats, transposed and added on the device, and adapt(oneArray, A) of a SparseMatrixCSC yields a oneSparseMatrixCSC.
dA = oneSparseMatrixCSR(sprand(Float32, 100, 100, 0.1))dB = dA .* 2f0 # oneSparseMatrixCSRdC = dA .+ 1f0 # dense oneMatrixsum(dA; dims=1) # row vectordAt = oneSparseMatrixCSC(dA) # format conversion, on the devicedS = dA + transpose(dA) # sparse additionAny element type can be stored in these matrices, but the oneMKL operations (*, mul!, the triangular solves, and the sparse_*! wrappers) require Float32, Float64, ComplexF32 or ComplexF64 values with Int32 or Int64 indices. The oneMKL matrix handle is created lazily when such an operation is first invoked; it refers to the storage vectors of the matrix, which therefore must not be modified in place afterwards (use copyto! or create a new matrix instead).
oneMKL's sparse back-end is CSR-based, and a oneSparseMatrixCSC is therefore handed to oneMKL as the CSR representation of its transpose (this requires oneMKL 2025.3 or later). As a consequence the triangular operations (sparse_trmv!, sparse_trsv!, sparse_trsm!) cannot be expressed for CSC matrices and throw an ArgumentError. Prefer CSR when you have the choice.
FFTs
Fast Fourier Transforms are supported through AbstractFFTs.jl interface integration with oneMKL DFTs. oneAPI.jl depends on AbstractFFTs.jl, so no separate FFT package is required.
using oneAPI, AbstractFFTsa = oneArray(rand(ComplexF32, 1024))# Forward FFTb = fft(a)# Inverse FFTc = ifft(b)