scanse / sweep-sdk

Sweep SDK
MIT License
90 stars 85 forks source link

Make libsweep allocator aware #10

Open daniel-j-h opened 8 years ago

daniel-j-h commented 8 years ago

We should provide means for the user to configure the allocator. The user should be able to plug in e.g. a efficient stack-allocator if she wants to. This needs to go hand in hand with the C++ abstractions.

MikeGitb commented 7 years ago

Could that be solved by adding another create device function that takes two additional function pointers as parameters (one for allocation and one for deallocation)? Maybe with an additional void* parameter?

daniel-j-h commented 7 years ago

Not sure if device specific allocators make sense - we could simply store decltype(free) / decltype(malloc p) pointers in the library initialized with malloc and free and expose a function to set both? I don't quite fully understand the pros and cons here.

For the impl. we can then provide a C++ allocator passing it to the stdlib functions and collections we use. Here are some notes on allocators in C++11 and a stack allocator:

MikeGitb commented 7 years ago

@daniel-j-h: You are probably right. That a global would suffice here.

The additional question here is how much information we want to give the userabout implementation details to tune the allocator (either as a static guarantee or something that can be queried during runtime).

Afaik there are 4 types of allocations: