46 requires(std::default_initializable<extents_type> && std::default_initializable<generator_type>)
57 return generator_(this->decode(
handle.base_offset +
offset));
78 -> std::array<
index_type, extents_type::rank()>
80 std::array<
index_type, extents_type::rank()> indices{};
81 for (std::size_t axis = extents_type::rank(); axis > 0; --axis)
83 auto const extent =
static_cast<std::size_t
>(extents_.extent(axis - 1));
84 indices[axis - 1] =
static_cast<index_type>(linear % extent);
96template <
class ElementType,
class Extents,
class Generator>
98 enable_accessor_in_domain<generated_accessor<ElementType, Extents, Generator>,
host_access_domain> =
true;
100template <
class ElementType,
class Extents,
class Generator>
102 enable_accessor_in_domain<generated_accessor<ElementType, Extents, Generator>,
cuda_access_domain> =
true;
Accessor that evaluates a generator at the logical index encoded by an offset.
Definition generated_accessor.hpp:33
std::remove_cv_t< ElementType > value_type
Definition generated_accessor.hpp:35
UNI20_HOST_DEVICE constexpr auto generator() const noexcept -> generator_type const &
Return the stored generator state.
Definition generated_accessor.hpp:71
value_type const element_type
Definition generated_accessor.hpp:36
typename extents_type::index_type index_type
Definition generated_accessor.hpp:43
std::size_t offset_type
Definition generated_accessor.hpp:40
UNI20_HOST_DEVICE constexpr generated_accessor(extents_type extents, generator_type generator)
Construct an accessor from the original extents and generator state.
Definition generated_accessor.hpp:50
UNI20_HOST_DEVICE constexpr reference access(data_handle_type handle, offset_type offset) const
Generate the value at a handle-relative synthetic offset.
Definition generated_accessor.hpp:55
UNI20_HOST_DEVICE constexpr generated_accessor()=default
Extents extents_type
Definition generated_accessor.hpp:41
UNI20_HOST_DEVICE constexpr auto extents() const noexcept -> extents_type const &
Return the extents used to decode generated offsets.
Definition generated_accessor.hpp:68
UNI20_HOST_DEVICE constexpr data_handle_type offset(data_handle_type handle, offset_type offset) const noexcept
Advance a generated handle while preserving its original index space.
Definition generated_accessor.hpp:61
Generator generator_type
Definition generated_accessor.hpp:42
value_type reference
Definition generated_accessor.hpp:37
Project compiler annotations shared by host and device code.
#define UNI20_HOST_DEVICE
Definition compiler_attributes.hpp:12
cuda::ResourceLease< HandleSlot > handle
Definition cublas/execution.cpp:33
Mdspan concept and accessor extensions for Uni20.
Definition async/async.hpp:26
Execution domain in which CUDA device code may evaluate an accessor.
Definition mdspan/concepts.hpp:78
Compact mdspan handle identifying a base offset in a generated value sequence.
Definition generated_accessor.hpp:22
friend UNI20_HOST_DEVICE constexpr bool operator==(generated_data_handle const &, generated_data_handle const &)=default
std::size_t base_offset
Definition generated_accessor.hpp:23
Execution domain in which ordinary host code may evaluate an accessor.
Definition mdspan/concepts.hpp:74