cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
unique_region.hpp File Reference

A smart pointer for CUDA device- and host-side memory, similar to the standard library's ::std::unique_ptr. More...

#include "memory.hpp"
#include <cassert>
Include dependency graph for unique_region.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::memory::unique_region< Deleter >
 A class for holding a region_t of memory owned "uniquely" by its creator - similar to how ::std::unique_ptr holds a uniquely- owned pointer. More...
 

Namespaces

 cuda
 Definitions and functionality wrapping CUDA APIs.
 
 cuda::memory
 Representation, allocation and manipulation of CUDA-related memory, of different.
 
 cuda::memory::device
 CUDA-Device-global memory on a single device (not accessible from the host)
 
 cuda::memory::host
 Host-side (= system) memory which is "pinned", i.e.
 
 cuda::memory::managed
 Paged memory accessible in both device-side and host-side code by triggering transfers of pages between physical system memory and physical device memory.
 

Typedefs

using cuda::memory::device::unique_region = memory::unique_region< detail_::deleter >
 A unique region of device-global memory.
 
using cuda::memory::host::unique_region = memory::unique_region< detail_::deleter >
 A unique region of pinned host memory.
 
using cuda::memory::managed::unique_region = memory::unique_region< detail_::deleter >
 A unique region of managed memory, see cuda::memory::managed.
 

Functions

unique_region cuda::memory::device::make_unique_region (const context_t &context, size_t num_bytes)
 Allocate a region in device-global memory. More...
 
unique_region cuda::memory::device::make_unique_region (const device_t &device, size_t num_elements)
 Create a variant of ::std::unique_pointer for an array in device-global memory. More...
 
unique_region cuda::memory::device::make_unique_region (size_t num_elements)
 Create a variant of ::std::unique_pointer for an array in device-global memory on the current device. More...
 
device::unique_region cuda::memory::make_unique_region (const context_t &context, size_t num_elements)
 See device::make_unique_region(const context_t& context, size_t num_elements)
 
device::unique_region cuda::memory::make_unique_region (const device_t &device, size_t num_elements)
 See device::make_unique_region(const device_t& device, size_t num_elements)
 
unique_region cuda::memory::host::make_unique_region (size_t num_bytes)
 Allocate a physical-address-pinned region of system memory. More...
 
unique_region cuda::memory::managed::make_unique_region (const context_t &context, size_t num_bytes, initial_visibility_t initial_visibility)
 Allocate a region of managed memory, accessible both from CUDA devices and from the CPU. More...
 
unique_region cuda::memory::managed::make_unique_region (const device_t &device, size_t num_bytes, initial_visibility_t initial_visibility)
 Allocate a region of managed memory, accessible both from CUDA devices and from the CPU. More...
 
unique_region cuda::memory::managed::make_unique_region (size_t num_bytes)
 Allocate a region of managed memory, accessible both from CUDA devices and from the CPU. More...
 

Detailed Description

A smart pointer for CUDA device- and host-side memory, similar to the standard library's ::std::unique_ptr.

Note
Unique pointers, like any (wrapped) memory allocations, do not extend the lifetime of contexts (primary or otherwise). In particular, they do not increase primary context refcounts.