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

Allocates the device-resident storage behind a GridHandle or NodeManagerHandle through a single-space buffer's memory resource, and transfers handles between address spaces. 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  IsStreamArgument< BufferT >
 True when BufferT is a stream rather than a buffer: cudaStream_t, or another non-buffer type that converts to it. nullptr is not a stream here. 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

Macros

#define NANOVDB_CUDA_HANDLESTORAGE_DEFERS_GRIDHANDLE_CUH

Typedefs

template<typename BufferT, typename T>
using PrototypeFormResult = typename std::enable_if<!IsStreamArgument<BufferT>::value, T>::type
 Return type of a tool's prototype-buffer form: T, except when BufferT deduced as a stream (cudaStream_t, or any other type that converts to it and is not a buffer, such as a stream wrapper), i.e. the call passed a stream where the prototype goes, which is the resource form's signature. A literal 0 or nullptr keeps the prototype form, whose static_assert asks for cudaStream_t(0). Removing the prototype form there leaves the resource form as the only candidate rather than relying on partial ordering, which compilers resolve differently for these overloads.

Functions

template<typename BufferT>
BufferT createDeviceStorage (uint64_t bytes, const BufferT *proto, cudaStream_t stream)
 Allocates bytes of device-resident storage of the single-space buffer type BufferT on the current device through proto's resource – on stream when the resource is stream-ordered.
template<typename BufferT>
void * deviceStorageData (BufferT &buffer)
 The device address of a storage buffer made by createDeviceStorage: its one allocation is the device allocation.
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 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 through a single-space buffer's memory resource, and transfers handles between address spaces.

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.

Macro Definition Documentation

◆ NANOVDB_CUDA_HANDLESTORAGE_DEFERS_GRIDHANDLE_CUH

#define NANOVDB_CUDA_HANDLESTORAGE_DEFERS_GRIDHANDLE_CUH