casacore
Loading...
Searching...
No Matches
LatticeCache.h
Go to the documentation of this file.
1//# LatticeCache: Cache for accessing a Lattice in Tiles
2//# Copyright (C) 1995,1996,1997,1999,2000,2001
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef LATTICES_LATTICECACHE_H
27#define LATTICES_LATTICECACHE_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/Array.h>
33#include <casacore/casa/Arrays/Vector.h>
34#include <casacore/casa/Containers/Block.h>
35
36//# Forward Declarations
37#include <casacore/casa/iosfwd.h>
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40template <class T> class Block;
41template <class T> class Lattice;
42
43// <summary> a class for caching image access via tiles</summary>
44//
45// <use visibility=export>
46//
47// <reviewed reviewer="" date="" tests="" demos="">
48// </reviewed>
49//
50// <prerequisite>
51// <li> <linkto class=Lattice>Lattice</linkto>
52// </prerequisite>
53//
54// <etymology>
55// This class divides an image into Tiles that are stored in
56// a Cache.
57// </etymology>
58//
59// <synopsis>
60// An image is divided into tiles of a specified shape. Access to the
61// image pixels is via these tiles. A cache of active tiles is kept
62// in memory up to a specified limit in memory allocation. Tiles
63// are flushed to disk using a Least-Recently-Used Criterion.
64//
65// The tile size specified is the maximum dimension. Near the edge,
66// smaller tiles are returned if necessary.
67//
68// The offset needed to get back to true pixels is also available.
69//
70// The cache hit rate for a sufficient number of random accesses
71// goes as the ratio of cache size to image size.
72//
73// Tiles may be overlapped. If there is any overlap then the
74// caller is responsible for dealing with the overlap. Normally
75// one will only want overlapping windows for additive operations
76// in which case the additive flag to the constructor should be
77// used.
78// </synopsis>
79//
80// <example>
81// <srcblock>
82// </srcblock>
83//
84// </example>
85//
86// <motivation>
87// To aid in gridding
88// </motivation>
89//
90// <todo asof="1997/02/27">
91// </todo>
92
93template <class T> class LatticeCache
94{
95public:
96
97 // Constructor: cachesize in units of T. tileOverlap is the fractional
98 // overlap between neighbouring tile.
101
103
105
106 virtual ~LatticeCache();
107
108 // Return the tile for a given location
109 // <group>
110 Array<T>& tile(IPosition& cacheLoc, const IPosition& tileLoc, Bool discard=True);
111 Array<T>& tile(const IPosition& tileLoc, Bool discard=True);
112 // </group>
113
114 // const version is needed
115 const Array<T>& tile(const IPosition& tileLoc);
116
117 // Return the IPosition for the start of this tile
118 IPosition& cacheLocation(IPosition& cacheLoc, const IPosition& tileLoc);
119
120 // Show the statistics of cache access
121 virtual void showCacheStatistics(ostream& os);
122
123 // Clear the statistics of cache access
124 virtual void clearCacheStatistics();
125
126 // Flush contents
127 virtual void flush();
128
129protected:
130
132
138
145
147
151
153 void readTile(Int tile, Bool readonly);
154
156};
157
158
159} //# NAMESPACE CASACORE - END
160
161#ifndef CASACORE_NO_AUTO_TEMPLATES
162#include <casacore/lattices/Lattices/LatticeCache.tcc>
163#endif //# CASACORE_NO_AUTO_TEMPLATES
164#endif
simple 1-D array
Definition Block.h:198
Block< IPosition > tileLocs
const Array< T > & tile(const IPosition &tileLoc)
const version is needed
void writeTile(Int tile)
Vector< Float > tileOverlap
virtual void clearCacheStatistics()
Clear the statistics of cache access.
Array< T > & tile(IPosition &cacheLoc, const IPosition &tileLoc, Bool discard=True)
Return the tile for a given location.
virtual void showCacheStatistics(ostream &os)
Show the statistics of cache access.
IPosition & cacheLocation(IPosition &cacheLoc, const IPosition &tileLoc)
Return the IPosition for the start of this tile.
Lattice< T > * image_p
LatticeCache(Lattice< T > &image, Int cacheSize, IPosition tileShape, Vector< Float > &tileOverlap, Bool additive)
Constructor: cachesize in units of T.
Vector< Int > tileOffsetVec
Block< Array< T > > tileContents
LatticeCache< T > & operator=(const LatticeCache< T > &other)
Block< Int > tileSequence
Vector< Int > tileShapeVec
Array< T > & tile(const IPosition &tileLoc, Bool discard=True)
Int getFreeTile(Bool readonly)
void readTile(Int tile, Bool readonly)
LatticeCache(const LatticeCache< T > &other)
virtual void flush()
Flush contents.
this file contains all the compiler specific defines
Definition mainpage.dox:28
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41