实用程序 Span#

group Exception

变量

constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max()#

用于区分静态和动态范围 std::span 的常量。

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 : public cudf::detail::span_base<T, cudf::dynamic_extent, host_span<T, cudf::dynamic_extent>>#
#include <span.hpp>

具有简化功能集的 C++20 std::span。

公共类型

using base = cudf::detail::span_base<T, Extent, host_span<T, Extent>>#

基类型。

公共函数

inline constexpr host_span(T *data, std::size_t size, bool is_device_accessible)#

从指针和大小构造。

注意

这需要是主机-设备可用的,因为它被 base_2dspan 中的主机-设备函数使用。

参数:
  • data – Span 中第一个元素的指针

  • size – Span 中的元素数量

  • is_device_accessible – 数据是否可由设备访问 (例如,锁页内存)

template<typename C>
inline constexpr host_span(C &in)#

从容器构造

参数:

in – 用于构造 span 的容器

template<typename C>
inline constexpr host_span(C const &in)#

从 const 容器构造

参数:

in – 用于构造 span 的容器

template<typename OtherT>
inline constexpr host_span(cudf::detail::host_vector<OtherT> &in)#

从 host_vector 构造

参数:

in – 用于构造 span 的 host_vector

template<typename OtherT>
inline constexpr host_span(cudf::detail::host_vector<OtherT> const &in)#

从 const host_vector 构造

参数:

in – 用于构造 span 的 host_vector

template<typename OtherT, std::size_t OtherExtent>
inline constexpr host_span(host_span<OtherT, OtherExtent> const &other) noexcept#
参数:

other – 要复制的 span

inline constexpr base::reference operator[](typename base::size_type idx) const#

返回序列中第 idx 个元素的引用。

如果 idx 超出范围(即大于或等于 size()),则行为未定义。

参数:

idx – 要访问的元素的索引

返回:

序列中第 idx 个元素的引用,即 data()[idx]

inline constexpr base::reference front() const#

返回 span 中第一个元素的引用。

对空 span 调用 front() 将导致未定义行为。

返回:

span 中第一个元素的引用

inline constexpr base::reference back() const#

返回 span 中最后一个元素的引用。

对空 span 调用 back() 将导致未定义行为。

返回:

span 中最后一个元素的引用

inline bool is_device_accessible() const#

返回数据是否可由设备访问 (例如,锁页内存)

返回:

如果数据可由设备访问,则为 true

inline constexpr host_span subspan(typename base::size_type offset, typename base::size_type count) const noexcept#

获取一个 span,它是从此 span 中从 offset 开始的 count 个元素的视图。

参数:
  • offset – 子 span 中第一个元素的偏移量

  • count – 子 span 中的元素数量

返回:

序列的子 span,具有请求的 count 和 offset

template<typename T>
struct is_device_span_supported_container : public std::false_type#
template<typename T, typename Alloc>
struct is_device_span_supported_container<thrust::device_vector<T, Alloc>> : public std::true_type#
template<typename T>
struct is_device_span_supported_container<rmm::device_vector<T>> : public std::true_type#
template<typename T>
struct is_device_span_supported_container<rmm::device_uvector<T>> : public std::true_type#
template<typename T, std::size_t Extent = cudf::dynamic_extent>
struct device_span : public cudf::detail::span_base<T, cudf::dynamic_extent, device_span<T, cudf::dynamic_extent>>#
#include <span.hpp>

C++20 std::span 的设备版本,具有简化功能集。

公共类型

using base = cudf::detail::span_base<T, Extent, device_span<T, Extent>>#

基类型。

公共函数

template<typename C>
inline constexpr device_span(C &in)#

从容器构造

参数:

in – 用于构造 span 的容器

template<typename C>
inline constexpr device_span(C const &in)#

从 const 容器构造

参数:

in – 用于构造 span 的容器

template<typename OtherT, std::size_t OtherExtent>
inline constexpr device_span(device_span<OtherT, OtherExtent> const &other) noexcept#
参数:

other – 要复制的 span

inline constexpr base::reference operator[](typename base::size_type idx) const#

返回序列中第 idx 个元素的引用。

如果 idx 超出范围(即大于或等于 size()),则行为未定义。

参数:

idx – 要访问的元素的索引

返回:

序列中第 idx 个元素的引用,即 data()[idx]

inline constexpr base::reference front() const#

返回 span 中第一个元素的引用。

对空 span 调用 front() 将导致未定义行为。

返回:

span 中第一个元素的引用

inline constexpr base::reference back() const#

返回 span 中最后一个元素的引用。

对空 span 调用 back() 将导致未定义行为。

返回:

span 中最后一个元素的引用

inline constexpr device_span subspan(typename base::size_type offset, typename base::size_type count) const noexcept#

获取一个 span,它是从此 span 中从 offset 开始的 count 个元素的视图。

参数:
  • offset – 子 span 中第一个元素的偏移量

  • count – 子 span 中的元素数量

返回:

序列的子 span,具有请求的 count 和 offset