Managed (unified) memory resource. Allocations (cudaMallocManaged) are accessible from both the host and the device, with the driver migrating pages on demand, so a container over this resource serves grids that are read on both sides – the replacement for the legacy UnifiedBuffer. A GridHandle over this resource parses (and validates) its metadata through the device like any device buffer – a host-side parse could race still-running producer kernels – while the host accessors remain available afterwards; ordering host reads after device writes is the caller's responsibility, exactly as with UnifiedBuffer.
More...
#include <nanovdb/cuda/ManagedResource.h>
|
| void * | allocate (size_t bytes, size_t alignment) |
| | Synchronous allocation of managed memory.
|
| void | deallocate (void *p, size_t bytes, size_t alignment) |
| | Synchronous deallocation.
|
Managed (unified) memory resource. Allocations (cudaMallocManaged) are accessible from both the host and the device, with the driver migrating pages on demand, so a container over this resource serves grids that are read on both sides – the replacement for the legacy UnifiedBuffer. A GridHandle over this resource parses (and validates) its metadata through the device like any device buffer – a host-side parse could race still-running producer kernels – while the host accessors remain available afterwards; ordering host reads after device writes is the caller's responsibility, exactly as with UnifiedBuffer.
- Note
- This resource is synchronous: cudaMallocManaged / cudaFree have no stream-ordered form, so it models the synchronous Resource concept (allocate / deallocate, no stream). The usual contract applies: the caller ensures device work touching an allocation has completed before it is freed.
◆ allocate()
| void * allocate |
( |
size_t | bytes, |
|
|
size_t | alignment ) |
|
inline |
Synchronous allocation of managed memory.
- Parameters
-
| bytes | number of bytes to allocate |
| alignment | requested alignment (ignored; cudaMallocManaged satisfies at least DEFAULT_ALIGNMENT) |
◆ deallocate()
| void deallocate |
( |
void * | p, |
|
|
size_t | bytes, |
|
|
size_t | alignment ) |
|
inline |
Synchronous deallocation.
- Parameters
-
| p | pointer previously returned by allocate |
| bytes | size passed to the matching allocate (unused) |
| alignment | alignment passed to the matching allocate (unused) |
◆ DEFAULT_ALIGNMENT
| size_t DEFAULT_ALIGNMENT = 256 |
|
staticconstexpr |
◆ DEVICE_ACCESSIBLE
| bool DEVICE_ACCESSIBLE = true |
|
staticconstexpr |
◆ HOST_ACCESSIBLE
| bool HOST_ACCESSIBLE = true |
|
staticconstexpr |