Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
batched_aio_reader< BatchSize > Class Template Reference

Public Member Functions

 batched_aio_reader (int fd)
 
void enqueue_read_first_batch (size_t offset_bytes, size_t size_bytes, void *dest)
 
void enqueue_read (size_t offset_bytes, size_t size_bytes, void *dest)
 
void wait_last_read ()
 

Protected Member Functions

void enqueue_next_batch ()
 

Protected Attributes

const int _fd
 
aiocb _batch1 [BatchSize]
 
aiocb _batch2 [BatchSize]
 
aiocb * _batch1_ptrs [BatchSize]
 
aiocb * _batch2_ptrs [BatchSize]
 
aiocb ** _active_batch
 
aiocb ** _next_batch
 
size_t _next_batch_size
 

Detailed Description

template<size_t BatchSize>
class batched_aio_reader< BatchSize >

Definition at line 391 of file profile_algebra_groups_read.cpp.

Constructor & Destructor Documentation

◆ batched_aio_reader()

template<size_t BatchSize>
batched_aio_reader< BatchSize >::batched_aio_reader ( int  fd)
inline

Definition at line 394 of file profile_algebra_groups_read.cpp.

395  : _fd(fd)
398  , _next_batch_size(0)
399  {
400  memset(_batch1, 0, sizeof(_batch1));
401  memset(_batch2, 0, sizeof(_batch2));
402  for (size_t i = 0; i < BatchSize; ++i) {
403  _batch1_ptrs[i] = &_batch1[i];
404  _batch2_ptrs[i] = &_batch2[i];
405  }
406  }

Member Function Documentation

◆ enqueue_next_batch()

template<size_t BatchSize>
void batched_aio_reader< BatchSize >::enqueue_next_batch ( )
inlineprotected

Definition at line 460 of file profile_algebra_groups_read.cpp.

461  {
462  int r = lio_listio(LIO_NOWAIT, _next_batch, BatchSize, nullptr);
463  if (r != 0) {
464  throw std::runtime_error("enqueue_batch error");
465  }
466  }

◆ enqueue_read()

template<size_t BatchSize>
void batched_aio_reader< BatchSize >::enqueue_read ( size_t  offset_bytes,
size_t  size_bytes,
void *  dest 
)
inline

Definition at line 428 of file profile_algebra_groups_read.cpp.

429  {
430  assert(_next_batch_size < BatchSize);
431 
432  aiocb *cb = _next_batch[_next_batch_size];
433  cb_init(cb, _fd, offset_bytes, size_bytes, dest);
434 
436  if (_next_batch_size == BatchSize) {
438  }
439  }
Here is the call graph for this function:

◆ enqueue_read_first_batch()

template<size_t BatchSize>
void batched_aio_reader< BatchSize >::enqueue_read_first_batch ( size_t  offset_bytes,
size_t  size_bytes,
void *  dest 
)
inline

Definition at line 408 of file profile_algebra_groups_read.cpp.

410  {
411  assert(_next_batch_size < BatchSize);
412 
413  aiocb *cb = _next_batch[_next_batch_size];
414  cb_init(cb, _fd, offset_bytes, size_bytes, dest);
415 
416  // When first batch is full, enqueue it and allow writing to the next
417  // batch.
418 
420  if (_next_batch_size == BatchSize) {
422 
423  std::swap(_active_batch, _next_batch);
424  _next_batch_size = 0;
425  }
426  }
Here is the call graph for this function:

◆ wait_last_read()

template<size_t BatchSize>
void batched_aio_reader< BatchSize >::wait_last_read ( )
inline

Definition at line 441 of file profile_algebra_groups_read.cpp.

442  {
443  // Wait for the _active_batch
444  for (size_t i = 0; i < BatchSize; ++i) {
445  int r = cb_wait(_active_batch[i]);
446  if (0 > r) {
447  throw std::runtime_error("bad read result");
448  }
449  if (0 == r) {
450  std::cout << "+";
451  }
452  }
453 
454  // swap pointers so it can be written into
455  std::swap(_active_batch, _next_batch);
456  _next_batch_size = 0;
457  }
Here is the call graph for this function:

Member Data Documentation

◆ _active_batch

template<size_t BatchSize>
aiocb** batched_aio_reader< BatchSize >::_active_batch
protected

Definition at line 473 of file profile_algebra_groups_read.cpp.

◆ _batch1

template<size_t BatchSize>
aiocb batched_aio_reader< BatchSize >::_batch1[BatchSize]
protected

Definition at line 469 of file profile_algebra_groups_read.cpp.

◆ _batch1_ptrs

template<size_t BatchSize>
aiocb* batched_aio_reader< BatchSize >::_batch1_ptrs[BatchSize]
protected

Definition at line 471 of file profile_algebra_groups_read.cpp.

◆ _batch2

template<size_t BatchSize>
aiocb batched_aio_reader< BatchSize >::_batch2[BatchSize]
protected

Definition at line 470 of file profile_algebra_groups_read.cpp.

◆ _batch2_ptrs

template<size_t BatchSize>
aiocb* batched_aio_reader< BatchSize >::_batch2_ptrs[BatchSize]
protected

Definition at line 472 of file profile_algebra_groups_read.cpp.

◆ _fd

template<size_t BatchSize>
const int batched_aio_reader< BatchSize >::_fd
protected

Definition at line 468 of file profile_algebra_groups_read.cpp.

◆ _next_batch

template<size_t BatchSize>
aiocb** batched_aio_reader< BatchSize >::_next_batch
protected

Definition at line 474 of file profile_algebra_groups_read.cpp.

◆ _next_batch_size

template<size_t BatchSize>
size_t batched_aio_reader< BatchSize >::_next_batch_size
protected

Definition at line 475 of file profile_algebra_groups_read.cpp.


The documentation for this class was generated from the following file:
batched_aio_reader::_batch2_ptrs
aiocb * _batch2_ptrs[BatchSize]
Definition: profile_algebra_groups_read.cpp:472
batched_aio_reader::_fd
const int _fd
Definition: profile_algebra_groups_read.cpp:468
batched_aio_reader::_batch1_ptrs
aiocb * _batch1_ptrs[BatchSize]
Definition: profile_algebra_groups_read.cpp:471
batched_aio_reader::_next_batch_size
size_t _next_batch_size
Definition: profile_algebra_groups_read.cpp:475
cb_wait
ssize_t cb_wait(aiocb *cb)
Definition: profile_algebra_groups_read.cpp:365
batched_aio_reader::enqueue_next_batch
void enqueue_next_batch()
Definition: profile_algebra_groups_read.cpp:460
cb_init
void cb_init(aiocb *cb, int fd, size_t offset_bytes, size_t size_bytes, void *dest)
Definition: profile_algebra_groups_read.cpp:338
batched_aio_reader::_next_batch
aiocb ** _next_batch
Definition: profile_algebra_groups_read.cpp:474
batched_aio_reader::_batch1
aiocb _batch1[BatchSize]
Definition: profile_algebra_groups_read.cpp:469
batched_aio_reader::_active_batch
aiocb ** _active_batch
Definition: profile_algebra_groups_read.cpp:473
batched_aio_reader::_batch2
aiocb _batch2[BatchSize]
Definition: profile_algebra_groups_read.cpp:470