casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes
casa::LatticeCache< T > Class Template Reference

a class for caching image access via tiles More...

#include <LatticeCache.h>

List of all members.

Public Member Functions

 LatticeCache (Lattice< T > &image, Int cacheSize, IPosition tileShape, Vector< Float > &tileOverlap, Bool additive)
 Constructor: cachesize in units of T.
 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)
 Return the tile for a given location.
Array< T > & tile (const IPosition &tileLoc, Bool discard=True)
const Array< T > & tile (const IPosition &tileLoc)
 const version is needed
IPositioncacheLocation (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.

Protected Member Functions

 LatticeCache ()
Int getFreeTile (Bool readonly)
void writeTile (Int tile)
void readTile (Int tile, Bool readonly)

Protected Attributes

Int numberTiles
IPosition tileShape
Vector< InttileShapeVec
Vector< InttileOffsetVec
Vector< FloattileOverlap
Bool additive
Int cacheSize
Int cacheAccesses
Int cacheHits
Int cacheMisses
Int cacheReads
Int cacheWrites
Block< IPositiontileLocs
Block< InttileSequence
Block< Array< T > > tileContents
Lattice< T > * image_p

Detailed Description

template<class T>
class casa::LatticeCache< T >

a class for caching image access via tiles

Intended use:

Public interface

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

Definition at line 94 of file LatticeCache.h.


Constructor & Destructor Documentation

template<class T>
casa::LatticeCache< T >::LatticeCache ( Lattice< T > &  image,
Int  cacheSize,
IPosition  tileShape,
Vector< Float > &  tileOverlap,
Bool  additive 
)

Constructor: cachesize in units of T.

tileOverlap is the fractional overlap between neighbouring tile.

template<class T>
casa::LatticeCache< T >::LatticeCache ( const LatticeCache< T > &  other)
template<class T>
virtual casa::LatticeCache< T >::~LatticeCache ( ) [virtual]
template<class T>
casa::LatticeCache< T >::LatticeCache ( ) [inline, protected]

Definition at line 132 of file LatticeCache.h.


Member Function Documentation

template<class T>
IPosition& casa::LatticeCache< T >::cacheLocation ( IPosition cacheLoc,
const IPosition tileLoc 
)

Return the IPosition for the start of this tile.

template<class T>
virtual void casa::LatticeCache< T >::clearCacheStatistics ( ) [virtual]

Clear the statistics of cache access.

template<class T>
virtual void casa::LatticeCache< T >::flush ( ) [virtual]

Flush contents.

template<class T>
Int casa::LatticeCache< T >::getFreeTile ( Bool  readonly) [protected]
template<class T>
LatticeCache<T>& casa::LatticeCache< T >::operator= ( const LatticeCache< T > &  other)
template<class T>
void casa::LatticeCache< T >::readTile ( Int  tile,
Bool  readonly 
) [protected]
template<class T>
virtual void casa::LatticeCache< T >::showCacheStatistics ( ostream &  os) [virtual]

Show the statistics of cache access.

template<class T>
Array<T>& casa::LatticeCache< T >::tile ( IPosition cacheLoc,
const IPosition tileLoc,
Bool  discard = True 
)

Return the tile for a given location.

template<class T>
Array<T>& casa::LatticeCache< T >::tile ( const IPosition tileLoc,
Bool  discard = True 
)
template<class T>
const Array<T>& casa::LatticeCache< T >::tile ( const IPosition tileLoc)

const version is needed

template<class T>
void casa::LatticeCache< T >::writeTile ( Int  tile) [protected]

Member Data Documentation

template<class T>
Bool casa::LatticeCache< T >::additive [protected]

Definition at line 138 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheAccesses [protected]

Definition at line 141 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheHits [protected]

Definition at line 142 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheMisses [protected]

Definition at line 143 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheReads [protected]

Definition at line 144 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheSize [protected]

Definition at line 140 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::cacheWrites [protected]

Definition at line 145 of file LatticeCache.h.

template<class T>
Lattice<T>* casa::LatticeCache< T >::image_p [protected]

Definition at line 156 of file LatticeCache.h.

template<class T>
Int casa::LatticeCache< T >::numberTiles [protected]

Definition at line 132 of file LatticeCache.h.

template<class T>
Block<Array<T> > casa::LatticeCache< T >::tileContents [protected]

Definition at line 151 of file LatticeCache.h.

template<class T>
Block<IPosition> casa::LatticeCache< T >::tileLocs [protected]

Definition at line 149 of file LatticeCache.h.

template<class T>
Vector<Int> casa::LatticeCache< T >::tileOffsetVec [protected]

Definition at line 136 of file LatticeCache.h.

template<class T>
Vector<Float> casa::LatticeCache< T >::tileOverlap [protected]

Definition at line 137 of file LatticeCache.h.

template<class T>
Block<Int> casa::LatticeCache< T >::tileSequence [protected]

Definition at line 150 of file LatticeCache.h.

template<class T>
IPosition casa::LatticeCache< T >::tileShape [protected]

Definition at line 135 of file LatticeCache.h.

template<class T>
Vector<Int> casa::LatticeCache< T >::tileShapeVec [protected]

Definition at line 136 of file LatticeCache.h.


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