1 #ifndef BAMBOO_MULTICORE_GC_PROFILE_H
2 #define BAMBOO_MULTICORE_GC_PROFILE_H
5 #include "runtime_arch.h"
6 #include "structdefs.h"
9 #define GCINFOLENGTH 100
12 #define GC_PROFILE_NUM_FIELD 15
14 #define GC_PROFILE_NUM_FIELD 14
15 #endif // GC_CACHE_ADAPT
17 typedef struct gc_info {
18 unsigned long long time[GC_PROFILE_NUM_FIELD];
22 GCInfo * gc_infoArray[GCINFOLENGTH];
23 unsigned int gc_infoIndex;
25 unsigned long long gc_num_livespace;
26 unsigned long long gc_num_freespace;
27 unsigned long long gc_num_lobjspace;
28 unsigned int gc_num_lobj;
30 unsigned int gc_num_liveobj;
31 unsigned int gc_num_obj;
32 unsigned int gc_num_forwardobj;
33 unsigned int gc_num_profiles;
36 volatile bool gc_profile_flag;
39 void initmulticoregcprofiledata(void);
40 void gc_outputProfileData();
42 INLINE static void gc_profileInit() {
48 gc_num_forwardobj = 0;
49 gc_num_profiles = NUMCORESACTIVE - 1;
52 INLINE static void gc_profileStart(void) {
53 if(!gc_infoOverflow) {
54 GCInfo* gcInfo = RUNMALLOC(sizeof(struct gc_info));
55 gc_infoArray[gc_infoIndex] = gcInfo;
57 gcInfo->time[0] = BAMBOO_GET_EXE_TIME();
61 INLINE static void gc_profileItem(void) {
62 if(!gc_infoOverflow) {
63 GCInfo* gcInfo = gc_infoArray[gc_infoIndex];
64 gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME();
68 INLINE static void gc_profileEnd(void) {
69 if(!gc_infoOverflow) {
70 GCInfo* gcInfo = gc_infoArray[gc_infoIndex];
71 gcInfo->time[gcInfo->index++] = BAMBOO_GET_EXE_TIME();
72 gcInfo->time[gcInfo->index++] = gc_num_livespace;
73 gcInfo->time[gcInfo->index++] = gc_num_freespace;
74 gcInfo->time[gcInfo->index++] = gc_num_lobj;
75 gcInfo->time[gcInfo->index++] = gc_num_lobjspace;
76 gcInfo->time[gcInfo->index++] = gc_num_obj;
77 gcInfo->time[gcInfo->index++] = gc_num_liveobj;
78 gcInfo->time[gcInfo->index++] = gc_num_forwardobj;
80 if(gc_infoIndex == GCINFOLENGTH) {
81 gc_infoOverflow = true;
86 #define INIT_MULTICORE_GCPROFILE_DATA() initmulticoregcprofiledata()
87 #define GC_OUTPUT_PROFILE_DATA() gc_outputProfileData()
88 // send the num of obj/liveobj/forwardobj to the startupcore
89 #define GCPROFILE_INFO_2_MASTER() \
91 if(STARTUPCORE != BAMBOO_NUM_OF_CORE) { \
92 send_msg_4(STARTUPCORE,GCPROFILES,gc_num_obj,gc_num_liveobj,gc_num_forwardobj); \
99 #define GCPROFILE_RECORD_LOBJ() \
101 if(gc_profile_flag) { \
105 // record lobj space info
106 #define GCPROFILE_RECORD_LOBJSPACE() \
108 if(gc_profile_flag) { \
109 gc_num_lobjspace = sumsize; \
112 // check the live/free space info
113 #define GCPROFILE_RECORD_SPACE() \
115 if(gc_profile_flag) { \
116 gc_num_livespace = 0; \
117 for(int tmpi = 0; tmpi < gcnumblock; tmpi++) { \
118 gc_num_livespace += bamboo_smemtbl[tmpi]; \
120 gc_num_freespace = (BAMBOO_SHARED_MEM_SIZE) - gc_num_livespace; \
123 // record forward obj info
124 #define GCPROFILE_RECORD_FORWARD_OBJ() \
126 if(gc_profile_flag) { \
127 gc_num_forwardobj++; \
130 // record live obj info
131 #define GCPROFILE_RECORD_LIVE_OBJ() \
133 if(gc_profile_flag) { \
137 #define GCPROFILE_START() \
139 if(gc_profile_flag) { \
143 #define GCPROFILE_ITEM() \
145 if(gc_profile_flag) { \
149 #define GCPROFILE_END() \
151 if(gc_profile_flag) { \
156 #define GCPROFILE_RECORD_LOBJ() (gc_num_lobj++)
157 #define GCPROFILE_RECORD_LOBJSPACE() (gc_num_lobjspace = sumsize)
158 #define GCPROFILE_RECORD_SPACE() \
160 gc_num_livespace = 0; \
161 for(int tmpi = 0; tmpi < gcnumblock; tmpi++) { \
162 gc_num_livespace += bamboo_smemtbl[tmpi]; \
164 gc_num_freespace = (BAMBOO_SHARED_MEM_SIZE) - gc_num_livespace; \
166 #define GCPROFILE_RECORD_FORWARD_OBJ() (gc_num_forwardobj++)
167 #define GCPROFILE_RECORD_LIVE_OBJ() (gc_num_liveobj++)
168 #define GCPROFILE_START() gc_profileStart()
169 #define GCPROFILE_ITEM() gc_profileItem()
170 #define GCPROFILE_END() gc_profileEnd()
173 #define GCPROFILE_INIT() gc_profileInit()
176 #define INIT_MULTICORE_GCPROFILE_DATA()
177 #define GC_OUTPUT_PROFILE_DATA()
178 #define GCPROFILE_INFO_2_MASTER()
179 #define GCPROFILE_RECORD_LOBJ()
180 #define GCPROFILE_RECORD_LOBJSPACE()
181 #define GCPROFILE_RECORD_SPACE()
182 #define GCPROFILE_RECORD_FORWARD_OBJ()
183 #define GCPROFILE_RECORD_LIVE_OBJ()
184 #define GCPROFILE_START()
185 #define GCPROFILE_ITEM()
186 #define GCPROFILE_END()
187 #define GCPROFILE_INIT()
190 #endif // MULTICORE_GC
191 #endif // BAMBOO_MULTICORE_GC_PROFILE_H