Skip to content

Commit 532fa02

Browse files
authored
Check JLL availability during init. (JuliaGPU#274)
1 parent e53b8a1 commit 532fa02

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

lib/level-zero/oneL0.jl

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,28 @@ include("residency.jl")
8181
const functional = Ref{Bool}(false)
8282

8383
function __init__()
84-
res = unsafe_zeInit(0)
85-
if res == RESULT_ERROR_UNINITIALIZED
86-
@error """No compatible oneAPI driver implementation found.
87-
Your hardware probably is not supported by any oneAPI driver.
88-
89-
oneAPI.jl currently only supports the Intel Compute runtime,
90-
consult their README for a list of compatible hardware:
91-
https://github.com/intel/compute-runtime#supported-platforms"""
92-
elseif res !== RESULT_SUCCESS
93-
throw_api_error(res)
94-
else
84+
precompiling = ccall(:jl_generating_output, Cint, ()) != 0
85+
precompiling && return
86+
87+
if !oneAPI_Level_Zero_Loader_jll.is_available()
88+
@error """No oneAPI Level Zero loader found for your platform. Currently, only Linux x86 is supported.
89+
If you have a local oneAPI toolchain, you can use that; refer to the documentation for more details."""
90+
return
91+
end
92+
93+
if !NEO_jll.is_available()
94+
@error """No oneAPI driver found for your platform. Currently, only Linux x86_64 is supported.
95+
If you have a local oneAPI toolchain, you can use that; refer to the documentation for more details."""
96+
return
97+
end
98+
99+
try
100+
zeInit(0)
95101
functional[] = true
102+
catch err
103+
@error "Failed to initialize oneAPI" exception=(err,catch_backtrace())
104+
functional[] = false
105+
return
96106
end
97107
end
98108

src/oneAPI.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ include("utils.jl")
6868

6969
function __init__()
7070
precompiling = ccall(:jl_generating_output, Cint, ()) != 0
71-
if !precompiling
72-
eval(overrides)
73-
end
71+
precompiling && return
7472

75-
# ensure that libopencl.so
73+
eval(overrides)
74+
75+
# ensure that the OpenCL runtime dispatcher finds the ICD files from our artifacts
7676
ENV["OCL_ICD_VENDORS"] = oneL0.NEO_jll.libigdrcl
7777
end
7878

0 commit comments

Comments
 (0)