cuda::experimental::places::data_place_invalid#
-
class data_place_invalid : public cuda::experimental::places::data_place_interface#
Implementation for the invalid data place.
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 = ::cuda::std::numeric_limits<int>::min()#
-
enumerator composite = -5#
-
enumerator device_auto = -4#
-
enumerator affine = -3#
-
enumerator managed = -2#
-
enumerator host = -1#
-
enumerator invalid = ::cuda::std::numeric_limits<int>::min()#
Public Functions
-
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 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
Three-way comparison with another place.
- Returns:
-1 if *this < other, 0 if *this == other, 1 if *this > other
- inline virtual void *allocate(
- ::std::ptrdiff_t,
- cudaStream_t
Allocate memory at this place.
This is a standalone entry point: callers are not required to activate this place or make any particular device current beforehand, so implementations must not assume the calling thread’s current device (or context) matches this place. An implementation that needs to switch must restore the caller’s current device before returning.
- 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 void deallocate(
- void*,
- size_t,
- cudaStream_t
Deallocate memory at this place.
Same standalone contract as allocate(): the caller’s current device is unspecified on entry and must be left unchanged on return.
- 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 virtual void *allocate_nd(
- dim4 data_dims,
- size_t elemsize,
- cudaStream_t stream
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).
The standalone contract of allocate() applies here as well: the caller’s current device is unspecified on entry and must be left unchanged on return.
- 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 CUresult mem_create(
- CUmemGenericAllocationHandle *handle,
- size_t size
Create a physical memory allocation for this place (VMM API)
Default implementation returns CUDA_ERROR_NOT_SUPPORTED. Subclasses that support VMM should override this.
Same standalone contract as allocate(): the caller’s current device is unspecified on entry and must be left unchanged on return. Placement must come from the explicit allocation properties (CUmemAllocationProp), not from the current device.
- 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 bool is_composite() const#
Whether this place is a composite place (data distributed over a grid of places by a partitioner)
-
inline virtual bool is_replicated() const noexcept#
Whether this is a replicated data place (one copy per grid member)
-
inline virtual size_t instance_count() const#
Number of data instances a dependency at this place resolves to: 1 for ordinary and composite places, one per grid member for a replicated place (see data_place::member for the r-th instance’s place)
-
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
-
enum ord#