Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/level-zero/oneL0.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function initialize(; quiet::Bool=false)
# Driver handles are process-local, so nothing keyed on one may survive into another
# process through a precompiled image.
empty!(extension_properties_cache)
@atomic deferred_frees.context = WeakRef()

# Resolve the LTS master switch up front, before the driver-availability early
# returns below: it gates codegen and behavior and must be set even on hosts
Expand Down
8 changes: 7 additions & 1 deletion src/compiler/exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ function allocate_report_slot(ctx::ZeContext, dev::ZeDevice, list)
end

release_report_slot(ctx::ZeContext, dev::ZeDevice, slot::ReportSlot) =
with_pool_lock(() -> push!(free_report_slots[(ctx, dev)], slot))
with_pool_lock() do
# the slabs are forgotten when the precompilation workload resets its state, and
# streams it created can be finalized later
free = get(free_report_slots, (ctx, dev), nothing)
free === nothing || push!(free, slot)
return
end

# Called when a stream is collected. Its kernels may still be executing, and writing the
# report, in which case the slot is leaked, as is the command list (see its finalizer).
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ end
empty!(stagings)
empty!(staged_devices)
empty!(eltype_support_cache)
empty!(free_report_slots)
with_pool_lock(() -> empty!(free_report_slots))
empty!(_compiler_configs)
empty!(oneL0.extension_properties_cache)
Base.@atomic oneL0.deferred_frees.context = WeakRef()
Base.@atomic oneAPIKernels.device_limits_cache.limits = oneAPIKernels.DeviceLimitsDict()
empty!(oneAPIKernels.pending_events)
_allocated_bytes[] = 0
Expand Down
5 changes: 5 additions & 0 deletions test/level-zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ end
# decide for other precompilation processes, and only applies while precompiling
@test oneAPI.precompile_probe[] === nothing
@test !oneAPI.can_precompile()

# nor is the context the workload freed memory in, whose handle is null once loaded.
# checked in a fresh process, as freeing memory here replaces it.
script = "using oneAPI; exit(oneAPI.oneL0.deferred_frees.context.value === nothing ? 0 : 1)"
@test success(`$(Base.julia_cmd()) --project=$(Base.active_project()) -e $script`)
end


Expand Down
Loading