cuda::experimental::stf::data_impl_base#

template<typename T>
class data_impl_base : public cuda::experimental::stf::data_interface#

Base implementation of data_interface using Data as constant data and PerInstanceData for each instance.

Adds the state, implements shape and instance and leaves everything else alone.

Subclassed by cuda::experimental::stf::graph_data_interface< scalar_view< T > >, cuda::experimental::stf::graph_data_interface< slice< T, 1 > >, cuda::experimental::stf::graph_data_interface< void_interface >, cuda::experimental::stf::stream_data_interface< scalar_view< T > >, cuda::experimental::stf::stream_data_interface< slice< T, 1 > >, cuda::experimental::stf::stream_data_interface_simple< hashtable >, cuda::experimental::stf::stream_data_interface_simple< void_interface >, cuda::experimental::stf::graph_data_interface< T >, cuda::experimental::stf::stream_data_interface< T >, cuda::experimental::stf::stream_data_interface_simple< T >

Public Types

using element_type = T#
using shape_t = shape_of<T>#

Public Functions

inline explicit data_impl_base(T object)#
inline explicit data_impl_base(shape_of<T> shape)#
inline T &instance(instance_id_t instance_id)#
inline const T &instance(instance_id_t instance_id) const#
inline virtual size_t data_hash(
instance_id_t instance_id,
) const final#

Get the hash of the data representation for the given instance ID.

Parameters:

instance_id – The ID of the data instance

Returns:

The hash of the data representation

inline size_t data_footprint() const final#
virtual void data_allocate(
backend_ctx_untyped &ctx,
block_allocator_untyped &custom_allocator,
const data_place &memory_node,
instance_id_t instance_id,
::std::ptrdiff_t &s,
void **extra_args,
event_list &prereqs,
) = 0#

Allocate data and return a prerequisite event list.

Parameters:
  • ctx – Backend context state

  • memory_node – The memory node where the data is stored

  • instance_id – The ID of the data instance

  • s – Pointer to the size of the allocated data

  • extra_args – Additional arguments required for allocation

  • prereqs – Prerequisite event list, will be updated as a side effect

virtual void data_deallocate(
backend_ctx_untyped &ctx,
block_allocator_untyped &custom_allocator,
const data_place &memory_node,
instance_id_t instance_id,
void *extra_args,
event_list &prereqs,
) = 0#

Deallocate data and return a prerequisite event list.

Parameters:
  • ctx – Backend context state

  • memory_node – The memory node where the data is stored

  • instance_id – The ID of the data instance

  • extra_args – Additional arguments required for deallocation

  • prereqs – Prerequisite event list, will be updated as a side effect

virtual void data_copy(
backend_ctx_untyped &ctx,
const data_place &dst_memory_node,
instance_id_t dst_instance_id,
const data_place &src_memory_node,
instance_id_t src_instance_id,
event_list &prereqs,
) = 0#

Copy data from one memory node to another, returning a prerequisite event list.

Parameters:
  • ctx – Backend context state

  • dst_memory_node – The destination memory node

  • dst_instance_id – The destination instance ID

  • src_memory_node – The source memory node

  • src_instance_id – The source instance ID

  • arg – Additional arguments required for copying data

  • prereqs – Prerequisite event list, will be updated as a side effect

inline virtual bool pin_host_memory(instance_id_t)#

Pin host memory.

Parameters:

instance_id – The ID of the data instance

Returns:

true if the instance was pinned, false otherwise

inline ::std::optional<cudaMemoryType> get_memory_type(
instance_id_t,
)#
inline virtual void unpin_host_memory(instance_id_t)#

Unpin host memory.

Parameters:

instance_id – The ID of the data instance

template<typename T>
inline const T &shape() const#

Get the part of the data interface that is common to all data instances.

Template Parameters:

T – The type of the data shape

Returns:

A const reference to the data shape

template<typename T>
inline const T &instance_const(
instance_id_t instance_id,
) const#

Get a const reference to the data instance of the given ID.

Template Parameters:

T – The type of the data instance

Parameters:

instance_id – The ID of the data instance

Returns:

A const reference to the data instance

template<typename backend_ctx_untyped>
inline instance_id_t get_default_instance_id(
backend_ctx_untyped&,
const logical_data_untyped &d,
task &tp,
) const#

Returns the index (ID) of the data instance for this logical data in the current task context.

If this is called outside a task, this will result in an error.

Parameters:
  • ctx – The backend context state

  • d – The logical data_untyped

Returns:

The ID of the data instance for this logical data

inline virtual bool is_void_interface() const#

Indicates whether this is a void data interface, which permits to skip some operations to allocate or move data for example.