New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When is it safe to free external DevicePtrs? #435
Comments
(oops, sorry I forgot to reply to this... feel free to ping me when I lose track of things...) Hm, that is a good question...
Yes, arrays are considered reclaimable once the Yes, I think the code you posted at the end should be safe; |
A further comment... I think v1.2 does implement (1) above as being synchronous w.r.t. kernel execution. I think this problem exists only in the development version, where a lot of this code got rewritten (mostly for the benefit of the CPU backend). |
I think this can be closed... feel free to reopen if you have further questions |
In this stack overflow answer, there's code similar to the following for making an
Array
out of aDevicePtr
.Something that's not quite clear to me is precisely when it's safe to free the device array backing
arr
. There're a few potential answers:r
is in WHNF, which means the kernel has launched. This is probably not sufficient, becauseuse
d arrays are allowed to be copied to the remote asynchronously.r
(or part of it) is in normal form, which means the computation has finished. This probably works, but isn't ideal, since I might want to use the samearr
again later.arr
(or itsArrayData
) is GC'd, which means the host is done with it but it might still be present on the device. Empirically, this seems to work, but I want to double-check that I understand why.Initially the assumption 'host array is unreachable' -> 'device array is reclaimable' seemed insufficient to me, but from what I can tell this is essentially how
Data.Array.Accelerate.Array.Remote.Table
works. From my understanding, arrays are considered reclaimable once their UniqueArray goes out of scope.Is it safe to do something like this?
The text was updated successfully, but these errors were encountered: