23 namespace rmm::mr::detail {
32 [[nodiscard]]
inline void*
pointer()
const {
return ptr; }
36 #ifdef RMM_DEBUG_PRINT
37 inline void print()
const { std::cout <<
pointer(); }
42 #ifdef RMM_DEBUG_PRINT
43 inline std::ostream& operator<<(std::ostream& out,
const block_base& block)
46 out << block.pointer();
64 template <
typename BlockType,
typename ListType = std::list<BlockType>>
75 using block_type = BlockType;
76 using list_type = ListType;
77 using size_type =
typename list_type::size_type;
78 using iterator =
typename list_type::iterator;
79 using const_iterator =
typename list_type::const_iterator;
82 [[nodiscard]] iterator
begin() noexcept {
return blocks.begin(); }
84 [[nodiscard]] const_iterator
begin() const noexcept {
return blocks.begin(); }
86 [[nodiscard]] const_iterator
cbegin() const noexcept {
return blocks.cbegin(); }
89 [[nodiscard]] iterator
end() noexcept {
return blocks.end(); }
91 [[nodiscard]] const_iterator
end() const noexcept {
return blocks.end(); }
93 [[nodiscard]] const_iterator
cend() const noexcept {
return blocks.cend(); }
100 [[nodiscard]] size_type
size() const noexcept {
return blocks.size(); }
108 [[nodiscard]]
bool is_empty() const noexcept {
return blocks.empty(); }
115 void erase(const_iterator iter) { blocks.erase(iter); }
121 void clear() noexcept { blocks.clear(); }
123 #ifdef RMM_DEBUG_PRINT
129 std::cout <<
size() << std::endl;
130 for (
auto const&
block : blocks) {
131 std::cout <<
block << std::endl;
153 return blocks.splice(pos, std::move(other.blocks));
const_iterator cend() const noexcept
beginning of the free list
Definition: free_list.hpp:93
const_iterator cbegin() const noexcept
beginning of the free list
Definition: free_list.hpp:86
const_iterator end() const noexcept
beginning of the free list
Definition: free_list.hpp:91
iterator begin() noexcept
beginning of the free list
Definition: free_list.hpp:82
void erase(const_iterator iter)
Removes the block indicated by iter from the free list.
Definition: free_list.hpp:115
Base class defining an interface for a list of free memory blocks.
Definition: free_list.hpp:65
void push_back(block_type &&block)
Appends the given block to the end of the free list. b is moved to the new element.
Definition: free_list.hpp:168
bool is_valid() const
Returns true if this block is valid (non-null), false otherwise.
Definition: free_list.hpp:34
size_type size() const noexcept
The size of the free list in blocks.
Definition: free_list.hpp:100
A simple block structure specifying the size and location of a block of memory, with a flag indicatin...
Definition: coalescing_free_list.hpp:36
iterator end() noexcept
end of the free list
Definition: free_list.hpp:89
void push_back(const block_type &block)
Appends the given block to the end of the free list.
Definition: free_list.hpp:161
void * pointer() const
Returns the raw pointer for this block.
Definition: free_list.hpp:32
void * ptr
Raw memory pointer.
Definition: free_list.hpp:26
bool is_empty() const noexcept
checks whether the free_list is empty.
Definition: free_list.hpp:108
void pop_front()
Removes the first element of the free list. If there are no elements in the free list,...
Definition: free_list.hpp:176
void insert(const_iterator pos, block_type const &block)
Insert a block in the free list before the specified position.
Definition: free_list.hpp:143
const_iterator begin() const noexcept
beginning of the free list
Definition: free_list.hpp:84
void clear() noexcept
Erase all blocks from the free_list.
Definition: free_list.hpp:121
Definition: free_list.hpp:25
void splice(const_iterator pos, free_list &&other)
Inserts a list of blocks in the free list before the specified position.
Definition: free_list.hpp:151