stl-containers#

group Containers

Typedefs

template<typename Storage>
using value_type_of_t = unspecified#

An alias for the value type of a legate::experimental::stl::logical_store_like type. A store’s value type is its element type stripped of any const qualification.

Template Parameters:

Storage – A type that satisfies the legate::experimental::stl::logical_store_like concept.

template<typename Storage>
using element_type_of_t = unspecified#

An alias for the element type of a legate::experimental::stl::logical_store_like type. A store’s element type is const qualified if the store is read-only.

Template Parameters:

Storage – A type that satisfies the legate::experimental::stl::logical_store_like concept.

Functions

template<typename ElementType, std::int32_t Dim>
logical_store<ElementType, Dim> as_typed(
const legate::LogicalStore &store
)#

Given an untyped legate::LogicalStore, return a strongly-typed legate::experimental::stl::logical_store.

Template Parameters:
Parameters:

store – The LogicalStore to convert.

Returns:

logical_store<ElementType, Dim>

Pre:

The element type of the LogicalStore must be the same as ElementType, and the dimensionality of the LogicalStore must be the same as Dim.

template<typename ElementType, std::int32_t Dim>
inline mdspan_t<ElementType, Dim> as_mdspan(
const legate::PhysicalStore &store
)#

Given an untyped legate::PhysicalStore, return a strongly-typed legate::experimental::stl::logical_store.

Template Parameters:
Parameters:

store – The PhysicalStore to convert.

Returns:

mdspan_t<ElementType, Dim>

Pre:

The element type of the PhysicalStore must be the same as ElementType, and the dimensionality of the PhysicalStore must be the same as Dim.

template<typename ElementType>
logical_store<ElementType, 0> create_store(
::cuda::std::span<const std::size_t, 0UL>,
ElementType value
)

Create and initialize a zero-dimensional (scalar) logical store of a given type.

auto scalar1 = stl::create_store({}, 0);      // scalar store of type int
// or
auto scalar2 = stl::create_store<int>({}, 0); // same thing

Template Parameters:

ElementType – The element type of the resulting logical_store.

Returns:

legate::experimental::stl::logical_store<ElementType, 0>

template<typename ElementType, std::size_t Dim>
logical_store<ElementType, Dim> create_store(
const std::size_t (&exts)[Dim]
)#

Create an uninitialized logical store of a given type and dimensionality.

auto store = stl::create_store<int>({40,50,60}); // A 3-dimensional store of type int

Template Parameters:
Returns:

legate::experimental::stl::logical_store<ElementType, Dim>

template<typename ElementType, std::size_t Dim>
logical_store<ElementType, Dim> create_store(
const ::cuda::std::array<std::size_t, Dim> &exts
)#

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

stl::legate_store<int, 3> input{...};
auto aligned = stl::create_store<int>(source.extents());
template<typename ElementType, std::int32_t Dim>
logical_store<ElementType, Dim> create_store(
const std::size_t (&exts)[Dim],
ElementType value
)#

Create and initialize a logical store of a given type and dimensionality.

auto store = stl::create_store<int>({40,50,60}, 0); // A 3-dimensional store of type int

Template Parameters:
Returns:

legate::experimental::stl::logical_store<ElementType, Dim>

template<typename ElementType, std::size_t Dim>
logical_store<ElementType, Dim> create_store(
const ::cuda::std::array<std::size_t, Dim> &exts,
ElementType value
)#

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

stl::legate_store<int, 3> input{...};
auto aligned = stl::create_store<int>(source.extents(), 0);
template<typename ElementType>
logical_store<ElementType, 0> scalar(
ElementType value
)#

Create an uninitialized zero-dimensional (scalar) logical store of a given type.

auto scalar = stl::scalar(0); // scalar store of type int

Template Parameters:

ElementType – The element type of the resulting logical_store.

Returns:

legate::experimental::stl::logical_store<ElementType, 0>

Variables

template<typename Storage>
std::int32_t dim_of_v#

A constexpr variable constant for the dimensionality of a legate::experimental::stl::logical_store_like type.

Template Parameters:

Storage – A type that satisfies the legate::experimental::stl::logical_store_like concept.

template<typename ElementType>
logical_store<ElementType, 0> create_store(
::cuda::std::span<const std::size_t, 0UL>
)#

Create an uninitialized zero-dimensional (scalar) logical store of a given type.

auto scalar = stl::create_store<int>({}); // scalar store of type int

Template Parameters:

ElementType – The element type of the resulting logical_store.

Return:

legate::experimental::stl::logical_store<ElementType, 0>

template<typename ElementType, std::int32_t Dim>
class logical_store
#include <legate/experimental/stl/detail/store.hpp>

A multi-dimensional data container.

logical_store is a multi-dimensional data container for fixed-size elements. Stores are internally partitioned and distributed across the system, but users need not specify the partitioning and distribution directly. Instead, Legate.STL automatically partitions and distributes stores based on how the logical_store object is used.

logical_store objects are value-like and are move-only. They are not immediately associated with a physical allocation. To access the data directly, users must ask for a view into the logical store. This will trigger the allocation of a physical store and the population of the physical memory, which is a blocking operation.

Template Parameters:
  • ElementType – The type of the elements of the store. The element type must be fixed size, and it must be one of the allowable Legate element types.

  • Dim – The number of dimensions in the logical store

Public Functions

template<std::size_t Rank>
inline explicit logical_store(
const std::size_t (&extents)[Rank]
)

Create a logical store of a given shape.

logical_store<int, 3> data{{ 10, 20, 30 }};

Template Parameters:

Rank – The number of dimensions in the store.

Parameters:

extents – The extents of the store.

inline explicit logical_store(
::cuda::std::span<const std::size_t, Dim> extents
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t Rank>
inline explicit logical_store(
const std::size_t (&extents)[Rank],
ElementType value
)

Create a logical store of a given shape and fills it with a given value.

logical_store<int, 3> data{{ 10, 20, 30 }, 42};

Template Parameters:

Rank – The number of dimensions in the store.

Parameters:
  • extents – The extents of the store.

  • value – The value to fill the store with.

inline explicit logical_store(
::cuda::std::span<const std::size_t, Dim> extents,
ElementType value
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

inline logical_store(std::in_place_t, init_list_t il)

Create a logical store from a std::initializer_list.

For stores with two or more dimensions, logical_store objects can be initialized from an initializer_list as follows:

logical_store<int, 2> data = { {1, 2, 3}, {4, 5, 6} };

For 1-dimensional stores, however, this syntax can get confused with the constructor that takes the shape of the store as a list of integers. So for 1-D stores, the first argument must be std::in_place as shown below:

logical_store<int, 1> data{std::in_place, {1, 2, 3, 4, 5, 6}};

Example:
stl::logical_store<int, 2> store = {{1, 2, 3}, {4, 5, 6}};
// store contains:
// [[1 2 3]
//  [4 5 6]]

Parameters:

il – The initializer list to create the store from. The type of il is a nested std::initializer_list of the store’s element type.

Pre:

  • The initializer list must have the same dimensionality (as determined by list nesting depth) as the store.

logical_store(init_list_t il)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note

This constructor is only available when the dimensionality of the store is greater than 1.

logical_store(logical_store&&) = default

logical_store is a move-only type.

inline ::cuda::std::array<std::size_t, Dim> extents(
) const noexcept

Retrieve the extents of the store as a std::array

Returns:

std::array<std::size_t, Dim> - The extents of the store.

Public Static Functions

static inline std::int32_t dim() noexcept

Get the dimensionality of the store.

Returns:

std::int32_t - The number of dimensions in the store.