|
rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
|
Abstract allocator of buffer objects on a memory_resource. More...
#include <rexlib/core/hardware/memory_allocator.hpp>
Public Member Functions | |
| memory_allocator (const memory_allocator &other)=delete | |
| memory_allocator (memory_allocator &&other)=delete | |
| memory_allocator & | operator= (const memory_allocator &other)=delete |
| memory_allocator & | operator= (memory_allocator &&other)=delete |
| virtual const memory_resource & | get_memory_resource () const noexcept=0 |
| Get the memory resource backing this allocator. | |
| virtual std::size_t | get_max_alignment () const noexcept=0 |
| Get the largest alignment this allocator can satisfy. | |
| virtual std::shared_ptr< buffer > | allocate (std::size_t size, std::size_t alignment, command_queue *queue_hint, command_token &pending)=0 |
| Allocate a new buffer on the backing memory resource. | |
Abstract allocator of buffer objects on a memory_resource.
Concrete implementations are free to back themselves with anything that fits the underlying backend.
The allocator is also in charge of tracking the asynchronous use of the buffers it produces: when a buffer's shared ownership is dropped while device work referencing it is still in flight, the allocator either defers the actual release until that work has completed, or hands the memory out again together with the token of that work.
|
pure virtual |
Allocate a new buffer on the backing memory resource.
The allocator may round size up to satisfy internal alignment or page granularity constraints; the resulting buffer's buffer::get_size may return a number greater than or equal to size .
| size | Requested minimum size, in bytes. |
| alignment | Requested alignment, in bytes. Must be a power of two and not greater than get_max_alignment. |
| queue_hint | Optional non-owning pointer to the queue on which the buffer is expected to be first used. The allocator may use it to hand out the memory that is cheapest to use there. The buffer can be used on any other queue as well. |
| pending | Output parameter that receives the token of the commands that still use the memory handed out. The first use of the buffer has to wait for it. It is empty when nothing uses the memory. |
| std::bad_alloc | (or a backend-specific exception derived from std::exception) on allocation failure. |
| std::invalid_argument | if alignment is not a valid power of two within get_max_alignment. |
|
pure virtualnoexcept |
Get the largest alignment this allocator can satisfy.
The returned value is the strictest alignment that may be passed to allocate. It is a power of two and is constant over the lifetime of the allocator.
|
pure virtualnoexcept |
Get the memory resource backing this allocator.