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 0x1000000
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_src_page(void *srcptr, void *tostart, void *tofinish);
44 void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded);
45 void cacheAdapt_gc(bool isgccachestage);
46 void cacheAdapt_master();
47 void cacheAdapt_mutator();
48 void cacheAdapt_phase_client();
49 void cacheAdapt_phase_master();
50 void gc_output_cache_sampling();
51 void gc_output_cache_sampling_r();
53 #ifdef GC_CACHE_SAMPLING
54 // enable the timer interrupt
55 #define CACHEADAPT_ENABLE_TIMER() \
57 bamboo_tile_timer_set_next_event(GC_TILE_TIMER_EVENT_SETTING); \
58 bamboo_unmask_timer_intr(); \
59 bamboo_dtlb_sampling_process(); \
62 #define CACHEADAPT_ENABLE_TIMER()
64 // disable the TILE_TIMER interrupt
65 #define CACHEADAPT_DISABLE_TIMER() bamboo_mask_timer_intr()
67 #ifdef GC_CACHE_SAMPLING
68 // reset the sampling arrays
69 #define CACHEADAPT_SAMPLING_RESET() bamboo_dtlb_sampling_reset()
70 #else // GC_CACHE_SAMPING
71 #define CACHEADAPT_SAMPLING_RESET()
74 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c) cacheadapt_finish_src_page(a,b,c);
75 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d) cacheadapt_finish_dst_page(a,b,c,d);
77 #define CACHEADAPT_GC(b) cacheAdapt_gc(b)
78 #define CACHEADAPT_MASTER() cacheAdapt_master()
79 #define CACHEADAPT_PHASE_CLIENT() cacheAdapt_phase_client()
80 #define CACHEADAPT_PHASE_MASTER() cacheAdapt_phase_master()
82 #ifdef GC_CACHE_ADAPT_OUTPUT
83 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING() gc_output_cache_sampling()
84 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R() gc_output_cache_sampling_r()
86 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING()
87 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R()
90 #ifdef GC_CACHE_ADAPT_OUTPUT_POLICY
92 #define CACHEADAPT_OUTPUT_CACHE_POLICY() \
94 if(gc_profile_flag) { \
95 bamboo_output_cache_policy(); \
99 #define CACHEADAPT_OUTPUT_CACHE_POLICY() bamboo_output_cache_policy()
101 #else // GC_CACHE_ADAPT_OUTPUT_POLICY
102 #define CACHEADAPT_OUTPUT_CACHE_POLICY()
103 #endif // GC_CACHE_ADAPT_OUTPUT
105 #else // GC_CACHE_ADAPT
106 #define CACHEADAPT_ENABLE_TIMER()
107 #define CACHEADAPT_DISABLE_TIMER()
108 #define CACHEADAPT_SAMPING_RESET()
109 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c)
110 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d)
111 #define CACHEADAPT_GC(b)
112 #define CACHEADAPT_MASTER()
113 #define CACHEADAPT_PHASE_CLIENT()
114 #define CACHEADAPT_PHASE_MASTER()
115 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING()
116 #define CACHEADAPT_OUTPUT_CACHE_SAMPLING_R()
117 #define CACHEADAPT_OUTPUT_CACHE_POLICY()
118 #endif // GC_CACHE_ADAPT
119 #else // MULTICORE_GC
120 #define CACHEADAPT_ENABLE_TIMER()
121 #define CACHEADAPT_DISABLE_TIMER()
122 #endif // MULTICORE_GC
124 #endif // BAMBOO_MULTICORE_CACHE_H