1 #ifndef BAMBOO_MULTICORE_CACHE_H
2 #define BAMBOO_MULTICORE_CACHE_H
5 #include "multicoremem.h"
6 #include "multicoregccompact.h"
7 #include "multicoregarbage.h"
10 // sampling unit to compute access frequency, this should be consistent all the
12 #define GC_CACHE_SAMPLING_UNIT 0x800000000
13 // freqeuency to trigger timer interrupt
14 #define GC_TILE_TIMER_EVENT_SETTING 10000000
16 // data structure to record policy information for a page
17 // should be consistent with multicoreruntime.h
23 // policy type, should be enough to accommodate all 4 possible polices
24 unsigned int cache_mode : 3;
26 unsigned int __reserved_0 : 5;
27 // Location Override Target Y
28 unsigned int lotar_y : 4;
30 unsigned int __reserved_1 : 4;
31 // Location Override Target X
32 unsigned int lotar_x : 4;
34 unsigned int __reserved_2 : 12;
36 } bamboo_cache_policy_t;
38 #define BAMBOO_CACHE_MODE_LOCAL 1 // locally cached
39 #define BAMBOO_CACHE_MODE_HASH 2 // hash-for-home
40 #define BAMBOO_CACHE_MODE_NONE 3 // no caching
41 #define BAMBOO_CACHE_MODE_COORDS 4 // cached on a specific core
43 void cacheadapt_finish_compact(void *toptr);
44 void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish);
45 void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded);
46 void cacheAdapt_gc(bool isgccachestage);
47 void cacheAdapt_master();
48 void cacheAdapt_mutator();
49 void cacheAdapt_phase_client();
50 void cacheAdapt_phase_master();
51 void gc_output_cache_sampling();
52 void gc_output_cache_sampling_r();
54 #ifdef GC_CACHE_SAMPLING
55 // enable the timer interrupt
56 #define CACHEADAPT_ENABLE_TIMER() \
58 bamboo_tile_timer_set_next_event(GC_TILE_TIMER_EVENT_SETTING); \
59 bamboo_unmask_timer_intr(); \
60 bamboo_dtlb_sampling_process(); \
63 #define CACHEADAPT_ENABLE_TIMER()
65 // disable the TILE_TIMER interrupt
66 #define CACHEADAPT_DISABLE_TIMER() bamboo_mask_timer_intr()
68 #ifdef GC_CACHE_SAMPLING
69 // reset the sampling arrays
70 #define CACHEADAPT_SAMPLING_RESET() bamboo_dtlb_sampling_reset()
71 #else // GC_CACHE_SAMPING
72 #define CACHEADAPT_SAMPLING_RESET()
75 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c) cacheadapt_finish_src_page(a,b,c);
76 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d) cacheadapt_finish_dst_page(a,b,c,d);
77 #define CACHEADAPT_FINISH_COMPACT(a) cacheadapt_finish_compact(a);
79 #define CACHEADAPT_GC(b) cacheAdapt_gc(b)
80 #define CACHEADAPT_MASTER() cacheAdapt_master()
81 #define CACHEADAPT_PHASE_CLIENT() cacheAdapt_phase_client()
82 #define CACHEADAPT_PHASE_MASTER() cacheAdapt_phase_master()
84 #ifdef GC_CACHE_ADAPT_OUTPUT
85 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING() gc_output_cache_sampling()
86 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R() gc_output_cache_sampling_r()
88 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING()
89 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R()
92 #ifdef GC_CACHE_ADAPT_OUTPUT_POLICY
94 #define CACHEADAPT_OUTPUT_CACHE_POLICY() \
96 if(gc_profile_flag) { \
97 bamboo_output_cache_policy(); \
101 #define CACHEADAPT_OUTPUT_CACHE_POLICY() bamboo_output_cache_policy()
103 #else // GC_CACHE_ADAPT_OUTPUT_POLICY
104 #define CACHEADAPT_OUTPUT_CACHE_POLICY()
105 #endif // GC_CACHE_ADAPT_OUTPUT
107 #else // GC_CACHE_ADAPT
108 #define CACHEADAPT_ENABLE_TIMER()
109 #define CACHEADAPT_DISABLE_TIMER()
110 #define CACHEADAPT_SAMPING_RESET()
111 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c)
112 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d)
113 #define CACHEADAPT_FINISH_COMPACT(a)
114 #define CACHEADAPT_GC(b)
115 #define CACHEADAPT_MASTER()
116 #define CACHEADAPT_PHASE_CLIENT()
117 #define CACHEADAPT_PHASE_MASTER()
118 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING()
119 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R()
120 #define CACHEADAPT_OUTPUT_CACHE_POLICY()
121 #endif // GC_CACHE_ADAPT
122 #else // MULTICORE_GC
123 #define CACHEADAPT_ENABLE_TIMER()
124 #define CACHEADAPT_DISABLE_TIMER()
125 #endif // MULTICORE_GC
127 #endif // BAMBOO_MULTICORE_CACHE_H