OpenVDB 13.1.0
Loading...
Searching...
No Matches
PinnedResource Class Reference

Default host-pinned memory resource. Allocations are page-locked host memory (cudaMallocHost) that is both host-accessible and device-accessible, so it can serve as the host side of an asynchronous host<->device copy. More...

#include <nanovdb/cuda/PinnedResource.h>

Public Member Functions

void * allocate (size_t bytes, size_t alignment)
 Synchronous allocation of page-locked host memory.
void deallocate (void *p, size_t bytes, size_t alignment)
 Synchronous deallocation.

Static Public Attributes

static constexpr size_t DEFAULT_ALIGNMENT = 256
static constexpr bool HOST_ACCESSIBLE = true
 Pinned allocations are mapped into the host address space, so containers over this resource remain host-readable (detected by nanovdb::cuda::is_host_accessible_resource).

Detailed Description

Default host-pinned memory resource. Allocations are page-locked host memory (cudaMallocHost) that is both host-accessible and device-accessible, so it can serve as the host side of an asynchronous host<->device copy.

Note
This resource is synchronous: cudaMallocHost / cudaFreeHost synchronize the context, so it models the synchronous Resource concept (allocate / deallocate, no stream) rather than the stream-ordered AsyncResource concept. It is a seam so callers can substitute a pooled / genuinely stream-ordered pinned-host resource and avoid that synchronization.

Member Function Documentation

◆ allocate()

void * allocate ( size_t bytes,
size_t alignment )
inline

Synchronous allocation of page-locked host memory.

Parameters
bytesnumber of bytes to allocate
alignmentrequested alignment (ignored; cudaMallocHost is page-aligned)

◆ deallocate()

void deallocate ( void * p,
size_t bytes,
size_t alignment )
inline

Synchronous deallocation.

Parameters
ppointer previously returned by allocate
bytessize passed to the matching allocate (unused)
alignmentalignment passed to the matching allocate (unused)

Member Data Documentation

◆ DEFAULT_ALIGNMENT

size_t DEFAULT_ALIGNMENT = 256
staticconstexpr

◆ HOST_ACCESSIBLE

bool HOST_ACCESSIBLE = true
staticconstexpr

Pinned allocations are mapped into the host address space, so containers over this resource remain host-readable (detected by nanovdb::cuda::is_host_accessible_resource).