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

Default stream-ordered device memory resource. Allocations are made with cudaMallocAsync and freed with cudaFreeAsync via the util::cuda wrappers. More...

#include <nanovdb/cuda/DeviceResource.h>

Public Member Functions

void * allocate_async (size_t bytes, size_t, cudaStream_t stream)
 Stream-ordered allocation.
void deallocate_async (void *p, size_t, size_t, cudaStream_t stream)
 Stream-ordered deallocation.
void * allocate (size_t bytes, size_t alignment)
 Synchronous allocation; the returned memory is immediately valid on every stream.
void deallocate (void *p, size_t bytes, size_t alignment)
 Synchronous deallocation; the caller guarantees that device work touching the memory has completed.

Static Public Member Functions

static void * allocateAsync (size_t bytes, size_t alignment, cudaStream_t stream)
static void deallocateAsync (void *p, size_t bytes, size_t alignment, cudaStream_t stream)

Static Public Attributes

static constexpr size_t DEFAULT_ALIGNMENT = 256

Detailed Description

Default stream-ordered device memory resource. Allocations are made with cudaMallocAsync and freed with cudaFreeAsync via the util::cuda wrappers.

Note
Models the AsyncResource concept, which refines the synchronous Resource concept (as in CCCL's cuda::mr): the instance methods provide both the stream-ordered allocate_async / deallocate_async and the synchronous allocate / deallocate. The type is stateless, so a default-constructed instance adds no overhead. The static allocateAsync / deallocateAsync methods are deprecated.

Member Function Documentation

◆ allocate()

void * allocate ( size_t bytes,
size_t alignment )
inline

Synchronous allocation; the returned memory is immediately valid on every stream.

Parameters
bytesnumber of bytes to allocate
alignmentrequested alignment

◆ allocate_async()

void * allocate_async ( size_t bytes,
size_t ,
cudaStream_t stream )
inline

Stream-ordered allocation.

Parameters
bytesnumber of bytes to allocate
streamcuda stream the allocation is ordered on
Note
the alignment parameter is unnamed: cudaMallocAsync always 256B-aligns

◆ allocateAsync()

void * allocateAsync ( size_t bytes,
size_t alignment,
cudaStream_t stream )
inlinestatic

◆ deallocate()

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

Synchronous deallocation; the caller guarantees that device work touching the memory has completed.

Parameters
ppointer previously returned by allocate or allocate_async
bytessize of the allocation in bytes
alignmentalignment of the allocation in bytes

◆ deallocate_async()

void deallocate_async ( void * p,
size_t ,
size_t ,
cudaStream_t stream )
inline

Stream-ordered deallocation.

Parameters
ppointer previously returned by allocate_async
streamcuda stream the deallocation is ordered on

◆ deallocateAsync()

void deallocateAsync ( void * p,
size_t bytes,
size_t alignment,
cudaStream_t stream )
inlinestatic

Member Data Documentation

◆ DEFAULT_ALIGNMENT

size_t DEFAULT_ALIGNMENT = 256
staticconstexpr