Skip to content

Commit 15661f7

Browse files
authored
Handle zeInit returning like other GPU packages (#549)
1 parent cf1b008 commit 15661f7

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "oneAPI"
22
uuid = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
3-
version = "2.5.0"
4-
authors = ["Tim Besard <tim.besard@gmail.com>"]
3+
version = "2.5.1"
4+
authors = ["Tim Besard <tim.besard@gmail.com>", "Alexis Montoison", "Michel Schanen <michel.schanen@gmail.com>"]
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

lib/level-zero/oneL0.jl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,35 @@ function __init__()
162162

163163
try
164164
zeInit(0)
165-
functional[] = true
166165
catch err
166+
# Handle the specific case where no oneAPI device is available
167+
if err isa ZeError && err.code == RESULT_ERROR_UNINITIALIZED
168+
functional[] = false
169+
return
170+
end
171+
# For other errors, still report them as errors
167172
@error "Failed to initialize oneAPI" exception=(err,catch_backtrace())
168173
functional[] = false
169174
return
170175
end
171176

177+
# Check if there are actually any drivers/devices available
178+
try
179+
drv_count = Ref{UInt32}(0)
180+
zeDriverGet(drv_count, C_NULL)
181+
if drv_count[] == 0
182+
@info "oneAPI initialized but no drivers found. oneAPI.jl will not be functional."
183+
functional[] = false
184+
return
185+
end
186+
catch err
187+
@error "Failed to enumerate oneAPI drivers" exception = (err, catch_backtrace())
188+
functional[] = false
189+
return
190+
end
191+
192+
functional[] = true
193+
172194
validation_layer[] = parse(Bool, get(ENV, "ZE_ENABLE_VALIDATION_LAYER", "false"))
173195
parameter_validation[] = parse(Bool, get(ENV, "ZE_ENABLE_PARAMETER_VALIDATION", "false"))
174196
end

0 commit comments

Comments
 (0)