OpenVDB 14.0.0
Loading...
Searching...
No Matches
MallocResource Class Reference

Synchronous device memory resource backed by cudaMalloc/cudaFree. Models only the Resource concept: it never touches stream-ordered allocation, so it works on devices without memory-pool support (cudaDevAttrMemoryPoolsSupported == 0), where DeviceResource's cudaMallocAsync path fails by design. Pair with AsyncFromSync to drive the stream-ordered builders on such a device. More...

#include <nanovdb/cuda/DeviceResource.h>

Public Member Functions

void * allocate (size_t bytes, size_t)
 Allocates bytes with cudaMalloc; valid on every stream when this returns. A zero request returns nullptr.
void deallocate (void *p, size_t, size_t)
 Frees p with cudaFree; the caller guarantees that device work touching the memory has completed.

Static Public Attributes

static constexpr size_t DEFAULT_ALIGNMENT = 256

Friends

bool operator== (const MallocResource &, const MallocResource &)
 Stateless: memory allocated through one instance may be deallocated through any other, so every two instances compare equal (the equality cuda::mr's resource concepts require).
bool operator!= (const MallocResource &, const MallocResource &)

Detailed Description

Synchronous device memory resource backed by cudaMalloc/cudaFree. Models only the Resource concept: it never touches stream-ordered allocation, so it works on devices without memory-pool support (cudaDevAttrMemoryPoolsSupported == 0), where DeviceResource's cudaMallocAsync path fails by design. Pair with AsyncFromSync to drive the stream-ordered builders on such a device.

Member Function Documentation

◆ allocate()

void * allocate ( size_t bytes,
size_t  )
inline

Allocates bytes with cudaMalloc; valid on every stream when this returns. A zero request returns nullptr.

◆ deallocate()

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

Frees p with cudaFree; the caller guarantees that device work touching the memory has completed.

◆ operator!=

bool operator!= ( const MallocResource & ,
const MallocResource &  )
friend

◆ operator==

bool operator== ( const MallocResource & ,
const MallocResource &  )
friend

Stateless: memory allocated through one instance may be deallocated through any other, so every two instances compare equal (the equality cuda::mr's resource concepts require).

Member Data Documentation

◆ DEFAULT_ALIGNMENT

size_t DEFAULT_ALIGNMENT = 256
staticconstexpr