Author: tobias@masterthesis-vm
Branch: c8-efficient-serial-execution
Changeset: r2023:f1f7a2e83f3c
Date: 2017-03-06 10:55 +0100
http://bitbucket.org/pypy/stmgc/changeset/f1f7a2e83f3c/

Log:    Add macros for timing instrumentation

diff --git a/c8/stm/prof.c b/c8/stm/prof.c
--- a/c8/stm/prof.c
+++ b/c8/stm/prof.c
@@ -39,8 +39,11 @@
                                                             buf.extra, 
EXTRA_LEN_MAX);
             }
         } else if (payload->type == STM_EVENT_PAYLOAD_DURATION) {
-            uint32_t duration = payload->data.duration;
-            buf.extra_length = sprintf(buf.extra, "%u", duration);
+            struct timespec *duration = payload->data.duration;
+            buf.extra_length = sprintf(buf.extra,
+                                        "s%un%u",
+                                        duration->tv_sec,
+                                        duration->tv_nsec);
         }
     }
 
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
new file mode 100644
--- /dev/null
+++ b/c8/stm/timing.h
@@ -0,0 +1,16 @@
+#include <time.h>
+
+/* Use raw monotonic time, i.e., solely based on local hardware (no NTP
+   adjustments) as in prof.c to obtain values comparable with total program
+   runtime. */
+#define start_timer() struct timespec start;                                 \
+                      clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+
+#define stop_timer() struct timespec stop;                                   \
+                     clock_gettime(CLOCK_MONOTONIC_RAW, &stop);
+
+/* Must use start_timer and stop_timer before using this macro. */
+#define get_duration() struct timespec duration = {                          \
+                           stop.tv_sec - start.tv_sec,                       \
+                           stop.tv_nsec - start.tv_nsec                      \
+                       };
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -201,7 +201,7 @@
 /* ==================== PUBLIC API ==================== */
 
 /* Number of segments (i.e. how many transactions can be executed in
-   parallel, in maximum).  If you try to start transactions in more
+   parallel, at maximum).  If you try to start transactions in more
    threads than the number of segments, it will block, waiting for the
    next segment to become free.
 */
@@ -616,9 +616,11 @@
 
     _STM_EVENT_PAYLOAD_N
 };
+
+#include <time.h>
 typedef union {
     stm_loc_marker_t *loc_marker;
-    uint32_t duration;
+    struct timespec *duration;
 } stm_timing_event_payload_data_t;
 /* Wrapper for payload holding data type and data. */
 typedef struct {
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to