OpenVDB 13.1.0
Loading...
Searching...
No Matches
AsyncFromSync< R > Struct Template Reference

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...

#include <nanovdb/cuda/DeviceResource.h>

Public Member Functions

void * allocate_async (size_t bytes, size_t alignment, cudaStream_t)
 Allocates through the synchronous resource; the result is valid on every stream, hence trivially valid on stream.
void deallocate_async (void *p, size_t bytes, size_t alignment, cudaStream_t stream)
 Synchronizes stream, then frees through the synchronous resource – the synchronize makes the quiescence contract hold. Null is a no-op and skips the synchronize.
void * allocate (size_t bytes, size_t alignment)
 Synchronous pair, forwarding to the wrapped resource.
void deallocate (void *p, size_t bytes, size_t alignment)

Public Attributes

resource

Static Public Attributes

static constexpr size_t DEFAULT_ALIGNMENT = R::DEFAULT_ALIGNMENT
static constexpr bool HOST_ACCESSIBLE = is_host_accessible_resource<R>::value
 The adapter is host-accessible iff the adapted resource is.
static constexpr bool DEVICE_ACCESSIBLE = is_device_accessible_resource<R>::value

Detailed Description

template<class R>
struct nanovdb::cuda::AsyncFromSync< R >

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).

Template Parameters
Rthe wrapped synchronous resource, held by value; wrap a ResourceRef<R> to borrow a stateful instance instead.

The mirror of SyncFromAsync, and the analog of cuda::mr's synchronous_resource_adapter. allocate_async forwards to R::allocate, whose memory is immediately valid on every stream – a stronger guarantee than stream-ordering requires. deallocate_async synchronizes stream before R::deallocate, establishing the quiescence the synchronous contract demands.

Warning
Every deallocation synchronizes its stream, so expect serialization relative to a genuinely stream-ordered resource. That is the unavoidable cost of a synchronous backend under a stream-ordered algorithm; this wrapper exists so the cost is explicit and chosen by the caller – e.g. on a device without memory-pool support – rather than silently substituted.

Member Function Documentation

◆ allocate()

template<class R>
void * allocate ( size_t bytes,
size_t alignment )
inline

Synchronous pair, forwarding to the wrapped resource.

◆ allocate_async()

template<class R>
void * allocate_async ( size_t bytes,
size_t alignment,
cudaStream_t  )
inline

Allocates through the synchronous resource; the result is valid on every stream, hence trivially valid on stream.

◆ deallocate()

template<class R>
void deallocate ( void * p,
size_t bytes,
size_t alignment )
inline

◆ deallocate_async()

template<class R>
void deallocate_async ( void * p,
size_t bytes,
size_t alignment,
cudaStream_t stream )
inline

Synchronizes stream, then frees through the synchronous resource – the synchronize makes the quiescence contract hold. Null is a no-op and skips the synchronize.

Member Data Documentation

◆ DEFAULT_ALIGNMENT

template<class R>
size_t DEFAULT_ALIGNMENT = R::DEFAULT_ALIGNMENT
staticconstexpr

◆ DEVICE_ACCESSIBLE

template<class R>
bool DEVICE_ACCESSIBLE = is_device_accessible_resource<R>::value
staticconstexpr

◆ HOST_ACCESSIBLE

template<class R>
bool HOST_ACCESSIBLE = is_host_accessible_resource<R>::value
staticconstexpr

The adapter is host-accessible iff the adapted resource is.

◆ resource

template<class R>
R resource