Open mkitti opened 2 years ago
Oh, that could be cool!
A MallocArray
is basically just a thin wrapper around a pointer, so if you have a pointer you can make a MallocArray
from it with just MallocArray{T}(ptr, size...)
The main catch might be making an AbstractArrayAllocator
that is StaticCompiler-able? But if that can be done then wrapping the pointer is easy enough.
We need either a Ptr
wrapper or a type parameter to allow for alternate implementations of free
when Libc.free
might not apply.
I think adding a new type parameter could make sense -- that may actually help answer a related question about what type views should return (some discussion at https://julialang.zulipchat.com/#narrow/stream/137791-general/topic/StaticTools.2Ejl/near/291368732)
I am interested in exploring how ArrayAllocators.jl may compose with MallocArray.
Essentially, the main task of an
AbstractArrayAllocator
is to allocate memory safely and return a pointer via the methodArrayAllocators.allocate
. We should be able to take that pointer and use it in aMallocArray
.One way of setting that up would be via
Base.unsafe_wrap
.