From cbb05124c7e72c8d1ac59b55de18dd5f01d8adf0 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 12 Aug 2024 18:54:21 +0000 Subject: [PATCH] Don't evict memory before freeing it. 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 0b27f10..06c4c97 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)