version runs specJBB...finally...
[IRC.git] / Robust / src / Runtime / bamboo / multicoregcprofile.c
1 #if (defined(MULTICORE_GC)||defined(PMC_GC))&&defined(GC_PROFILE)
2 #include "multicoregcprofile.h"
3 #include "structdefs.h"
4 #include "runtime_arch.h"
5 #include "mem.h"
6
7 void initmulticoregcprofiledata() {
8   if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
9     // startup core to initialize corestatus[]
10     gc_infoIndex = 0;
11     gc_infoOverflow = false;
12     gc_num_livespace = 0;
13     gc_num_freespace = 0;
14   }
15   gc_num_obj = 0;
16   gc_num_liveobj = 0;
17   gc_num_forwardobj = 0;
18   gc_num_profiles = NUMCORESACTIVE - 1;
19 }
20
21 // output the profiling data
22 void gc_outputProfileData() {
23   int i = 0;
24   int j = 0;
25   unsigned long long totalgc = 0;
26
27 #ifndef BAMBOO_MEMPROF
28   BAMBOO_PRINT(0xdddd);
29 #endif
30   // output task related info
31   for(i= 0; i < gc_infoIndex; i++) {
32     GCInfo * gcInfo = gc_infoArray[i];
33 #ifdef BAMBOO_MEMPROF
34     unsigned long long tmp=gcInfo->time[gcInfo->index-8]-gcInfo->time[0]; //0;
35 #else
36     unsigned long long tmp = 0;
37     BAMBOO_PRINT(0xddda);
38     for(j = 0; j < gcInfo->index - 7; j++) {
39       BAMBOO_PRINT(gcInfo->time[j]);
40       BAMBOO_PRINT(gcInfo->time[j]-tmp);
41       BAMBOO_PRINT(0xdddb);
42       tmp = gcInfo->time[j];
43     }
44     tmp = (tmp-gcInfo->time[0]);
45     BAMBOO_PRINT_REG(tmp);
46     BAMBOO_PRINT(0xdddc);
47     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 7]);
48     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 6]);
49     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 5]);
50     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 4]);
51     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 3]);
52     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 2]);
53     BAMBOO_PRINT(gcInfo->time[gcInfo->index - 1]);
54     BAMBOO_PRINT(0xddde);
55 #endif
56     totalgc += tmp;
57   }
58 #ifndef BAMBOO_MEMPROF
59   BAMBOO_PRINT(0xdddf);
60 #endif
61   BAMBOO_PRINT_REG(totalgc);
62
63   if(gc_infoOverflow) {
64     BAMBOO_PRINT(0xefee);
65   }
66
67 #ifndef BAMBOO_MEMPROF
68   BAMBOO_PRINT(0xeeee);
69 #endif
70 }
71
72 // output the profiling data
73 void gc_outputProfileDataReadable() {
74   // output task related info
75   for(int i= 0; i < gc_infoIndex; i++) {
76     GCInfo * gcInfo = gc_infoArray[i];
77
78     unsigned long long starttime=gcInfo->time[0]; //0;
79
80     for(int j = 1; j < gcInfo->index - 7; j++) {
81       printf("Event %u time since start=%llu, time since last event=%llu\n",j, gcInfo->time[j]-starttime, gcInfo->time[j]-gcInfo->time[j-1]);
82     }
83     printf("Livespace %llu\n", gcInfo->time[gcInfo->index-7]);
84     printf("Freespace %llu\n", gcInfo->time[gcInfo->index-6]);
85     printf("# Lobj %llu\n", gcInfo->time[gcInfo->index-5]);
86     printf("Lobj space %llu\n", gcInfo->time[gcInfo->index-4]);
87     printf("# obj %llu\n", gcInfo->time[gcInfo->index-3]);
88     printf("# live obj %llu\n", gcInfo->time[gcInfo->index-2]);
89     printf("# forward obj %llu\n", gcInfo->time[gcInfo->index-1]);
90   }
91 }
92 #endif // MULTICORE_GC