cuda::experimental::stf::green_ctx_data_place#
-
class green_ctx_data_place#
Data place for green contexts.
Green contexts allow partitioning GPU resources (SMs, memory bandwidth) for fine-grained control over execution. This class provides a data_place for green context-based data locations using the extension mechanism.
Public Static Functions
-
static inline data_place create(const green_ctx_view &gc_view)#
Create a green context data place.
- Parameters:
gc_view – The green context view
- Returns:
data_place for the green context
- ::std::shared_ptr<green_ctx_view> gc_view_ptr
Create a green context data place.
- Parameters:
gc_view_ptr – Shared pointer to the green context view
- Returns:
data_place for the green context
-
class extension : public cuda::experimental::stf::data_place_extension#
Extension implementation for green context data places.
Public Functions
-
inline explicit extension(green_ctx_view view)#
Construct from a green context view.
- Parameters:
view – The green context view containing context and stream pool
- ::std::shared_ptr<green_ctx_view> view_ptr
Construct from a shared pointer to a green context view.
- Parameters:
view_ptr – Shared pointer to the green context view
-
inline virtual exec_place get_affine_exec_place() const override#
Get the affine execution place for this data place.
Returns the exec_place that should be used for computation on data stored at this place. The exec_place may have its own virtual methods (e.g., activate/deactivate) for execution-specific behavior.
-
inline virtual int get_device_ordinal() const override#
Get the device ordinal for this place.
Returns the CUDA device ID associated with this place. For host-only places, this should return -1.
-
inline virtual ::std::string to_string() const override#
Get a string representation of this place.
Used for debugging and logging purposes.
-
inline virtual size_t hash() const override#
Compute a hash value for this place.
Used for storing data_place in hash-based containers.
- inline virtual bool equals(
- const data_place_extension &other
Check equality with another extension.
- Parameters:
other – The other extension to compare with
- Returns:
true if the extensions represent the same place
-
inline const green_ctx_view &get_view() const#
Get the underlying green context view.
- inline const ::std::shared_ptr<green_ctx_view> &get_view_ptr(
Get shared pointer to the view (if constructed with one)
- inline virtual void *allocate(
- ::std::ptrdiff_t size,
- cudaStream_t stream
Allocate memory for green context (uses cudaMallocAsync on the device)
- inline virtual void deallocate(
- void *ptr,
- size_t,
- cudaStream_t stream
Deallocate memory for green context.
- inline virtual CUresult mem_create(
- CUmemGenericAllocationHandle *handle,
- size_t size
Create a physical memory allocation for this place (VMM API)
This method is used by localized arrays (composite_slice) to create physical memory segments that are then mapped into a contiguous virtual address space. Custom place types can override this method to provide specialized memory allocation behavior.
See also
allocate() for regular memory allocation
Note
Managed memory is not supported by the VMM API.
- Parameters:
handle – Output parameter for the allocation handle
size – Size of the allocation in bytes
- Returns:
CUresult indicating success or failure
-
inline virtual bool allocation_is_stream_ordered() const#
Returns true if allocation/deallocation is stream-ordered.
When this returns true, the allocation uses stream-ordered APIs like cudaMallocAsync, and allocators should use stream_async_op to synchronize prerequisites before allocation.
When this returns false, the allocation is immediate (like cudaMallocHost) and the stream parameter is ignored. Note that immediate deallocations (e.g., cudaFree) may or may not introduce implicit synchronization.
Default is true since most GPU-based extensions use cudaMallocAsync.
-
inline explicit extension(green_ctx_view view)#
-
static inline data_place create(const green_ctx_view &gc_view)#