Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #718 from JuliaGPU/tb/unsafe_free_workspace
Browse files Browse the repository at this point in the history
Actually put the workspace buffer back in the memory pool.
  • Loading branch information
maleadt authored May 13, 2020
2 parents 2da1b24 + 31dcff3 commit 3d1038f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ Afterwards, the buffer is put back into the memory pool for reuse.
This helper protects against the rare but real issue of `getWorkspaceSize` returning
different results based on the GPU device memory pressure, which might change _after_
initial allocation of the workspace (which can cause a GC collection).
Use of this macro should be as physically close as possible to the function that actually
uses the workspace, to minimize the risk of GC interventions between the allocation and use
of the workspace.
"""
macro workspace(ex...)
code = ex[end]
Expand Down Expand Up @@ -128,7 +123,9 @@ macro workspace(ex...)
end

let $(esc(code_arg)) = workspace
$(esc(code))
ret = $(esc(code))
unsafe_free!(workspace)
ret
end
end
end

0 comments on commit 3d1038f

Please sign in to comment.