File: cache.h

package info (click to toggle)
gnubg 0.90-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 30,800 kB
  • ctags: 8,224
  • sloc: ansic: 92,884; xml: 13,338; sh: 9,675; makefile: 425; python: 392; yacc: 295; sql: 237; lex: 220; php: 102; cs: 81; awk: 25; sed: 16
file content (66 lines) | stat: -rw-r--r-- 1,943 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* This program is free software; you can redistribute it and/or modify
 * it under the terms of version 3 or later of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 * cache.h
 *
 * by Gary Wong, 1997-2000
 * $Id: cache.h,v 1.12 2007/12/18 21:48:07 Superfly_Jon Exp $
 */

#ifndef _CACHE_H_
#define _CACHE_H_

#include <stdlib.h>

#define CACHE_STATS 1	/* Calculate simple cache stats */

typedef struct _cacheNode {
  unsigned char auchKey[10];
  int nEvalContext;
  float ar[7 /*NUM_ROLLOUT_OUTPUTS*/];
} cacheNode;

/* name used in eval.c */
typedef cacheNode evalcache;

typedef struct _cache
{
  cacheNode*	m;
  int *locks;
  
  unsigned int size;
  unsigned long hashMask;

#if CACHE_STATS
  unsigned int nAdds;
  unsigned int cLookup;
  unsigned int cHit;
#endif
} evalCache;

/* Cache size will be adjusted to a power of 2 */
int CacheCreate(evalCache* pc, unsigned int size);
int CacheResize(evalCache *pc, unsigned int cNew);

#define CACHEHIT ((unsigned int)-1)
/* returns a value which is passed to CacheAdd (if a miss) */
unsigned int CacheLookup(evalCache* pc, const cacheNode* e, float *arOut, float *arCubeful);

void CacheAdd(evalCache* pc, const cacheNode* e, unsigned long l);
void CacheAddNoKey(evalCache* pc, const cacheNode* e);
void CacheFlush(const evalCache* pc);
void CacheDestroy(const evalCache* pc);
void CacheStats(const evalCache* pc, unsigned int* pcLookup, unsigned int* pcHit, unsigned int* pcUsed);

#endif