Thrill
0.1
|
Implements dynamically resizable prefetching pool.
Definition at line 34 of file prefetch_pool.hpp.
#include <prefetch_pool.hpp>
Classes | |
struct | bid_hash |
Public Types | |
using | bid_type = typename block_type::bid_type |
using | block_type = BlockType |
Public Member Functions | |
prefetch_pool (size_t init_size=1) | |
prefetch_pool (const prefetch_pool &)=delete | |
non-copyable: delete copy-constructor More... | |
virtual | ~prefetch_pool () |
Waits for completion of all ongoing read requests and frees memory. More... | |
void | add (block_type *&block) |
Add a new block to prefetch pool, enlarges size of pool. More... | |
size_t | busy_size () const |
Returns the number of busy prefetching blocks. More... | |
request_ptr | find (bid_type bid) |
size_t | free_size () const |
Returns the number of free prefetching blocks. More... | |
bool | hint (bid_type bid) |
Gives a hint for prefetching a block, the block may or may not be read into a prefetch buffer. More... | |
bool | hint (bid_type bid, write_pool< block_type > &w_pool) |
Gives a hint for prefetching a block, the block may or may not be read into a prefetch buffer. More... | |
bool | in_prefetching (bid_type bid) |
Checks if a block is in the hinted block set. More... | |
bool | invalidate (bid_type bid) |
Cancel a hint request in case the block is no longer desired. More... | |
prefetch_pool & | operator= (const prefetch_pool &)=delete |
non-copyable: delete assignment operator More... | |
bool | poll (bid_type bid) |
Returns true if the blocks was hinted and the request is finished. More... | |
request_ptr | read (block_type *&block, bid_type bid) |
Reads block. More... | |
request_ptr | read (block_type *&block, bid_type bid, write_pool< block_type > &w_pool) |
size_t | resize (size_t new_size) |
size_t | size () const |
Returns number of owned blocks. More... | |
block_type * | steal () |
void | swap (prefetch_pool &obj) |
Protected Types | |
using | busy_blocks_iterator = typename unordered_map_type::iterator |
using | busy_entry = std::pair< block_type *, request_ptr > |
using | free_blocks_iterator = typename std::list< block_type * >::iterator |
using | unordered_map_type = typename std::unordered_map< bid_type, busy_entry, bid_hash > |
Protected Attributes | |
unordered_map_type | busy_blocks |
blocks that are in reading or already read but not retrieved by user More... | |
std::list< block_type * > | free_blocks |
contains free prefetch blocks More... | |
size_t | free_blocks_size |
count number of free blocks, since traversing the std::list is slow. More... | |
Static Private Attributes | |
static constexpr bool | debug = false |
using bid_type = typename block_type::bid_type |
Definition at line 40 of file prefetch_pool.hpp.
using block_type = BlockType |
Definition at line 39 of file prefetch_pool.hpp.
|
protected |
Definition at line 67 of file prefetch_pool.hpp.
|
protected |
Definition at line 64 of file prefetch_pool.hpp.
|
protected |
Definition at line 66 of file prefetch_pool.hpp.
|
protected |
Definition at line 65 of file prefetch_pool.hpp.
|
inlineexplicit |
Constructs pool.
init_size | initial number of blocks in the pool |
Definition at line 81 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::operator=().
|
delete |
non-copyable: delete copy-constructor
|
inlinevirtual |
Waits for completion of all ongoing read requests and frees memory.
Definition at line 102 of file prefetch_pool.hpp.
|
inline |
Add a new block to prefetch pool, enlarges size of pool.
Definition at line 142 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size.
Referenced by read_write_pool< BlockType >::add_prefetch().
|
inline |
Returns the number of busy prefetching blocks.
Definition at line 136 of file prefetch_pool.hpp.
Referenced by read_write_pool< BlockType >::busy_size_prefetch().
|
inline |
Returns the request pointer for a hinted block, or an invalid nullptr request in case it was not requested due to lack of prefetch buffers.
Definition at line 270 of file prefetch_pool.hpp.
Referenced by read_write_pool< BlockType >::find_hint(), and prefetch_pool< BlockType >::poll().
|
inline |
Returns the number of free prefetching blocks.
Definition at line 130 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size.
Referenced by read_write_pool< BlockType >::free_size_prefetch().
|
inline |
Gives a hint for prefetching a block, the block may or may not be read into a prefetch buffer.
bid | address of a block to be prefetched |
true
if there was a free block to do prefetch and prefetching was scheduled, false
otherwiseread
method) calling hint
function has no effect Definition at line 174 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size, prefetch_pool< BlockType >::in_prefetching(), and TLX_LOG.
Referenced by read_write_pool< BlockType >::hint(), and read_write_pool< BlockType >::write().
|
inline |
Gives a hint for prefetching a block, the block may or may not be read into a prefetch buffer.
This variant checks if the write pool is currently writing said block.
bid | address of a block to be prefetched |
true
if there was a free block to do prefetch and prefetching was scheduled, false
otherwisew_pool | The corresponding write pool; so the method can check if the block is maybe still in RAM. |
read
method) calling hint
function has no effect Definition at line 212 of file prefetch_pool.hpp.
References write_pool< BlockType >::add(), prefetch_pool< BlockType >::free_blocks_size, write_pool< BlockType >::has_request(), prefetch_pool< BlockType >::in_prefetching(), write_pool< BlockType >::steal_request(), and TLX_LOG.
|
inline |
Checks if a block is in the hinted block set.
Definition at line 263 of file prefetch_pool.hpp.
Referenced by prefetch_pool< BlockType >::hint(), and read_write_pool< BlockType >::in_prefetching().
|
inline |
Cancel a hint request in case the block is no longer desired.
Definition at line 244 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size, and request_interface::READ.
Referenced by read_write_pool< BlockType >::invalidate(), and read_write_pool< BlockType >::write().
|
delete |
non-copyable: delete assignment operator
Referenced by prefetch_pool< BlockType >::prefetch_pool().
|
inline |
Returns true if the blocks was hinted and the request is finished.
Definition at line 281 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::find(), and CountingPtr< Type, Deleter >::valid().
Referenced by read_write_pool< BlockType >::poll_hint().
|
inline |
Reads block.
If this block is cached block is not read but passed from the cache.
block | block object, where data to be read to. If block was cached block 's ownership goes to the pool and block from cache is returned in block value. |
bid | address of the block |
block
parameter must be allocated dynamically using new
.Definition at line 301 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size, and TLX_LOG.
Referenced by read_write_pool< BlockType >::read().
|
inline |
Definition at line 321 of file prefetch_pool.hpp.
References write_pool< BlockType >::add(), prefetch_pool< BlockType >::free_blocks_size, write_pool< BlockType >::has_request(), write_pool< BlockType >::steal_request(), and TLX_LOG.
|
inline |
Resizes size of the pool.
new_size | desired size of the pool. If some blocks are used for prefetching, these blocks can't be freed. Only free blocks (not in prefetching) can be freed by reducing the size of the pool calling this method. |
Definition at line 359 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size, and prefetch_pool< BlockType >::size().
Referenced by read_write_pool< BlockType >::resize_prefetch().
|
inline |
Returns number of owned blocks.
Definition at line 124 of file prefetch_pool.hpp.
Referenced by prefetch_pool< BlockType >::resize(), and read_write_pool< BlockType >::size_prefetch().
|
inline |
Take out a block from the pool, one unhinted free block must be available.
Definition at line 152 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::free_blocks_size, and tlx_die_unless.
Referenced by read_write_pool< BlockType >::steal_prefetch().
|
inline |
Definition at line 94 of file prefetch_pool.hpp.
References prefetch_pool< BlockType >::busy_blocks, prefetch_pool< BlockType >::free_blocks, and prefetch_pool< BlockType >::free_blocks_size.
Referenced by std::swap().
|
protected |
blocks that are in reading or already read but not retrieved by user
Definition at line 73 of file prefetch_pool.hpp.
Referenced by prefetch_pool< BlockType >::swap().
|
staticprivate |
Definition at line 36 of file prefetch_pool.hpp.
|
protected |
contains free prefetch blocks
Definition at line 70 of file prefetch_pool.hpp.
Referenced by prefetch_pool< BlockType >::swap().
|
protected |
count number of free blocks, since traversing the std::list is slow.
Definition at line 76 of file prefetch_pool.hpp.
Referenced by prefetch_pool< BlockType >::add(), prefetch_pool< BlockType >::free_size(), prefetch_pool< BlockType >::hint(), prefetch_pool< BlockType >::invalidate(), prefetch_pool< BlockType >::read(), prefetch_pool< BlockType >::resize(), prefetch_pool< BlockType >::steal(), and prefetch_pool< BlockType >::swap().