cuda::experimental::stf::data_place_interface#

class data_place_interface#

Abstract interface for data_place implementations.

All data_place types (host, managed, device, composite, future places) implement this interface. The data_place class holds a shared_ptr to this interface and delegates all operations to it.

Subclassed by cuda::experimental::stf::data_place_affine, cuda::experimental::stf::data_place_composite, cuda::experimental::stf::data_place_device, cuda::experimental::stf::data_place_device_auto, cuda::experimental::stf::data_place_host, cuda::experimental::stf::data_place_invalid, cuda::experimental::stf::data_place_managed, cuda::experimental::stf::green_ctx_data_place_impl

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

virtual ~data_place_interface() = default#
virtual bool is_resolved() const = 0#

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.

virtual int get_device_ordinal() const = 0#

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

virtual ::std::string to_string() const = 0#

Get a string representation of this place.

virtual size_t hash() const = 0#

Compute a hash value for this place.

virtual int cmp(const data_place_interface &other) const = 0#

Three-way comparison with another place.

Returns:

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

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

virtual void deallocate(
void *ptr,
size_t size,
cudaStream_t stream
) const = 0#

Deallocate memory at this place.

Parameters:
  • ptr – Pointer to memory to deallocate

  • size – Size of the allocation

  • stream – CUDA stream for stream-ordered deallocations

virtual bool allocation_is_stream_ordered() const = 0#

Returns true if allocation/deallocation is stream-ordered.

inline virtual CUresult mem_create(
CUmemGenericAllocationHandle*,
size_t
) 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 ::std::shared_ptr<void> get_affine_exec_impl() const#

Get the implementation for the affine exec_place (for custom place types)

Custom data_place implementations (e.g. green contexts) override this to provide their own affine exec_place. Returns nullptr by default, which causes data_place::affine_exec_place() to fall through to the error path. The returned shared_ptr should be castable to shared_ptr<exec_place::impl>.

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