10 #include <rapidsmpf/buffer/buffer.hpp>
60 std::ranges::input_range Range =
61 std::initializer_list<std::pair<MemoryType, std::size_t>>>
62 requires std::convertible_to<
63 std::ranges::range_value_t<Range>,
64 std::pair<MemoryType, std::size_t>>
67 content_sizes_.fill(0);
68 for (
auto&& [mem_type, size] : sizes) {
69 auto idx =
static_cast<std::size_t
>(mem_type);
70 if (idx < content_sizes_.size()) {
71 content_sizes_[idx] = size;
93 [[nodiscard]] constexpr std::size_t&
content_size(MemoryType mem_type) noexcept {
94 return content_sizes_[
static_cast<std::size_t
>(mem_type)];
103 [[nodiscard]] constexpr std::size_t
content_size(MemoryType mem_type)
const noexcept {
104 return content_sizes_[
static_cast<std::size_t
>(mem_type)];
117 return std::accumulate(
118 content_sizes_.begin(), content_sizes_.end(), std::size_t{0}
123 [[nodiscard]] constexpr
bool spillable() const noexcept {
136 return spillable_ == other.spillable_ && content_sizes_ == other.content_sizes_;
142 std::array<std::size_t, MEMORY_TYPES.size()> content_sizes_ = {};
147 std::is_trivially_copyable_v<ContentDescription>,
148 "ContentDescription must be trivially copyable"
Description of an object's content.
Spillable
Indicates whether the content is spillable.
constexpr ContentDescription(Spillable spillable=Spillable::NO)
Construct a description with all sizes zero and a given spillability.
requires constexpr std::convertible_to< std::ranges::range_value_t< Range >, std::pair< MemoryType, std::size_t > > ContentDescription(Range &&sizes, Spillable spillable)
Construct a content description from a range of (MemoryType, size) pairs.
constexpr std::size_t content_size(MemoryType mem_type) const noexcept
Get the size for a specific memory type.
constexpr std::size_t & content_size(MemoryType mem_type) noexcept
Access (read/write) the size for a specific memory type.
constexpr std::size_t content_size() const noexcept
Get the total content size across all memory types.
constexpr bool operator==(ContentDescription const &other) const noexcept
Equality comparison.
constexpr bool spillable() const noexcept