cuda::experimental::places::data_place_cute_composite#

class data_place_cute_composite : public cuda::experimental::places::data_place_interface#

Composite data place whose partitioner is a cute_partition object.

Like data_place_composite but ownership is defined by the partition object value (a bare partition_fn_t cannot carry its leaves), so a canonical descriptor is stored on the place. Because a padded partition is intrinsically specific to one tensor, such a place is per-tensor by nature. This place supports both shaped raw allocations (allocate_nd(data_dims, elemsize)) and STF logical data.

Public Types

enum ord#

Special device ordinal values for non-device places.

Returned by get_device_ordinal() for places that don’t correspond to a specific CUDA device.

Values:

enumerator invalid = ::std::numeric_limits<int>::min()#
enumerator composite = -5#
enumerator device_auto = -4#
enumerator affine = -3#
enumerator managed = -2#
enumerator host = -1#

Public Functions

inline data_place_cute_composite(
exec_place grid,
cute_partition_descriptor partition
)#
inline virtual bool is_resolved() const override#

Whether this place is fully resolved and ready for allocation.

Returns true for places that represent a concrete memory target: host, managed, device(N), composite, green_ctx, etc. Returns false for abstract/deferred places that need further resolution: invalid, affine, device_auto.

inline virtual bool is_composite() const override#

Whether this place is a composite place (data distributed over a grid of places by a partitioner)

inline virtual int get_device_ordinal() const override#

Get the device ordinal for this place.

Returns:

  • >= 0 for specific CUDA devices

  • data_place_ordinals::host (-1) for host

  • data_place_ordinals::managed (-2) for managed

  • data_place_ordinals::affine (-3) for affine

  • data_place_ordinals::device_auto (-4) for device_auto

  • data_place_ordinals::composite (-5) for composite

  • data_place_ordinals::invalid for invalid

inline virtual ::std::string to_string() const override#

Get a string representation of this place.

inline virtual size_t hash() const override#

Compute a hash value for this place.

inline virtual int cmp(
const data_place_interface &other
) const override#

Three-way comparison with another place.

Returns:

-1 if *this < other, 0 if *this == other, 1 if *this > other

inline void *allocate(
::cuda::std::ptrdiff_t,
cudaStream_t
) const override#
inline virtual void *allocate_nd(
dim4 data_dims,
size_t elemsize,
cudaStream_t
) const override#

Allocate memory at this place for a tensor with the given extents.

The default implementation ignores the tensor geometry and forwards to the byte-count allocate(); places whose physical placement depends on the geometry (composite places, whose partitioner maps element coordinates to places) override it with the real implementation.

Extents follow the dimension-0-fastest linearization convention of dim4::get_index() (the STF slice convention). Row-major callers should present reversed extents (and a coordinate-reversing partitioner).

Parameters:
  • data_dims – Extents of the tensor

  • elemsize – Size of one element in bytes

  • stream – CUDA stream for stream-ordered allocations

Returns:

Pointer to allocated memory

inline virtual void deallocate(
void *ptr,
size_t,
cudaStream_t
) const override#

Deallocate memory at this place.

Parameters:
  • ptr – Pointer to memory to deallocate

  • size – Size of the allocation

  • stream – CUDA stream for stream-ordered deallocations

inline virtual bool allocation_is_stream_ordered() const override#

Returns true if allocation/deallocation is stream-ordered.

inline ::std::shared_ptr<void> get_affine_exec_impl(
) const override#
inline const cute_partition_descriptor &get_partition() const#
inline const exec_place &get_grid() const#
virtual void *allocate(
::std::ptrdiff_t size,
cudaStream_t stream
) const = 0#

Allocate memory at this place.

Parameters:
  • size – Size of the allocation in bytes

  • stream – CUDA stream for stream-ordered allocations

Throws:

std::runtime_error – if allocation is not supported for this place type

Returns:

Pointer to allocated memory

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

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

Default implementation returns CUDA_ERROR_NOT_SUPPORTED. Subclasses that support VMM should override this.

Parameters:
  • handle – Output parameter for the allocation handle

  • size – Size of the allocation in bytes

Returns:

CUresult indicating success or failure

inline virtual const partition_fn_t &get_partitioner() const#

Get the partitioner function for composite places.

Throws:

std::logic_error – if not a composite place