SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes
CCache< T > Class Template Reference

Detailed Description

template<class T>
class shogun::CCache< T >

Template class Cache implements a simple cache.

When the cache is full – elements that are least used are freed from the cache. Thus for the cache to be effective one should not visit loop over objects, i.e. visit elements in order 0...num_elements (with num_elements >> the maximal number of entries in cache)

Definition at line 31 of file Cache.h.

Inheritance diagram for CCache< T >:
Inheritance graph
[legend]

Public Member Functions

 CCache ()
 
 CCache (int64_t cache_size, int64_t obj_size, int64_t num_entries)
 
virtual ~CCache ()
 
bool is_cached (int64_t number)
 
T * lock_entry (int64_t number)
 
void unlock_entry (int64_t number)
 
T * set_entry (int64_t number)
 
virtual const char * get_name () const
 
- Public Member Functions inherited from CSGObject
 CSGObject ()
 
 CSGObject (const CSGObject &orig)
 
virtual ~CSGObject ()
 
virtual bool is_generic (EPrimitiveType *generic) const
 
template<class T >
void set_generic ()
 
void unset_generic ()
 
virtual void print_serializable (const char *prefix="")
 
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
 
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
 
void set_global_io (SGIO *io)
 
SGIOget_global_io ()
 
void set_global_parallel (Parallel *parallel)
 
Parallelget_global_parallel ()
 
void set_global_version (Version *version)
 
Versionget_global_version ()
 
SGVector< char * > get_modelsel_names ()
 
char * get_modsel_param_descr (const char *param_name)
 
index_t get_modsel_param_index (const char *param_name)
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 

Protected Attributes

bool cache_is_full
 
int64_t entry_size
 
int64_t nr_cache_lines
 
TEntry * lookup_table
 
TEntry ** cache_table
 
T * cache_block
 

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
 
Parallelparallel
 
Versionversion
 
Parameterm_parameters
 
Parameterm_model_selection_parameters
 
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
 
virtual void load_serializable_post () throw (ShogunException)
 
virtual void save_serializable_pre () throw (ShogunException)
 
virtual void save_serializable_post () throw (ShogunException)
 

Constructor & Destructor Documentation

CCache ( )

default constructor

Definition at line 46 of file Cache.h.

CCache ( int64_t  cache_size,
int64_t  obj_size,
int64_t  num_entries 
)

constructor

create a cache in which num_entries objects can be cached whose lookup table of sizeof(int64_t)*num_entries must fit into memory

Parameters
cache_sizecache size in Megabytes
obj_sizeobject size
num_entriesnumber of cached objects

Definition at line 68 of file Cache.h.

virtual ~CCache ( )
virtual

Definition at line 112 of file Cache.h.

Member Function Documentation

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 245 of file Cache.h.

bool is_cached ( int64_t  number)

checks if an object is cached

Parameters
numbernumber of object to check for
Returns
if an object is cached

Definition at line 124 of file Cache.h.

T* lock_entry ( int64_t  number)

lock and get a cache entry

Parameters
numbernumber of object to lock and get
Returns
cache entry or NULL when not cached

Definition at line 134 of file Cache.h.

T* set_entry ( int64_t  number)

returns the address of a free cache entry to where the data of size obj_size has to be written

Parameters
numbernumber of object to unlock
Returns
address of a free cache entry

Definition at line 163 of file Cache.h.

void unlock_entry ( int64_t  number)

unlock a cache entry

Parameters
numbernumber of object to unlock

Definition at line 150 of file Cache.h.

Member Data Documentation

T* cache_block
protected

cache block

Definition at line 259 of file Cache.h.

bool cache_is_full
protected

if cache is full

Definition at line 249 of file Cache.h.

TEntry** cache_table
protected

cache table containing cached objects

Definition at line 257 of file Cache.h.

int64_t entry_size
protected

size of one entry

Definition at line 251 of file Cache.h.

TEntry* lookup_table
protected

lookup table

Definition at line 255 of file Cache.h.

int64_t nr_cache_lines
protected

number of cache lines

Definition at line 253 of file Cache.h.


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

SHOGUN Machine Learning Toolbox - Documentation