Memory regions appearing in both on the host-side and device-side address spaces with the regions in both spaces mapped to each other (i.e.
More...
|
struct | region_pair_t |
| A pair of memory regions, one in system (=host) memory and one on a CUDA device's memory - mapped to each other. More...
|
|
struct | span_pair_t |
| A pair of memory spans, one in device-global memory and one in host/system memory, mapped to it. More...
|
|
Memory regions appearing in both on the host-side and device-side address spaces with the regions in both spaces mapped to each other (i.e.
guaranteed to have the same contents on access up to synchronization details). Consult the CUDA C programming guide section on mapped memory for more details.
◆ allocate() [1/2]
Allocate a memory region on the host, which is also mapped to a memory region in a context of some CUDA device - so that changes to one will be reflected in the other.
- Parameters
-
context | The device context in which the device-side region in the pair will be allocated. |
size_in_bytes | amount of memory to allocate (in each of the regions) |
options | see memory::allocation_options |
◆ allocate() [2/2]
Allocate a memory region on the host, which is also mapped to a memory region in the global memory of a CUDA device - so that changes to one will be reflected in the other.
- Parameters
-
device | The device on which the device-side region in the pair will be allocated |
size_in_bytes | amount of memory to allocate (in each of the regions) |
options | see memory::allocation_options |
◆ device_side_pointer_for()
template<typename T >
T* cuda::memory::mapped::device_side_pointer_for |
( |
T * |
host_memory_ptr | ) |
|
|
inline |
Obtain a pointer in the device-side memory space (= address range) given given a host-side pointer mapped to it.
- Parameters
-
[in] | host_memory_ptr | a pointer to host-side memory which has been allocated as one side of a CUDA mapped memory region pair |
◆ device_side_region_for() [1/2]
region_t cuda::memory::mapped::device_side_region_for |
( |
region_t |
region | ) |
|
|
inline |
Get the memory region mapped to a given host-side region.
- Note
- if the input is already a device-side region, this function is idempotent
◆ device_side_region_for() [2/2]
const_region_t cuda::memory::mapped::device_side_region_for |
( |
const_region_t |
region | ) |
|
|
inline |
Get the memory region mapped to a given host-side region.
- Note
- if the input is already a device-side region, this function is idempotent
◆ free()
Free a pair of mapped memory regions.
- Parameters
-
pair | a pair of mapped host- and device-side regions |
◆ free_region_pair_of()
void cuda::memory::mapped::free_region_pair_of |
( |
void * |
ptr | ) |
|
|
inline |
Free a pair of mapped memory regions using just one of them.
- Parameters
-
ptr | a pointer to one of the mapped regions (can be either the device-side or the host-side) |
◆ is_part_of_a_region_pair()
bool cuda::memory::mapped::is_part_of_a_region_pair |
( |
const void * |
ptr | ) |
|
|
inline |
Determine whether a given stretch of memory was allocated as part of a mapped pair of host and device memory regions.
- Todo:
- What if it's a managed pointer?
- Parameters
-
ptr | the beginning of a memory region - in either host or device memory - to check |
- Returns
true
iff the region was allocated as one side of a mapped memory region pair