Utility Span#
- group Exception
Typedefs
Variables
-
constexpr std::size_t dynamic_extent = cuda::std::dynamic_extent#
A constant used to differentiate std::span of static and dynamic extent.
-
template<typename T>
struct is_host_span_supported_container : public std::false_type#
-
template<typename T, typename Alloc>
struct is_host_span_supported_container<std::vector<T, Alloc>> : public std::true_type#
-
template<typename T, typename Alloc>
struct is_host_span_supported_container<thrust::host_vector<T, Alloc>> : public std::true_type#
-
template<typename T, typename Alloc>
struct is_host_span_supported_container<std::basic_string<T, std::char_traits<T>, Alloc>> : public std::true_type#
-
template<typename T, std::size_t Extent = cudf::dynamic_extent>
struct host_span# - #include <cudf/utilities/span.hpp>
Host span, a non-owning view over a contiguous sequence of host-accessible elements.
Backed by
cuda::std::span, with additional support for constructing from cudf-supported host containers and for tracking whether the underlying memory is device accessible (e.g. pinned memory), which enables copy engine optimizations.Public Types
-
using element_type = typename span_type::element_type#
Element type.
-
using value_type = typename span_type::value_type#
Stored value type.
-
using size_type = typename span_type::size_type#
Size type.
-
using difference_type = typename span_type::difference_type#
std::ptrdiff_t
-
using const_pointer = typename span_type::const_pointer#
Pointer returned by data() const.
-
using reference = typename span_type::reference#
Reference returned by operator[].
-
using const_reference = typename span_type::const_reference#
Const reference to an element.
Public Functions
-
inline constexpr host_span(T *data, std::size_t size)#
Constructs a span from a pointer and a size.
Note
This needs to be host-device, as it’s used by a host-device function in base_2dspan
- Parameters:
data – Pointer to the first element in the span
size – The number of elements in the span
- inline constexpr host_span(
- T *data,
- std::size_t size,
- bool is_device_accessible
Constructor from pointer, size and device-accessibility flag.
Note
This needs to be host-device, as it’s used by a host-device function in base_2dspan
- Parameters:
data – Pointer to the first element in the span
size – The number of elements in the span
is_device_accessible – Whether the data is device accessible (e.g. pinned memory)
-
template<typename C>
inline constexpr host_span(C &in)# Constructor from container
- Parameters:
in – The container to construct the span from
-
template<typename C>
inline constexpr host_span(C const &in)# Constructor from const container
- Parameters:
in – The container to construct the span from
-
template<typename OtherT, std::size_t OtherExtent>
inline constexpr host_span( - host_span<OtherT, OtherExtent> const &other
- Parameters:
other – The span to copy
-
inline constexpr reference operator[](size_type idx) const#
Returns a reference to the idx-th element of the sequence.
The behavior is undefined if idx is out of range (i.e., if it is greater than or equal to size()).
- Parameters:
idx – the index of the element to access
- Returns:
A reference to the idx-th element of the sequence, i.e.,
data()[idx]
-
inline constexpr reference front() const#
Returns a reference to the first element in the span.
Calling front on an empty span results in undefined behavior.
- Returns:
Reference to the first element in the span
-
inline constexpr reference back() const#
Returns a reference to the last element in the span.
Calling back on an empty span results in undefined behavior.
- Returns:
Reference to the last element in the span
-
inline constexpr iterator begin() const noexcept#
Returns an iterator to the first element of the span.
If the span is empty, the returned iterator will be equal to end().
- Returns:
An iterator to the first element of the span
-
inline constexpr iterator end() const noexcept#
Returns an iterator to the element following the last element of the span.
This element acts as a placeholder; attempting to access it results in undefined behavior.
- Returns:
An iterator to the element following the last element of the span
-
inline constexpr pointer data() const noexcept#
Returns a pointer to the beginning of the sequence.
- Returns:
A pointer to the first element of the span
-
inline constexpr size_type size() const noexcept#
Returns the number of elements in the span.
- Returns:
The number of elements in the span
-
inline constexpr size_type size_bytes() const noexcept#
Returns the size of the sequence in bytes.
- Returns:
The size of the sequence in bytes
-
inline constexpr bool empty() const noexcept#
Checks if the span is empty.
- Returns:
True if the span is empty, false otherwise
-
inline constexpr host_span first(size_type count) const noexcept#
Obtains a subspan consisting of the first count elements of the sequence.
- Parameters:
count – Number of elements from the beginning of this span to put in the subspan.
- Returns:
A subspan of the first count elements of the sequence
-
inline constexpr host_span last(size_type count) const noexcept#
Obtains a subspan consisting of the last count elements of the sequence.
- Parameters:
count – Number of elements from the end of this span to put in the subspan
- Returns:
A subspan of the last count elements of the sequence
-
inline bool is_device_accessible() const#
Returns whether the data is device accessible (e.g. pinned memory)
- Returns:
true if the data is device accessible
- inline constexpr host_span subspan( ) const noexcept#
Obtains a span that is a view over the
countelements of this span starting at offset.- Parameters:
offset – The offset of the first element in the subspan
count – The number of elements in the subspan
- Returns:
A subspan of the sequence, of requested count and offset
Public Static Attributes
-
static constexpr std::size_t extent = span_type::extent#
The extent of the span.
-
using element_type = typename span_type::element_type#
-
constexpr std::size_t dynamic_extent = cuda::std::dynamic_extent#