Matrix Multiplication Using oneAPI.jl Fails on Second Invocation

Been playing with oneAPI.jl to run matrix x vector multiplication using the integrated Intel GPU on my Windows laptop (WSL2) and came across a strange behavior.

The first time mul!() is invoked I get a reasonable result, all subsequent calls return zeros and when I exit Julia by calling exit() I get a segmentation fault.

Here’s a repro example:

using Random, Distributions, LinearAlgebra, oneAPI, BenchmarkTools 

row_count = 768
coeff_count = 80
rep_coeffs = rand(Normal(200, 20), coeff_count)
w_vals = 5 .+ (1.5 .* randn(row_count, coeff_count) .^ 2)
res = zeros(row_count)

rep_coeffs_f32 = oneArray(Float32.(rep_coeffs))
w_vals_f32 = oneArray(Float32.(w_vals))
res_f32 = oneArray(zeros(Float32, row_count))

mul!(res_f32, w_vals_f32, rep_coeffs_f32)
mul!(res, w_vals, rep_coeffs)
maximum(abs.(res - Float64.(Array(res_f32)))) < .025

mul!(res_f32, w_vals_f32, rep_coeffs_f32)
mul!(res, w_vals, rep_coeffs)
maximum(abs.(res - Float64.(Array(res_f32)))) < .025

Second check of maximum squared diff returns false.

Has anyone else seen this? Is there anything I am doing here that could be problematic?

Here’s what my environment looks like:

$ julia --project=. --threads=auto
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.4 (2024-06-04)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using oneAPI
julia> oneAPI.versioninfo()
Binary dependencies:
- NEO: 24.22.29735+0
- libigc: 1.0.16695+0
- gmmlib: 22.3.19+0
- SPIRV_LLVM_Translator_unified: 0.4.0+0
- SPIRV_Tools: 2024.2.0+0

Toolchain:
- Julia: 1.10.4
- LLVM: 15.0.7

1 driver:
- 00000000-0000-0000-17ee-b392010371d2 (v1.3.29138, API v1.3.0)

1 device:
- Intel(R) Graphics [0x46a8]

Does it help if you run with SYCL_PI_LEVEL_ZERO_BATCH_SIZE=1 in your environment before loading oneAPI.jl? This may be SYCL batching causes invalid results · Issue #445 · JuliaGPU/oneAPI.jl · GitHub

1 Like

Yep, doing that fixed the behavior.