profile data
authorbdemsky <bdemsky>
Mon, 4 Jul 2011 08:17:46 +0000 (08:17 +0000)
committerbdemsky <bdemsky>
Mon, 4 Jul 2011 08:17:46 +0000 (08:17 +0000)
Robust/src/Runtime/bamboo/multicoreprofile.c [new file with mode: 0644]
Robust/src/Runtime/bamboo/multicoreprofile.h [new file with mode: 0644]

diff --git a/Robust/src/Runtime/bamboo/multicoreprofile.c b/Robust/src/Runtime/bamboo/multicoreprofile.c
new file mode 100644 (file)
index 0000000..f8306c2
--- /dev/null
@@ -0,0 +1,31 @@
+#include "multicoreprofile.h"
+#include "runtime_arch.h"
+
+struct profiledata * eventdata;
+
+void startEvent(enum eventprofile event) {
+  struct eventprofile *profile=&eventdata->cores[BAMBOO_NUM_OF_CORE].events[event];
+  profile->totaltimestarts+=BAMBOO_GET_EXE_TIME();
+  profile->numstarts++;
+}
+
+void stopEvent(enum eventprofile event) {
+  struct eventprofile *profile=&eventdata->cores[BAMBOO_NUM_OF_CORE].events[event];
+  profile->totaltimestops+=BAMBOO_GET_EXE_TIME();
+  profile->numstops++;
+}
+
+void printResults() {
+  for(int core=0;core<NUMCORES;core++) {
+    printf("Core: %u", core);
+    for(int event=0;event<NUMEVENTS;event++) {
+      printf("  Event:%s\n", eventnames[event]);
+      struct eventprofile *profile=&eventdata->cores[core].events[event];
+      if (profile->numstarts!=profile->numstops) {
+       printf("    Mismatched starts and stops\n");
+      }
+      long long totaltime=profile->totaltimestops-profile->totaltimestarts;
+      printf("    Total time: %llu Total events: %u Average time:%f\n", totaltime, profile->numstarts, ((double)totaltime)/profile->numstarts);
+    }
+  }
+}
diff --git a/Robust/src/Runtime/bamboo/multicoreprofile.h b/Robust/src/Runtime/bamboo/multicoreprofile.h
new file mode 100644 (file)
index 0000000..4c0e0ba
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef MULTICOREPROFILE_H
+#define MULTICOREPROFILE_H
+
+enum profileevents {
+  GCTIME,
+  NUMEVENTS;
+};
+
+char ** eventnames={"gctime", "endmarker"};
+
+struct eventprofile {
+  long long totaltimestarts;
+  long long totaltimestops;
+  int numstarts;
+  int numstops;
+};
+
+struct coreprofile {
+  struct eventprofile events[NUMEVENTS];
+};
+
+struct profiledata {
+  struct coreprofile cores[NUMCORES];
+};
+
+extern struct profiledata * eventdata;
+
+void startEvent(enum eventprofile event);
+void stopEvent(enum eventprofile event);
+void printResults();
+
+#endif