Skip to content

Commit

Permalink
Don't evict memory before freeing it. (#459)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maleadt authored Aug 13, 2024
1 parent b1ba771 commit 7c07a62
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 7c07a62

Please sign in to comment.