Thrill  0.1
block_prefetcher< BlockType, BidIteratorType > Class Template Reference

Detailed Description

template<typename BlockType, typename BidIteratorType>
class foxxll::block_prefetcher< BlockType, BidIteratorType >

Encapsulates asynchronous prefetching engine.

block_prefetcher overlaps I/Os with consumption of read data. Utilizes optimal asynchronous prefetch scheduling (by Peter Sanders et.al.)

Definition at line 56 of file block_prefetcher.hpp.

+ Collaboration diagram for block_prefetcher< BlockType, BidIteratorType >:

#include <block_prefetcher.hpp>

Public Types

using bid_iterator_type = BidIteratorType
 
using bid_type = typename block_type::bid_type
 
using block_type = BlockType
 

Public Member Functions

 block_prefetcher (bid_iterator_type _cons_begin, bid_iterator_type _cons_end, size_t *_pref_seq, size_t _prefetch_buf_size, completion_handler do_after_fetch=completion_handler())
 
 block_prefetcher (const block_prefetcher &)=delete
 non-copyable: delete copy-constructor More...
 
 ~block_prefetcher ()
 Frees used memory. More...
 
bool block_consumed (block_type *&buffer)
 
bool empty () const
 
block_prefetcheroperator= (const block_prefetcher &)=delete
 non-copyable: delete assignment operator More...
 
size_t pos () const
 Index of the next element in the consume sequence. More...
 
block_typepull_block ()
 

Protected Member Functions

block_typewait (size_t iblock)
 

Protected Attributes

onoff_switchcompleted
 
bid_iterator_type consume_seq_begin
 
bid_iterator_type consume_seq_end
 
completion_handler do_after_fetch
 
size_t nextconsume
 
size_t nextread
 
const size_t nreadblocks
 
size_t * pref_buffer
 
size_t * prefetch_seq
 
bid_typeread_bids
 
block_typeread_buffers
 
request_ptrread_reqs
 
size_t seq_length
 

Static Private Attributes

static constexpr bool debug = false
 

Member Typedef Documentation

◆ bid_iterator_type

using bid_iterator_type = BidIteratorType

Definition at line 62 of file block_prefetcher.hpp.

◆ bid_type

using bid_type = typename block_type::bid_type

Definition at line 64 of file block_prefetcher.hpp.

◆ block_type

using block_type = BlockType

Definition at line 61 of file block_prefetcher.hpp.

Constructor & Destructor Documentation

◆ block_prefetcher() [1/2]

block_prefetcher ( bid_iterator_type  _cons_begin,
bid_iterator_type  _cons_end,
size_t *  _pref_seq,
size_t  _prefetch_buf_size,
completion_handler  do_after_fetch = completion_handler() 
)
inline

Constructs an object and immediately starts prefetching.

Parameters
_cons_beginbid_iterator pointing to the bid of the first block to be consumed
_cons_endbid_iterator pointing to the bid of the ( last + 1 ) block of consumption sequence
_pref_seqgives the prefetch order, is a pointer to the integer array that contains the indices of the blocks in the consumption sequence
_prefetch_buf_sizeamount of prefetch buffers to use
do_after_fetchunknown

Definition at line 110 of file block_prefetcher.hpp.

References set_switch_handler::set_switch_handler(), and TLX_LOG.

◆ block_prefetcher() [2/2]

block_prefetcher ( const block_prefetcher< BlockType, BidIteratorType > &  )
delete

non-copyable: delete copy-constructor

◆ ~block_prefetcher()

~block_prefetcher ( )
inline

Frees used memory.

Definition at line 221 of file block_prefetcher.hpp.

Member Function Documentation

◆ block_consumed()

bool block_consumed ( block_type *&  buffer)
inline

Exchanges buffers between prefetcher and application.

Parameters
bufferpointer to the consumed buffer. After call if return value is true buffer contains valid pointer to the next unconsumed prefetched buffer.
Remarks
parameter buffer must be value returned by pull_block() or block_consumed() methods
Returns
false if there are no blocks to prefetch left, true if consumption sequence is not emptied

Definition at line 172 of file block_prefetcher.hpp.

References set_switch_handler::set_switch_handler(), and TLX_LOG.

Referenced by buf_istream< BlockType, BidIteratorType >::operator++(), buf_istream_reverse< BlockType, BidIteratorType >::operator++(), buf_istream< BlockType, BidIteratorType >::operator>>(), and buf_istream_reverse< BlockType, BidIteratorType >::operator>>().

◆ empty()

bool empty ( ) const
inline

No more consumable blocks available, but can't delete the prefetcher, because not all blocks may have been returned, yet.

Definition at line 209 of file block_prefetcher.hpp.

◆ operator=()

block_prefetcher& operator= ( const block_prefetcher< BlockType, BidIteratorType > &  )
delete

non-copyable: delete assignment operator

◆ pos()

size_t pos ( ) const
inline

Index of the next element in the consume sequence.

Definition at line 215 of file block_prefetcher.hpp.

◆ pull_block()

block_type* pull_block ( )
inline

Pulls next unconsumed block from the consumption sequence.

Returns
Pointer to the already prefetched block from the internal buffer pool

Definition at line 162 of file block_prefetcher.hpp.

References TLX_LOG.

Referenced by buf_istream< BlockType, BidIteratorType >::buf_istream().

◆ wait()

block_type* wait ( size_t  iblock)
inlineprotected

Definition at line 87 of file block_prefetcher.hpp.

References TLX_LOG, onoff_switch::wait_for_on(), and stats::WAIT_OP_READ.

Member Data Documentation

◆ completed

onoff_switch* completed
protected

Definition at line 82 of file block_prefetcher.hpp.

◆ consume_seq_begin

bid_iterator_type consume_seq_begin
protected

Definition at line 67 of file block_prefetcher.hpp.

◆ consume_seq_end

bid_iterator_type consume_seq_end
protected

Definition at line 68 of file block_prefetcher.hpp.

◆ debug

constexpr bool debug = false
staticprivate

Definition at line 58 of file block_prefetcher.hpp.

◆ do_after_fetch

completion_handler do_after_fetch
protected

Definition at line 85 of file block_prefetcher.hpp.

◆ nextconsume

size_t nextconsume
protected

Definition at line 74 of file block_prefetcher.hpp.

◆ nextread

size_t nextread
protected

Definition at line 73 of file block_prefetcher.hpp.

◆ nreadblocks

const size_t nreadblocks
protected

Definition at line 76 of file block_prefetcher.hpp.

◆ pref_buffer

size_t* pref_buffer
protected

Definition at line 83 of file block_prefetcher.hpp.

◆ prefetch_seq

size_t* prefetch_seq
protected

Definition at line 71 of file block_prefetcher.hpp.

◆ read_bids

bid_type* read_bids
protected

Definition at line 80 of file block_prefetcher.hpp.

◆ read_buffers

block_type* read_buffers
protected

Definition at line 78 of file block_prefetcher.hpp.

◆ read_reqs

request_ptr* read_reqs
protected

Definition at line 79 of file block_prefetcher.hpp.

◆ seq_length

size_t seq_length
protected

Definition at line 69 of file block_prefetcher.hpp.


The documentation for this class was generated from the following file: