(no title)
pbalcer | 1 year ago
Not necessarily. If you are able to map a block of normal memory in a known location relative to the GPU memory that you are managing with an "offset allocator", it should be possible to directly calculate the metadata location for each "offset". This is how most allocators find arenas/buckets (whatever you want to call them) for an allocation by a pointer.
Something like this:
+-------------------------+ 0x000000 (start of managed memory)
| Metadata |
| |
| |
| ... |
+-------------------------+ 0x001000
| Padding ... |
+-------------------------+ 0x010000
| GPU Memory Block |
| |
| |
| | ~2MB block
| |
| |
| |
+-------------------------+ 0x210000
With this layout, to get to a metadata for an allocation, all you need to do is to align down the allocation pointer and calculate the appropriate location in the metadata page.This obviously won't work in all scenarios, but it's a simple and practical way around a map lookup.
exDM69|1 year ago
If you have a large allocation you have to mark every "page" in metadata table which makes allocation O(size in bytes / page size).
The overhead might still be practically acceptable, even if it is not constant time.