ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::TwoLevelMemory Class Reference

the parameters \( B \) and \( M \) of the model, the counters of the I/Os and the occupation of the internal memory More...

#include <ADS/external/TwoLevelMemory.h>

Public member functions

 TwoLevelMemory (std::size_t B, std::size_t M)
 a memory of \( M \) items and blocks of \( B \) items
 TwoLevelMemory (const TwoLevelMemory &)=delete
 no copy, since the counters belong to one simulation
TwoLevelMemory & operator= (const TwoLevelMemory &)=delete
 no copy, since the counters belong to one simulation
std::size_t blockSize (void) const
 \( B \), the items of a block
std::size_t memorySize (void) const
 \( M \), the items of the internal memory
std::size_t blocks (std::size_t n) const
 \( \lceil n / B \rceil \), the blocks of \( n \) items
std::uint64_t reads (void) const
 the reads counted so far
std::uint64_t writes (void) const
 the writes counted so far
std::uint64_t ios (void) const
 the I/Os counted so far, reads() plus writes()
void resetCounters (void)
 sets the counters of the I/Os to 0, and the peak to the memory in use
void allocate (std::size_t k)
 takes \( k \) items of the internal memory
void release (std::size_t k)
 gives back \( k \) items of the internal memory
std::size_t used (void) const
 the items of the internal memory in use
std::size_t peak (void) const
 the largest used() since the construction or resetCounters()
void countRead (void)
 one more read: called by DiskFile only
void countWrite (void)
 one more write: called by DiskFile only

Detailed description

the parameters \( B \) and \( M \) of the model, the counters of the I/Os and the occupation of the internal memory

Constructor and destructor documentation

◆ TwoLevelMemory() [1/2]

ADS::TwoLevelMemory::TwoLevelMemory ( std::size_t B,
std::size_t M )

a memory of \( M \) items and blocks of \( B \) items

Precondition
\( B \ge 1 \) and \( M \ge 2 B \)

◆ TwoLevelMemory() [2/2]

ADS::TwoLevelMemory::TwoLevelMemory ( const TwoLevelMemory & )
delete

no copy, since the counters belong to one simulation

Member function documentation

◆ allocate()

void ADS::TwoLevelMemory::allocate ( std::size_t k)

takes \( k \) items of the internal memory

Precondition
used() plus \( k \) is at most \( M \)

◆ blocks()

std::size_t ADS::TwoLevelMemory::blocks ( std::size_t n) const
nodiscard

\( \lceil n / B \rceil \), the blocks of \( n \) items

◆ blockSize()

std::size_t ADS::TwoLevelMemory::blockSize ( void ) const
nodiscard

\( B \), the items of a block

◆ countRead()

void ADS::TwoLevelMemory::countRead ( void )

one more read: called by DiskFile only

◆ countWrite()

void ADS::TwoLevelMemory::countWrite ( void )

one more write: called by DiskFile only

◆ ios()

std::uint64_t ADS::TwoLevelMemory::ios ( void ) const
nodiscard

the I/Os counted so far, reads() plus writes()

◆ memorySize()

std::size_t ADS::TwoLevelMemory::memorySize ( void ) const
nodiscard

\( M \), the items of the internal memory

◆ operator=()

TwoLevelMemory & ADS::TwoLevelMemory::operator= ( const TwoLevelMemory & )
delete

no copy, since the counters belong to one simulation

◆ peak()

std::size_t ADS::TwoLevelMemory::peak ( void ) const
nodiscard

the largest used() since the construction or resetCounters()

◆ reads()

std::uint64_t ADS::TwoLevelMemory::reads ( void ) const
nodiscard

the reads counted so far

◆ release()

void ADS::TwoLevelMemory::release ( std::size_t k)

gives back \( k \) items of the internal memory

Precondition
\( k \) is at most used()

◆ resetCounters()

void ADS::TwoLevelMemory::resetCounters ( void )

sets the counters of the I/Os to 0, and the peak to the memory in use

◆ used()

std::size_t ADS::TwoLevelMemory::used ( void ) const
nodiscard

the items of the internal memory in use

◆ writes()

std::uint64_t ADS::TwoLevelMemory::writes ( void ) const
nodiscard

the writes counted so far


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