OpenVDB 13.1.0
Loading...
Searching...
No Matches
nanovdb::util::cuda Namespace Reference

Classes

class  Timer
class  unique_ptr
 Simple (naive) implementation of a unique device pointer using stream ordered memory allocation and deallocation. More...

Functions

bool memoryPoolsSupported (int device)
 Returns true if device supports stream-ordered memory pools, i.e. cudaMallocAsync/cudaFreeAsync. Queried once per process for all devices and cached; out-of-range device ids return false.
cudaError_t mallocAsync (void **d_ptr, size_t size, cudaStream_t)
 Wrapper forced to synchronous cudaMalloc; see the mode comment above. The trailing stream argument is accepted for signature compatibility and ignored.
cudaError_t freeAsync (void *d_ptr, cudaStream_t)
 Wrapper forced to synchronous cudaFree; see the mode comment above. The trailing stream argument is accepted for signature compatibility and ignored.
int ptrToDevice (void *ptr)
 Returns the device ID associated with the specified pointer.
int currentDevice ()
 Returns the ID of the current device.
int deviceCount ()
 Returns the number of devices with compute capability greater or equal to 1.0 that are available for execution.
void printDevInfo (int device, const char *preMsg=nullptr, std::FILE *file=stderr)
 Print information about a specific device.
size_t blocksPerGrid (size_t numItems, size_t threadsPerBlock)
 Computes the number of blocks per grid given the problem size and number of threads per block.
cudaError_t memAdvise (const void *devPtr, size_t count, cudaMemoryAdvise advice, int device)
 Compatbility wrapper for cudaMemAdvise/cudaMemAdvise.
cudaError_t memPrefetchAsync (const void *devPtr, size_t count, int dstDevice, cudaStream_t stream)
 Compatbility wrapper for cudaMemPrefetchAsync/cudaMemPrefetchAsync.

Function Documentation

◆ blocksPerGrid()

size_t blocksPerGrid ( size_t numItems,
size_t threadsPerBlock )
inline

Computes the number of blocks per grid given the problem size and number of threads per block.

Parameters
numItemsProblem size
threadsPerBlockNumber of threads per block (second CUDA launch parameter)
Returns
number of blocks per grid (first CUDA launch parameter)
Note
CUDA launch parameters: kernel<<< blocksPerGrid, threadsPerBlock, sharedMemSize, streamID>>>

◆ currentDevice()

int currentDevice ( )
inline

Returns the ID of the current device.

◆ deviceCount()

int deviceCount ( )
inline

Returns the number of devices with compute capability greater or equal to 1.0 that are available for execution.

◆ freeAsync()

cudaError_t freeAsync ( void * d_ptr,
cudaStream_t  )
inline

Wrapper forced to synchronous cudaFree; see the mode comment above. The trailing stream argument is accepted for signature compatibility and ignored.

Parameters
d_ptrDevice pointer that will be freed
Returns
Cuda error code

◆ mallocAsync()

cudaError_t mallocAsync ( void ** d_ptr,
size_t size,
cudaStream_t  )
inline

Wrapper forced to synchronous cudaMalloc; see the mode comment above. The trailing stream argument is accepted for signature compatibility and ignored.

Parameters
d_ptrDevice pointer to allocated device memory
sizeNumber of bytes to allocate
Returns
Cuda error code

◆ memAdvise()

cudaError_t memAdvise ( const void * devPtr,
size_t count,
cudaMemoryAdvise advice,
int device )
inline

Compatbility wrapper for cudaMemAdvise/cudaMemAdvise.

◆ memoryPoolsSupported()

bool memoryPoolsSupported ( int device)
inline

Returns true if device supports stream-ordered memory pools, i.e. cudaMallocAsync/cudaFreeAsync. Queried once per process for all devices and cached; out-of-range device ids return false.

◆ memPrefetchAsync()

cudaError_t memPrefetchAsync ( const void * devPtr,
size_t count,
int dstDevice,
cudaStream_t stream )
inline

Compatbility wrapper for cudaMemPrefetchAsync/cudaMemPrefetchAsync.

◆ printDevInfo()

void printDevInfo ( int device,
const char * preMsg = nullptr,
std::FILE * file = stderr )
inline

Print information about a specific device.

Parameters
devicedevice ID for which information will be printed
preMsgoptional message printed before the device information
fileOptional file stream to print to, e.g. stderr or stdout

◆ ptrToDevice()

int ptrToDevice ( void * ptr)
inline

Returns the device ID associated with the specified pointer.

Note
If ptr points to host memory (only) the return ID is either cudaInvalidDeviceId = -2 or cudaCpuDeviceId = -1