f8306c2c0f619f47e4705d4a09cb51ccd60b5743
[IRC.git] / Robust / src / Runtime / bamboo / multicoreprofile.c
1 #include "multicoreprofile.h"
2 #include "runtime_arch.h"
3
4 struct profiledata * eventdata;
5
6 void startEvent(enum eventprofile event) {
7   struct eventprofile *profile=&eventdata->cores[BAMBOO_NUM_OF_CORE].events[event];
8   profile->totaltimestarts+=BAMBOO_GET_EXE_TIME();
9   profile->numstarts++;
10 }
11
12 void stopEvent(enum eventprofile event) {
13   struct eventprofile *profile=&eventdata->cores[BAMBOO_NUM_OF_CORE].events[event];
14   profile->totaltimestops+=BAMBOO_GET_EXE_TIME();
15   profile->numstops++;
16 }
17
18 void printResults() {
19   for(int core=0;core<NUMCORES;core++) {
20     printf("Core: %u", core);
21     for(int event=0;event<NUMEVENTS;event++) {
22       printf("  Event:%s\n", eventnames[event]);
23       struct eventprofile *profile=&eventdata->cores[core].events[event];
24       if (profile->numstarts!=profile->numstops) {
25         printf("    Mismatched starts and stops\n");
26       }
27       long long totaltime=profile->totaltimestops-profile->totaltimestarts;
28       printf("    Total time: %llu Total events: %u Average time:%f\n", totaltime, profile->numstarts, ((double)totaltime)/profile->numstarts);
29     }
30   }
31 }