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

Namespaces

namespace  detail

Classes

struct  AsyncFromSync
 Wrapper presenting a synchronous resource as a stream-ordered one, so it can drive components that require the AsyncResource concept (TempPool and the GPU builders). More...
class  Buffer
 Owning, typed container of T elements allocated from a memory resource R held by value. More...
class  BufferView
 Non-owning, trivially copyable view of a contiguous range of T elements, with span semantics. More...
class  DeviceMesh
 This class wraps a vector of per-device IDs and CUDA streams and holds inter-device connectivity information and NCCL comms. More...
struct  DeviceNode
 POD struct representing a device id and a stream on that device. More...
class  DeviceResource
 Default stream-ordered device memory resource. Allocations are made with cudaMallocAsync and freed with cudaFreeAsync via the util::cuda wrappers. More...
class  DeviceStreamMap
 map from a device ID to an associated cuda stream. Useful for multi-GPU applications. More...
class  DualDeviceBuffer
 Simple memory buffer using un-managed pinned host memory when compiled with NVCC. Obviously this class is making explicit used of CUDA so replace it with your own memory allocator if you are not using CUDA. More...
class  DualUnifiedBuffer
 buffer, used for instance by the GridHandle, to allocate unified memory that can be resized and shared between multiple devices and the host. More...
struct  is_async_resource
 Detection trait: is_async_resource<R>::value is true iff R models the stream-ordered AsyncResource concept, i.e. exposes allocate_async(size_t, size_t, cudaStream_t) and deallocate_async(void*, size_t, size_t, cudaStream_t). More...
struct  is_async_resource< R, std::void_t< decltype(std::declval< R & >().allocate_async(size_t{0}, size_t{0}, cudaStream_t{0})), decltype(std::declval< R & >().deallocate_async(std::declval< void * >(), size_t{0}, size_t{0}, cudaStream_t{0})), decltype(std::declval< R & >().allocate(size_t{0}, size_t{0})), decltype(std::declval< R & >().deallocate(std::declval< void * >(), size_t{0}, size_t{0}))> >
struct  is_device_accessible_resource
 Companion detection: is_device_accessible_resource<R>::value is true iff R declares static constexpr bool DEVICE_ACCESSIBLE = / true, i.e. its allocations are also valid device addresses even though they are host-accessible (e.g. ManagedResource). A handle over such a resource exposes both accessor families. Purely device-resident resources do not need the marker: not being host-accessible already implies device residency. More...
struct  is_device_accessible_resource< R, typename std::enable_if< bool(R::DEVICE_ACCESSIBLE)>::type >
struct  is_host_accessible_resource
 Detection trait: is_host_accessible_resource<R>::value is true iff R declares static constexpr bool HOST_ACCESSIBLE = true, i.e. its allocations are mapped into the host address space (e.g. PinnedResource). Defaults to false: allocations are device-resident. More...
struct  is_host_accessible_resource< R, typename std::enable_if< bool(R::HOST_ACCESSIBLE)>::type >
struct  is_resource
 Detection trait: is_resource<R>::value is true iff R models the synchronous Resource concept, i.e. exposes allocate(size_t, size_t) and deallocate(void*, size_t, size_t). More...
struct  is_resource< R, std::void_t< decltype(std::declval< R & >().allocate(size_t{0}, size_t{0})), decltype(std::declval< R & >().deallocate(std::declval< void * >(), size_t{0}, size_t{0}))> >
class  MallocResource
 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...
class  ManagedResource
 Managed (unified) memory resource. Allocations (cudaMallocManaged) are accessible from both the host and the device, with the driver migrating pages on demand, so a container over this resource serves grids that are read on both sides – the replacement for the legacy UnifiedBuffer. A GridHandle over this resource parses (and validates) its metadata through the device like any device buffer – a host-side parse could race still-running producer kernels – while the host accessors remain available afterwards; ordering host reads after device writes is the caller's responsibility, exactly as with UnifiedBuffer. More...
struct  NoInit
 Tag type selecting the Buffer constructors that skip element initialization, leaving the contents indeterminate. More...
class  PinnedResource
 Default host-pinned memory resource. Allocations are page-locked host memory (cudaMallocHost) that is both host-accessible and device-accessible, so it can serve as the host side of an asynchronous host<->device copy. More...
struct  ResourceRef
 Non-owning reference to a memory resource that is itself a resource: copying the ref shares the underlying resource rather than copying it. More...
struct  SyncFromAsync
 CRTP base supplying the synchronous half of the resource concept in terms of the stream-ordered half, so a custom stream-ordered resource only has to write allocate_async and deallocate_async. More...
class  TempPool

Typedefs

using TempDevicePool = TempPool<DeviceResource>

Functions

size_t minDevicePageSize (const DeviceMesh &mesh)
 Returns the minimum page size (in bytes) across all devices on the system.
template<class R>
R & default_resource ()
 Returns a program-lifetime, address-stable reference to a default instance of resource R.
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.

Variables

constexpr NoInit noInit {}

Typedef Documentation

◆ TempDevicePool

Function Documentation

◆ copyTo() [1/2]

template<typename DstBufferT, typename SrcBufferT>
GridHandle< DstBufferT > copyTo ( const GridHandle< SrcBufferT > & src,
const DstBufferT * proto = nullptr )
inline

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.

◆ copyTo() [2/2]

template<typename DstBufferT, typename SrcBufferT>
GridHandle< DstBufferT > copyTo ( const GridHandle< SrcBufferT > & src,
cudaStream_t stream,
const DstBufferT * proto = nullptr )
inline

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 Parameters
DstBufferTdestination buffer type (specify explicitly)
Parameters
srcthe handle to copy; must not be dual-space (use deviceUpload/deviceDownload on those)
streamstream the copy is issued on; a device destination buffer with a stream-ordered resource retains it
Warning
Passing a stream other than the source buffer's retained stream makes the caller responsible for ordering: prior work on the source (and the source's later destruction, which frees on its own stream) must be ordered against stream by the caller, e.g. with cudaStreamWaitEvent or a synchronization. The stream-less overload below has no such requirement for a source with a retained stream. A source WITHOUT one (a synchronous resource, e.g. a pinned-resource buffer) is the caller's to keep alive under either overload: its destruction frees host memory immediately, unordered against the still-asynchronous copy, so synchronize stream before destroying such a source. (A pageable HostBuffer source is exempt: its copy degrades to synchronous behavior.)
Parameters
protooptional buffer whose resource (or pool, for buffers providing create()) allocates the destination storage; without it the destination resource is default-constructed
Returns
a handle of the destination buffer type with equal contents

A host-readable destination – HostBuffer, pinned, or a both-space managed buffer – synchronizes stream before returning, so its host accessors are immediately valid; a device-only destination is stream-ordered, so use its contents on stream or synchronize first. The metadata is adopted from the source handle – it was validated when that handle was constructed from raw bytes – so no kernel runs and this function is callable from host-only translation units. A pageable host source or destination (HostBuffer) degrades the copy to synchronous behavior; pinned single-space handles keep it asynchronous.

◆ default_resource()

template<class R>
R & default_resource ( )
inline

Returns a program-lifetime, address-stable reference to a default instance of resource R.

The instance is a function-local static, so it outlives every caller and is safe to bind through a default function/constructor argument. R must be default-constructible.

◆ minDevicePageSize()

size_t minDevicePageSize ( const DeviceMesh & mesh)
inline

Returns the minimum page size (in bytes) across all devices on the system.

Variable Documentation

◆ noInit

NoInit noInit {}
inlineconstexpr