[m-rev.] for review: trail entry counts in deep profiler (part 1)

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Nov 5 03:49:13 AEDT 2008


For review by Zoltan.

Extend the deep profiler so that in trailing grades it records
counts of value and function trail entries.
The deep profiling tool has not yet been updated to view the
new information.  I will do that once this change is installed.

runtime/mercury_conf_param.h:
 	Add a new macro MR_DEEP_PROFILING_TRAIL whose value says
 	whether counts of trail entries should be recorded.  The
 	new macro is only defined if MR_USE_TRAIL is.

runtime/mercury_deep_profiling.h:
 	Add two new fields to the Profiling_Metrics structure to
 	hold counts of trail entries.

runtime/mercury_deep_profiling.c:
 	Write out trail entry counts if recording of them is
 	enabled.

runtime/mercury_trail.h:
 	Update the appropriate counter in the current csd when
 	a new trail entry is added.

 	Shift a section header that was out of place.

deep_profiler/read_profile.m:
 	Read and (for now) ignore any trail entry counts.

Julien.

Index: deep_profiler/read_profile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/read_profile.m,v
retrieving revision 1.26
diff -u -r1.26 read_profile.m
--- deep_profiler/read_profile.m	18 Aug 2008 02:14:51 -0000	1.26
+++ deep_profiler/read_profile.m	4 Nov 2008 16:32:44 -0000
@@ -742,6 +742,11 @@
                  !MaybeError, !IO),
              maybe_read_num_handle_error(Mask, 0x0020, Words,
                  !MaybeError, !IO),
+            % XXX ignore these last two for now.
+            maybe_read_num_handle_error(Mask, 0x1000, _ValTrails,
+                !MaybeError, !IO),
+            maybe_read_num_handle_error(Mask, 0x2000, _FuncTrails,
+                !MaybeError, !IO),
              LastMaybeError = !.MaybeError
          ),
          (
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.107
diff -u -r1.107 mercury_conf_param.h
--- runtime/mercury_conf_param.h	5 Sep 2008 11:19:33 -0000	1.107
+++ runtime/mercury_conf_param.h	4 Nov 2008 13:07:40 -0000
@@ -596,15 +596,21 @@
  **
  ** MR_DEEP_PROFILING_MEMORY.
  ** Enables deep profiling of memory usage.
+**
+** MR_DEEP_PROFILING_TRAIL.
+** Enables deep profiling of trail entries.
  */

  #ifdef	MR_DEEP_PROFILING
-  /* this is the default set of measurements in deep profiling grades */
+  /* This is the default set of measurements in deep profiling grades. */
    #define MR_DEEP_PROFILING_PORT_COUNTS
    #ifndef MR_DEEP_PROFILING_PERF_TEST
      #define MR_DEEP_PROFILING_TIMING
      #define MR_DEEP_PROFILING_CALL_SEQ
      #define MR_DEEP_PROFILING_MEMORY
+    #if defined(MR_USE_TRAIL)
+      #define MR_DEEP_PROFILING_TRAIL
+    #endif
    #endif
  #else
    #undef  MR_DEEP_PROFILING_PORT_COUNTS
Index: runtime/mercury_deep_profiling.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_deep_profiling.c,v
retrieving revision 1.34
diff -u -r1.34 mercury_deep_profiling.c
--- runtime/mercury_deep_profiling.c	2 Oct 2008 05:22:38 -0000	1.34
+++ runtime/mercury_deep_profiling.c	4 Nov 2008 15:37:19 -0000
@@ -94,6 +94,9 @@
      0,
  #endif
  #ifdef MR_DEEP_PROFILING_MEMORY
+    0, 0,
+#endif
+#ifdef MR_DEEP_PROFILING_TRAIL
      0, 0
  #endif
      },
@@ -1193,6 +1196,14 @@
          bitmask |= 0x0020;
      }
  #endif
+#ifdef MR_DEEP_PROFILING_TRAIL
+    if (csd->MR_csd_own.MR_own_val_trails != 0) {
+        bitmask |= 0x1000;
+    }
+    if (csd->MR_csd_own.MR_own_func_trails != 0) {
+        bitmask |= 0x2000;
+    }
+#endif

      MR_write_num(fp, bitmask);

@@ -1237,6 +1248,15 @@
      }
  #endif

+#ifdef MR_DEEP_PROFILING_TRAIL
+    if (csd->MR_csd_own.MR_own_val_trails != 0) {
+        MR_write_num(fp, csd->MR_csd_own.MR_own_val_trails);
+    }
+    if (csd->MR_csd_own.MR_own_func_trails != 0) {
+        MR_write_num(fp, csd->MR_csd_own.MR_own_func_trails);
+    }
+#endif
+
      MR_write_out_proc_dynamic(fp, csd->MR_csd_callee_ptr);
  }

Index: runtime/mercury_deep_profiling.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_deep_profiling.h,v
retrieving revision 1.21
diff -u -r1.21 mercury_deep_profiling.h
--- runtime/mercury_deep_profiling.h	20 Sep 2008 11:38:05 -0000	1.21
+++ runtime/mercury_deep_profiling.h	4 Nov 2008 13:07:40 -0000
@@ -48,9 +48,15 @@
  	unsigned				MR_own_allocs;
  	unsigned				MR_own_words;
  #endif
+#if defined(MR_DEEP_PROFILING_TRAIL)
+	unsigned				MR_own_val_trails;
+	unsigned				MR_own_func_trails;
+#endif
  	/* ANSI/ISO C requires non-empty structs */
  #if !defined(MR_DEEP_PROFILING_PORT_COUNTS) && \
-	!defined(MR_DEEP_PROFILING_TIMING) && !defined(MR_DEEP_PROFILING_MEMORY)
+	!defined(MR_DEEP_PROFILING_TIMING)  && \
+	!defined(MR_DEEP_PROFILING_MEMORY)  && \
+	!defined(MR_DEEP_PROFILING_TRAIL)
  	unsigned				dummy;
  #endif
  };
@@ -210,6 +216,17 @@
    	((void) 0)
  #endif

+#ifdef MR_DEEP_PROFILING_TRAIL
+  #define MR_init_own_trail(csd)					\
+	do {								\
+		(csd)->MR_csd_own.MR_own_val_trails = 0;		\
+		(csd)->MR_csd_own.MR_own_func_trails = 0;		\
+	} while (0)
+#else
+  #define MR_init_own_trail(csd)					\
+	((void) 0)
+#endif
+
  #ifdef MR_DEEP_PROFILING_TAIL_RECURSION
    #define MR_init_depth_count(csd)					\
    	do {								\
@@ -229,6 +246,7 @@
  		MR_init_own_quanta(newcsd);				\
  		MR_init_own_call_seqs(newcsd);				\
  		MR_init_own_memory(newcsd);				\
+		MR_init_own_trail(newcsd);				\
  		MR_init_depth_count(newcsd);				\
  	} while (0)

Index: runtime/mercury_trail.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trail.h,v
retrieving revision 1.31
diff -u -r1.31 mercury_trail.h
--- runtime/mercury_trail.h	5 Sep 2008 11:19:33 -0000	1.31
+++ runtime/mercury_trail.h	4 Nov 2008 13:07:40 -0000
@@ -18,6 +18,7 @@

  #include "mercury_conf.h"
  #include "mercury_memory.h"
+#include "mercury_deep_profiling.h"

  #ifdef MR_USE_TRAIL
    #define MR_IF_USE_TRAIL(x) x
@@ -430,13 +431,26 @@
  #endif

  /*---------------------------------------------------------------------------*/
-/*
-** This is the interface that should be used by C code that wants to
-** do trailing.
-**
-** It is documented in the "Trailing" section of the
-** Mercury language reference manual.
-*/
+
+#if defined(MR_DEEP_PROFILING) && defined(MR_DEEP_PROFILING_TRAIL)
+
+#define MR_profdeep_maybe_record_val_trail_entry()                          \
+    do {                                                                    \
+        MR_current_call_site_dynamic->MR_csd_own.MR_own_val_trails++;       \
+    } while (0)
+
+#define MR_profdeep_maybe_record_func_trail_entry()                         \
+    do {                                                                    \
+        MR_current_call_site_dynamic->MR_csd_own.MR_own_func_trails++;      \
+    } while (0)
+
+#else 
+ 
+    #define MR_profdeep_maybe_record_val_trail_entry()      ((void) 0)
+    #define MR_profdeep_maybe_record_func_trail_entry()     ((void) 0)
+
+#endif
+
  /*---------------------------------------------------------------------------*/

  #if defined(MR_TRAIL_SEGMENTS)
@@ -454,6 +468,16 @@

  #endif /* !MR_TRAIL_SEGMENTS */

+/*---------------------------------------------------------------------------*/
+/*
+** This is the interface that should be used by C code that wants to
+** do trailing.
+**
+** It is documented in the "Trailing" section of the
+** Mercury language reference manual.
+*/
+/*---------------------------------------------------------------------------*/
+

  /*
  ** void  MR_trail_value(MR_Word *address, MR_Word value);
@@ -465,6 +489,7 @@
  #define MR_trail_value(address, value)                                      \
      do {                                                                    \
          MR_trail_extend_and_check();                                        \
+        MR_profdeep_maybe_record_val_trail_entry();                         \
          MR_store_value_trail_entry(MR_trail_ptr,                            \
              (address), (value));                                            \
          MR_trail_ptr++;                                                     \
@@ -495,6 +520,7 @@
  #define MR_trail_function(untrail_func, datum)                              \
      do {                                                                    \
          MR_trail_extend_and_check();                                        \
+        MR_profdeep_maybe_record_func_trail_entry();                        \
          MR_store_function_trail_entry((MR_trail_ptr),                       \
              (untrail_func), (datum));                                       \
          MR_trail_ptr++;                                                     \

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list