OpenVDB 13.1.0
Loading...
Searching...
No Matches
HandleStorage.h File Reference

Allocates the device-resident storage behind a GridHandle or NodeManagerHandle for any buffer family: through the static create() interface for buffers that provide it (the dual-space DeviceBuffer family), and through the buffer's memory resource for a single-space cuda::Buffer. This is the bridge that lets every tool entry point accept either buffer family. More...

#include <nanovdb/GridHandle.h>
#include <nanovdb/HostBuffer.h>
#include <nanovdb/cuda/Buffer.h>
#include <nanovdb/util/cuda/Util.h>
#include <utility>
#include <vector>
#include <stdexcept>
#include <type_traits>

Go to the source code of this file.

Classes

struct  HandleFactory
 The one gateway for constructing a GridHandle from a buffer plus metadata that is already known to be valid – adopted from another handle, whose own construction from raw bytes did the validation. More...

Namespaces

namespace  nanovdb
 Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
namespace  nanovdb::cuda
namespace  nanovdb::cuda::detail

Functions

template<typename BufferT>
BufferT createDeviceStorage (uint64_t bytes, const BufferT *proto, int device, cudaStream_t stream)
 Allocates bytes of device-resident storage of buffer type BufferT: single-space buffers allocate through pool's resource – on stream when the resource is stream-ordered – and every other buffer type goes through its static create(bytes, pool, device, stream) interface.
template<typename BufferT>
void * deviceStorageData (BufferT &buffer)
 The device address of a storage buffer made by createDeviceStorage: data() for a single-space buffer, whose one allocation is the device allocation, and deviceData() for the dual-space family.
template<typename BufferT>
void orderBeforeHandleConstruction (cudaStream_t stream)
 Orders the host after stream where a handle is about to be constructed from bytes still being written on it: a single-space buffer over a synchronous resource retains no stream, so the constructor's metadata parse (which runs on the default stream) is not otherwise ordered after the producer. A no-op for dual-space buffers (their constructor path predates this bridge) and for stream-ordered resources (the buffer retains the stream).
template<typename DstBufferT>
DstBufferT makeTransferStorage (uint64_t bytes, cudaStream_t stream, const DstBufferT *proto)
 Allocates bytes of destination storage for a cross-space transfer: single-space buffers allocate through proto's resource (or a default-constructed resource without one), on stream when the resource is stream-ordered; buffers providing create() go through it.
template<typename DstBufferT, typename SrcBufferT>
GridHandle< DstBufferT > copyTo (const GridHandle< SrcBufferT > &src, cudaStream_t stream, const DstBufferT *proto=nullptr)
 Deep-copies a grid handle into a different address space: the explicit, stream-carrying transfer between single-space device handles and host-readable handles (HostBuffer or a host-accessible single-space buffer such as a pinned-resource cuda::Buffer).
template<typename DstBufferT, typename SrcBufferT>
GridHandle< DstBufferT > copyTo (const GridHandle< SrcBufferT > &src, const DstBufferT *proto=nullptr)
 Convenience overload issuing the copy on the source buffer's retained stream when it has one (any single-space source over a stream-ordered resource), the default stream otherwise.

Detailed Description

Allocates the device-resident storage behind a GridHandle or NodeManagerHandle for any buffer family: through the static create() interface for buffers that provide it (the dual-space DeviceBuffer family), and through the buffer's memory resource for a single-space cuda::Buffer. This is the bridge that lets every tool entry point accept either buffer family.

Note
This header is host-includable: it calls the CUDA runtime but launches no kernels, so a plain C++ translation unit (linked against the CUDA runtime) can allocate storage and transfer grid handles with cuda::copyTo.