cuda::experimental::places::data_place#

class data_place#

Public Functions

inline explicit data_place(
::std::shared_ptr<data_place_interface> impl
)#
inline data_place()#

Default constructor.

The object is initialized as invalid.

data_place(const data_place&) = default#
data_place(data_place&&) = default#
data_place &operator=(const data_place&) = default#
data_place &operator=(data_place&&) = default#
inline bool operator==(const data_place &rhs) const#
inline bool operator!=(const data_place &rhs) const#
inline bool operator<(const data_place &rhs) const#
inline bool operator>(const data_place &rhs) const#
inline bool operator<=(const data_place &rhs) const#
inline bool operator>=(const data_place &rhs) const#
inline bool is_composite() const#
inline bool is_replicated() const noexcept#
inline size_t instance_count() const#

Number of data instances a dependency at this place resolves to.

inline data_place member(size_t r) const#

Data place of the r-th instance (r < instance_count()); *this when the place resolves to a single instance.

inline size_t instance_of(size_t place_index) const#

Instance index the given (linear) grid place resolves to; 0 when the place resolves to a single instance.

With axis-grouped replication, places differing only along SHARED axes map to the same instance.

inline bool is_invalid() const#
inline bool is_host() const#
inline bool is_managed() const#
inline bool is_affine() const#
inline bool is_device() const#
inline bool is_device_auto() const#
inline bool is_resolved() const#
inline ::std::string to_string() const#
inline const partition_fn_t &get_partitioner() const#
inline exec_place affine_exec_place() const#
inline size_t hash() const#

Compute a hash value for this data place.

Used by std::hash specialization for unordered containers.

inline augmented_stream getDataStream(
exec_place_resources &res
) const#
inline const ::std::shared_ptr<data_place_interface> &get_impl(
) const#

Get the underlying interface pointer.

This is primarily for internal use and backward compatibility.

inline CUresult mem_create(
CUmemGenericAllocationHandle *handle,
size_t size
) const#

Create a physical memory allocation for this place (VMM API)

Standalone call: the place does not need to be activated first, and the calling thread’s current device is left unchanged.

inline void *allocate(
::std::ptrdiff_t size,
cudaStream_t stream = nullptr
) const#

Allocate memory at this data place (raw allocation)

Standalone call: the place does not need to be activated first, and the calling thread’s current device is left unchanged.

inline void *allocate_nd(
dim4 data_dims,
size_t elemsize,
cudaStream_t stream = nullptr
) const#

Allocate memory at this data place for a tensor with the given extents (geometry-aware allocation)

For most places this is equivalent to allocate(prod(data_dims) * elemsize); composite places use the geometry to back each block of the allocation on the place that owns it according to the partitioner. Extents follow the dimension-0-fastest convention of dim4::get_index().

Standalone call: the place does not need to be activated first, and the calling thread’s current device is left unchanged.

Throws:

std::invalid_argument – if the product of the extents and elemsize overflows size_t or exceeds PTRDIFF_MAX

inline void deallocate(
void *ptr,
size_t size,
cudaStream_t stream = nullptr
) const#

Deallocate memory at this data place (raw deallocation)

Standalone call: the place does not need to be activated first, and the calling thread’s current device is left unchanged.

inline bool allocation_is_stream_ordered() const#

Returns true if allocation/deallocation is stream-ordered.

Public Static Functions

static inline data_place invalid()#

Represents an invalid data_place object.

static inline data_place host()#

Represents the host CPU as the data_place (pinned host memory, or memory which should be pinned by CUDASTF).

static inline data_place managed()#

Represents a managed memory location as the data_place.

static inline data_place affine()#

This actually does not define a data_place, but means that we should use the data place affine to the execution place.

static inline data_place device_auto()#

Constant representing a placeholder that lets the library automatically select a GPU device as the data_place.

static inline data_place device(int dev_id = 0)#

Data is placed on device with index dev_id.

static inline data_place current_device()#

Select the embedded memory of the current device as data_place.

template<typename partitioner_t>
static data_place composite(
partitioner_t p,
const exec_place &g
)#
static inline data_place composite(
partition_fn_t f,
const exec_place &grid
)#
static inline data_place replicated(const exec_place &grid)#

Replicated data place: one full copy of the data in the affine memory of every member of grid.

READ-ONLY: tasks may only take read access at this place (mutate the data at another place; the next replicated read re-broadcasts). A single-place grid degenerates to that place’s affine data place (a plain place, not replicated): a live replicated place always has at least two instances.

static inline data_place replicated()#

Deferred replicated data place: replicated over the grid of whichever task the dependency is used with (materialized at task acquisition; a scalar execution place degenerates to its affine data place).

The counterpart of affine() for replication. The deferred form always replicates over every grid axis (axis grouping requires the explicit replicate_over overload).

template<size_t... axes>
static data_place replicated(
const exec_place &grid,
replicate_over_t<axes...>
)#

Axis-grouped replication: one copy per coordinate of the REPLICATED axes; the remaining (shared) axes’ fibers share their coordinate’s instance.

Fiber members must be co-located (equal affine data places) &#8212; validated at construction. Example: on a (K, 2) grid of K devices x 2 domains, replicated(grid, replicate_over<0>) places one copy per device, shared by the device’s two domains. When the replicated axes multiply out to a single instance, the result degenerates to the shared members’ (co-located) affine data place, like the single-place grid of the all-axes overload.

static inline data_place green_ctx(const green_ctx_view &gc_view)#
static inline data_place locality_domain(
const locality_domain_view &view
)#

Create a data place pinned to one locality domain of a device.

Create a data place pinned to one locality domain.

Defined in exec/locality_domain.cuh. On toolkits older than CUDA 13.4 the place gracefully degrades to plain device memory.

See the addressing-model note at the top of this file: the view is an identity token validated lazily, when memory is actually allocated.

static inline data_place locality_domain(int dev_id, int domain_id)#

Friends

inline friend size_t to_index(const data_place &p)#

Returns an index guaranteed to be >= 0 (0 for managed CPU, 1 for pinned CPU, 2 for device 0, 3 for device 1, …).

Requires that p is initialized and different from data_place::invalid().

inline friend data_place from_index(size_t n)#

Inverse of to_index: converts an index back to a data_place.

Index 0 -> managed, 1 -> host, 2 -> device(0), 3 -> device(1), …

inline friend int device_ordinal(const data_place &p)#

Returns the device ordinal (0 = first GPU, 1 = second GPU, … and by convention the CPU is -1) Requires that p is initialized.