📄 d4.h
字号:
/* wback returns true for write-back */ int (*wbackf) (struct d4_cache_struct *, d4memref, int, d4stacknode *ptr, int); int prefetch_distance; /* specific to built-in prefetch policies */ int prefetch_abortpercent; char *name_replacement; /* for printing */ char *name_prefetch; char *name_walloc; char *name_wback;#ifdef D4CACHE_USERHOOK D4CACHE_USERHOOK /* allow additional stuff for user policies */#endif /* * Infinite cache for compulsory/capacity/conflict classification */ int nranges; int maxranges; d4range *ranges; /* * Cache statistics * Doubles are used as big integers * Index is accesstype + 0 or * accesstype + D4PREFETCH for prefetch */ double fetch [2 * D4NUMACCESSTYPES]; double miss [2 * D4NUMACCESSTYPES]; double blockmiss [2 * D4NUMACCESSTYPES]; double comp_miss [2 * D4NUMACCESSTYPES]; /* compulsory misses */ double comp_blockmiss [2 * D4NUMACCESSTYPES]; double cap_miss [2 * D4NUMACCESSTYPES]; /* capacity misses */ double cap_blockmiss [2 * D4NUMACCESSTYPES]; double conf_miss [2 * D4NUMACCESSTYPES]; /* conflict misses */ double conf_blockmiss [2 * D4NUMACCESSTYPES]; double multiblock; double bytes_read; double bytes_written;} d4cache;/* flags for d4cache */#define D4F_MEM 0x1 /* for simulated memory only */#define D4F_CCC 0x2 /* compulsory/capacity/conflict classification */#define D4F_RO 0x4 /* cache is read-only (e.g., an instruction cache) */#define D4F_USERFLAG1 0x8 /* first available flag bit */ /* * This macro provides access to certain fields of the * d4cache structure in a way that allows the references to be * replaced by constants if D4CUSTOM is true. With suitable * definitions of D4_CACHE_* macros, partial evaluation in the * compiler can simplify and speed up simulation. */#define D4VAL(cache,field) \ ((D4CUSTOM && D4_TRIGGER_FIELD(D4_CACHEID,field)) ? \ D4_VAL_(cache,D4_CACHEID,field) : \ ((cache)->field)) /* Some additional internal macros help get around ## wierdness */#define D4_VAL__(cache,cacheid,field) D4_CACHE_ ## cacheid ## _ ## field#define D4_VAL_(cache,cacheid,field) D4_VAL__(cache,cacheid,field)#define D4_TRIGGER_FIELD_(cacheid,field) D4_TRIGGER_ ## cacheid ## _ ## field#define D4_TRIGGER_FIELD(cacheid,field) D4_TRIGGER_FIELD_(cacheid,field) /* define something to avoid undeclared identifiers when !D4CUSTOM */ #define D4_CACHEID bogus#define D4_CACHE_bogus_flags 0#define D4_TRIGGER_bogus_flags 0#define D4_CACHE_bogus_lg2blocksize 0#define D4_TRIGGER_bogus_lg2blocksize 0#define D4_CACHE_bogus_lg2subblocksize 0#define D4_TRIGGER_bogus_lg2subblocksize 0#define D4_CACHE_bogus_lg2size 0#define D4_TRIGGER_bogus_lg2size 0#define D4_CACHE_bogus_assoc 0#define D4_TRIGGER_bogus_assoc 0#define D4_CACHE_bogus_numsets 0#define D4_TRIGGER_bogus_numsets 0#define D4_CACHE_bogus_replacementf NULL#define D4_TRIGGER_bogus_replacementf 0#define D4_CACHE_bogus_prefetchf NULL#define D4_TRIGGER_bogus_prefetchf 0#define D4_CACHE_bogus_wallocf NULL#define D4_TRIGGER_bogus_wallocf 0#define D4_CACHE_bogus_wbackf NULL#define D4_TRIGGER_bogus_wbackf 0#define D4_CACHE_bogus_prefetch_abortpercent 0#define D4_TRIGGER_bogus_prefetch_abortpercent 0#define D4_OPTS_bogus_ccc 0#define D4_OPTS_bogus_prefetch_none 0/* * Miscellaneous pseudo-functions */#define D4LG2MASK(n) /* make an n-bit mask */ \ ((((d4addr)1)<<(n))-1)#define D4ADDR2BLOCK(cache,addr) /* byte address of block containing ref */ \ ((addr) & ~D4LG2MASK(D4VAL(cache,lg2blocksize)))#define D4ADDR2SUBBLOCK(cache,addr) /* byte addr of subblock for ref */ \ ((addr) & ~D4LG2MASK(D4VAL(cache,lg2subblocksize)))#define D4ADDR2SET(cache,addr) /* which set does addr go in? */ \ (((addr)>>D4VAL(cache,lg2blocksize)) % D4VAL(cache,numsets))#define D4REFNSB(cache,mref) /* how many subblocks will mref touch? */ \ ((((mref).address+(mref).size-1) >> D4VAL(cache,lg2subblocksize)) - \ ((mref).address>>D4VAL(cache,lg2subblocksize)) + 1)#define D4ADDR2SBMASK(cache,mref) /* produce subblock bit mask for mref */ \ (D4LG2MASK(D4REFNSB(cache,mref)) << \ (((mref).address-D4ADDR2BLOCK(cache,(mref).address)) >> \ D4VAL(cache,lg2subblocksize)))/* * Compiler support */#if D4CUSTOM && __GNUC__#define D4_INLINE static inline#else#define D4_INLINE#endif/* * Global data declarations */extern const int d4custom; /* how to tell if this program was customized */extern struct d4_stackhash_struct d4stackhash; /* hash table for all caches */extern d4stacknode d4freelist; /* free list for stack nodes of all caches */extern int d4nnodes; /* total number of stack nodes allocated *//* * Global declarations for functions making up the Dinero IV * subroutine callable interface. *//* top level user-callable functions */extern d4cache *d4new (d4cache *);extern int d4setup (void);#if D4CUSTOM && !defined(d4ref)#define d4ref(c,m) (*(c)->ref)(c,m) /* call customized version */#elsevoid d4ref (d4cache *, d4memref); /* call generic version */#endifvoid d4copyback (d4cache *, const d4memref *, int);void d4invalidate (d4cache *, const d4memref *, int);void d4customize (FILE *);/* replacement policies */extern d4stacknode *d4rep_lru (d4cache *, int stacknum, d4memref, d4stacknode *ptr);extern d4stacknode *d4rep_fifo (d4cache *, int stacknum, d4memref, d4stacknode *ptr);extern d4stacknode *d4rep_random (d4cache *, int stacknum, d4memref, d4stacknode *ptr);/* prefetch policies */extern d4pendstack *d4prefetch_none (d4cache *, d4memref, int miss, d4stacknode *);extern d4pendstack *d4prefetch_always (d4cache *, d4memref, int miss, d4stacknode *);extern d4pendstack *d4prefetch_loadforw (d4cache *, d4memref, int miss, d4stacknode *);extern d4pendstack *d4prefetch_subblock (d4cache *, d4memref, int miss, d4stacknode *);extern d4pendstack *d4prefetch_miss (d4cache *, d4memref, int miss, d4stacknode *);extern d4pendstack *d4prefetch_tagged (d4cache *, d4memref, int miss, d4stacknode *);/* write allocate policies */extern int d4walloc_always (d4cache *, d4memref);extern int d4walloc_never (d4cache *, d4memref);extern int d4walloc_nofetch (d4cache *, d4memref);extern int d4walloc_impossible (d4cache *, d4memref); /* for icaches *//* write back/through policies */extern int d4wback_always (d4cache *, d4memref, int, d4stacknode *, int);extern int d4wback_never (d4cache *, d4memref, int, d4stacknode *, int);extern int d4wback_nofetch (d4cache *, d4memref, int, d4stacknode *, int);extern int d4wback_impossible (d4cache *, d4memref, int, d4stacknode *, int); /* for icaches *//* initialization routines */extern void d4init_rep_lru (d4cache *);extern void d4init_rep_fifo (d4cache *);extern void d4init_rep_random (d4cache *);extern void d4init_prefetch_none (d4cache *);extern void d4init_prefetch_always (d4cache *, int, int);extern void d4init_prefetch_loadforw (d4cache *, int, int);extern void d4init_prefetch_subblock (d4cache *, int, int);extern void d4init_prefetch_miss (d4cache *, int, int);extern void d4init_prefetch_tagged (d4cache *, int, int);extern void d4init_walloc_always (d4cache *);extern void d4init_walloc_never (d4cache *);extern void d4init_walloc_nofetch (d4cache *);extern void d4init_wback_always (d4cache *);extern void d4init_wback_never (d4cache *);extern void d4init_wback_nofetch (d4cache *);/* Miscellaneous functions users may or may not need */extern d4pendstack *d4get_mref(void); /* allocate struct for pending mref */extern void d4put_mref (d4pendstack *); /* deallocate pending mref */extern void d4init_prefetch_generic (d4cache *); /* helper routine for prefetch */extern d4stacknode *d4findnth (d4cache *, int stacknum, int n);extern void d4movetotop (d4cache *, int stacknum, d4stacknode *);extern void d4movetobot (d4cache *, int stacknum, d4stacknode *);extern void d4hash (d4cache *, int stacknum, d4stacknode *);/* * Global declarations for internal Dinero IV use. */extern int d4_infcache (d4cache *, d4memref);extern d4memref d4_splitm (d4cache *, d4memref, d4addr);extern void d4_dopending (d4cache *, d4pendstack *);extern void d4_unhash (d4cache *c, int stacknum, d4stacknode *);extern d4stacknode *d4_find (d4cache *, int stacknum, d4addr blockaddr);extern void d4_wbblock (d4cache *, d4stacknode *, const int);extern int d4_ncustom;extern long *d4_cust_vals[];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -