OpenVDB 13.1.0
Loading...
Searching...
No Matches
is_async_resource< R, class > Struct Template Reference

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

#include <nanovdb/cuda/DeviceResource.h>

Detailed Description

template<class R, class = void>
struct nanovdb::cuda::is_async_resource< R, class >

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

Use it to dispatch between a stream-ordered resource and a synchronous one (which exposes allocate/deallocate without a stream argument):

template<typename R>
void* allocate(R& resource, size_t bytes, size_t alignment, cudaStream_t stream)
{
return resource.allocate_async(bytes, alignment, stream); // stream-ordered
else
return resource.allocate(bytes, alignment); // synchronous
}
Detection trait: is_async_resource<R>::value is true iff R models the stream-ordered AsyncResource co...
Definition DeviceResource.h:118
Note
AsyncResource refines the synchronous Resource concept, matching CCCL's cuda::mr: an async resource must also provide the synchronous allocate / deallocate, so is_async_resource<R> implies is_resource<R>. A synchronous-only resource (e.g. PinnedResource) models just is_resource. The synchronous methods of a stream-ordered resource are typically thin delegates (allocate_async on the null stream followed by a stream synchronize).