Skip to content
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

Compose with ArrayAllocators.jl #18

Open
mkitti opened this issue Jul 28, 2022 · 3 comments
Open

Compose with ArrayAllocators.jl #18

mkitti opened this issue Jul 28, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@mkitti
Copy link
Contributor

mkitti commented Jul 28, 2022

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 method ArrayAllocators.allocate. We should be able to take that pointer and use it in a MallocArray.

One way of setting that up would be via Base.unsafe_wrap.

@brenhinkeller
Copy link
Owner

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.

@mkitti
Copy link
Contributor Author

mkitti commented Jul 28, 2022

We need either a Ptr wrapper or a type parameter to allow for alternate implementations of free when Libc.free might not apply.

@brenhinkeller
Copy link
Owner

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)

@brenhinkeller brenhinkeller added the enhancement New feature or request label Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants