From 7c07a62e3d720c570b3258cc5aaa7c41af2c4146 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 13 Aug 2024 10:10:56 +0200 Subject: [PATCH] Don't evict memory before freeing it. (#459) Memory eviction is not queue ordered, so unsafe to perform here. But it's probably not needed as we're freeing the memory anyway. This was triggered by the recent resize implementation, which frees quickly after issueing a copy operation. --- src/pool.jl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pool.jl b/src/pool.jl index 0b27f10c..06c4c973 100644 --- a/src/pool.jl +++ b/src/pool.jl @@ -55,11 +55,17 @@ end function release(buf::oneL0.AbstractBuffer) sizeof(buf) == 0 && return - if buf isa oneL0.DeviceBuffer || buf isa oneL0.SharedBuffer - ctx = oneL0.context(buf) - dev = oneL0.device(buf) - evict(ctx, dev, buf) - end + # XXX: is it necessary to evice memory if we are going to free it? + # this is racy, because eviction is not queue-ordered, and + # we don't want to synchronize inside what could have been a + # GC-driven finalizer. if we need to, port the stream/queue + # tracking from CUDA.jl so that we can synchronize only the + # queue that's associated with the buffer. + #if buf isa oneL0.DeviceBuffer || buf isa oneL0.SharedBuffer + # ctx = oneL0.context(buf) + # dev = oneL0.device(buf) + # evict(ctx, dev, buf) + #end free(buf; policy=oneL0.ZE_DRIVER_MEMORY_FREE_POLICY_EXT_FLAG_BLOCKING_FREE)