11 #ifndef CUDA_API_WRAPPERS_UNIQUE_REGION_HPP_ 12 #define CUDA_API_WRAPPERS_UNIQUE_REGION_HPP_ 40 template<
typename Deleter>
44 using region_t::pointer;
45 using region_t::const_pointer;
46 using region_t::size_type;
47 using deleter_type = Deleter;
76 if (data() !=
nullptr) {
88 reset(other.release());
112 deleter_type
get_deleter() const noexcept {
return deleter_type{}; }
115 explicit operator bool() const noexcept {
return data() !=
nullptr; }
137 ::std::swap<region_t>(*
this, region);
138 if (region.start() !=
nullptr) {
146 ::std::swap<region_t>(*
this, other);
159 CAW_SET_SCOPE_CONTEXT(context_handle);
160 return unique_region{ allocate_in_current_context(num_bytes) };
234 CAW_SET_SCOPE_CONTEXT(context_handle);
235 return unique_region { allocate_in_current_context(num_bytes, initial_visibility) };
277 #endif // CUDA_API_WRAPPERS_UNIQUE_REGION_HPP_ Wrapper class for a CUDA context.
Definition: context.hpp:244
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
detail_::region_helper< memory::region_t > region_t
A child class of the generic region_t with some managed-memory-specific functionality.
Definition: memory.hpp:1960
deleter_type get_deleter() const noexcept
Return a deleter of the fixed type (it can't be a reference - we don't keep a deleter object) ...
Definition: unique_region.hpp:112
CUcontext handle_t
Raw CUDA driver handle for a context; see {context_t}.
Definition: types.hpp:878
unique_region make_unique_region(const context_t &context, cuda::size_t num_elements)
Allocate a region in device-global memory.
Definition: unique_region.hpp:21
A class for holding a region_t of memory owned "uniquely" by its creator - similar to how ::std::uniq...
Definition: unique_region.hpp:41
constexpr unique_region(::std::nullptr_t) noexcept
Act like the default constructor for nullptr_t's.
Definition: unique_region.hpp:56
unique_region(region_t region) noexcept
Take ownership of an existing region.
Definition: unique_region.hpp:59
device::unique_region make_unique_region(const context_t &context, size_t num_elements)
See device::make_unique_region(const context_t& context, size_t num_elements)
Definition: unique_region.hpp:197
detail_::region_helper< memory::const_region_t > const_region_t
A child class of the generic const_region_t with some managed-memory-specific functionality.
Definition: memory.hpp:1962
region_t release() noexcept
Release ownership of any stored pointer.
Definition: unique_region.hpp:120
void swap(unique_region &other) noexcept
Exchange the pointer and deleter with another object.
Definition: unique_region.hpp:144
void reset(region_t region=region_t{})
Replace the memory region held by this object.
Definition: unique_region.hpp:135
constexpr unique_region() noexcept=default
Default constructor, creates an empty unique_region which owns nothing.
unique_region & operator=(::std::nullptr_t) noexcept
Reset the unique_region to empty, invoking the deleter if necessary.
Definition: unique_region.hpp:94
unique_region & operator=(const unique_region &)=delete
No copy-assignment - that would break our ownership guarantee.
unique_region(unique_region &&other) noexcept
Move constructor.
Definition: unique_region.hpp:66
unique_region & operator=(unique_region &&other) noexcept
A Move-assignment operator, which takes ownership of the other region.
Definition: unique_region.hpp:86
Wrapper class for a CUDA device.
Definition: device.hpp:135
initial_visibility_t
The choices of which categories CUDA devices must a managed memory region be visible to...
Definition: types.hpp:753
freestanding wrapper functions for working with CUDA's various kinds of memory spaces, arranged into a relevant namespace hierarchy.