LatticeCache.h

Classes

LatticeCache -- a class for caching image access via tiles (full description)

template <class T> class LatticeCache

Interface

Public Members
LatticeCache(Lattice<T> &image, Int cacheSize, IPosition tileShape, IPosition<Float>& tileOverlap, Bool additive)
LatticeCache(const LatticeCache<T> & other)
LatticeCache<T> &operator=(const LatticeCache<T> & other)
virtual ~LatticeCache()
Array<T>& tile(IPosition& cacheLoc, const IPosition& tileLoc, Bool discard=True)
Array<T>& tile(const IPosition& tileLoc, Bool discard=True)
const Array<T>& tile(const IPosition& tileLoc)
IPosition& cacheLocation(IPosition& cacheLoc, const IPosition& tileLoc)
virtual void showCacheStatistics(ostream& os)
virtual void clearCacheStatistics()
virtual void flush()
Protected Members
LatticeCache()
Int getFreeTile(Bool readonly)
void writeTile(Int tile)
void readTile(Int tile, Bool readonly)

Description

Prerequisite

Etymology

This class divides an image into Tiles that are stored in a Cache.

Synopsis

An image is divided into tiles of a specified shape. Access to the image pixels is via these tiles. A cache of active tiles is kept in memory up to a specified limit in memory allocation. Tiles are flushed to disk using a Least-Recently-Used Criterion.

The tile size specified is the maximum dimension. Near the edge, smaller tiles are returned if necessary.

The offset needed to get back to true pixels is also available.

The cache hit rate for a sufficient number of random accesses goes as the ratio of cache size to image size.

Tiles may be overlapped. If there is any overlap then the caller is responsible for dealing with the overlap. Normally one will only want overlapping windows for additive operations in which case the additive flag to the constructor should be used.

Example


Motivation

To aid in gridding

To Do

Member Description

LatticeCache(Lattice<T> &image, Int cacheSize, IPosition tileShape, IPosition<Float>& tileOverlap, Bool additive)

Constructor: cachesize in units of T. tileOverlap is the fractional overlap between neighbouring tile.

LatticeCache(const LatticeCache<T> & other)

LatticeCache<T> &operator=(const LatticeCache<T> & other)

virtual ~LatticeCache()

Array<T>& tile(IPosition& cacheLoc, const IPosition& tileLoc, Bool discard=True)
Array<T>& tile(const IPosition& tileLoc, Bool discard=True)

Return the tile for a given location

const Array<T>& tile(const IPosition& tileLoc)

const version is needed

IPosition& cacheLocation(IPosition& cacheLoc, const IPosition& tileLoc)

Return the IPosition for the start of this tile

virtual void showCacheStatistics(ostream& os)

Show the statistics of cache access

virtual void clearCacheStatistics()

Clear the statistics of cache access

virtual void flush()

Flush contents

LatticeCache()

Int getFreeTile(Bool readonly)

void writeTile(Int tile)

void readTile(Int tile, Bool readonly)