[m-rev.] for review: a step towards making deep profiling work on Windows

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Nov 4 16:00:38 AEDT 2011


For review by Zoltan or Paul.

Branches: main, 11.07

A step towards getting a subset of deep profiling to work on Windows.

runtime/mercury_conf_param.h:
 	Re-order some definitions so that macros that specify C compiler or OS
 	specific properties are defined first.  This allows them to be used in
 	subsequent definitions.

 	Undefine MR_DEEP_PROFILING_TIMING if we are on Windows.  Time profiling
 	is not currently supported on Windows since it is implemented using
 	setitimer and that function doesn't exist on Windows.  (It does exist
 	in Cygwin, but is rather dodgy IIRC -- I'll check on this separately
 	a re-enable it in the Cygwin version if it turns out to work.)

runtime/mercury_prof_time.[ch]:
 	Fix incorrect guards: the contents of these files should only
 	be visible if MR_DEEP_PROFILING_TIMING is enabled.

Julien.

Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.122
diff -u -r1.122 mercury_conf_param.h
--- runtime/mercury_conf_param.h	13 Oct 2011 02:42:21 -0000	1.122
+++ runtime/mercury_conf_param.h	4 Nov 2011 04:51:03 -0000
@@ -31,6 +31,86 @@
  #define MERCURY_CONF_PARAM_H

  /*---------------------------------------------------------------------------*/
+
+/*
+** Win32 API specific.
+*/
+
+/*
+** MR_WIN32 -- The Win32 API is available.
+**
+** MR_WIN32_GETSYSTEMINFO -- Is GetSystemInfo() available?
+**
+** MR_WIN32_VIRTUAL_ALLOC -- Is VirtualAlloc() available?
+**
+** MR_BROKEN_ST_INO - Is the st_ino field of `struct stat' junk.
+**	Windows doesn't fill in this field correctly.
+*/
+#ifdef _WIN32
+  #define MR_WIN32
+  #define MR_WIN32_GETSYSTEMINFO
+  #define MR_WIN32_VIRTUAL_ALLOC
+  #define MR_WIN32_GETPROCESSTIMES
+  #define MR_BROKEN_ST_INO
+#endif
+
+/*---------------------------------------------------------------------------*/
+
+/*
+** Mac OS X specific.
+*/
+
+#if defined(__APPLE__) && defined(__MACH__)
+   #define MR_MAC_OSX
+#endif
+
+/*---------------------------------------------------------------------------*/
+
+/*
+** MinGW specific.
+*/
+
+#if defined(__MINGW32__)
+   #define MR_MINGW
+#endif
+
+/*---------------------------------------------------------------------------*/
+
+/*
+** Cygwin specific.
+*/
+
+#if defined(__CYGWIN__)
+   #define MR_CYGWIN
+#endif
+
+/*---------------------------------------------------------------------------*/
+
+/*
+** C compilers.
+*/
+
+/*
+** MR_CLANG -- The C compiler is clang.
+**
+** MR_GNUC -- The C compiler is GCC. 
+**            The value of this macro gives the major version number.
+**            We use this macro instead of __GNUC__ since clang also
+**            defines __GNUC__.
+**
+** MR_MSVC -- The C compiler is Visual C.
+**            The value of this macro gives the version number.
+*/
+
+#if defined(__clang__)
+    #define MR_CLANG __clang__
+#elif defined(__GNUC__)
+    #define MR_GNUC __GNUC__
+#elif defined(_MSC_VER)
+    #define MR_MSVC _MSC_VER
+#endif
+
+/*---------------------------------------------------------------------------*/
  /*
  ** Documentation for configuration parameters which can be set on the
  ** command line via `-D'.
@@ -630,6 +710,8 @@
  **
  ** MR_DEEP_PROFILING_TIMING.
  ** Enables deep profiling of time (obtained via clock interrupt signals).
+** This is not currently supported on Windows; we always disable it on that
+** platform.
  **
  ** MR_DEEP_PROFILING_CALL_SEQ.
  ** Enables deep profiling of time (obtained by counting call sequence numbers).
@@ -653,7 +735,7 @@
  */

  #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
@@ -691,6 +773,13 @@
    #define MR_CHECK_DU_EQ
  #endif

+/*
+** Time profiling is not currently supported on Windows.
+*/
+#if defined(MR_WIN32)
+  #undef MR_DEEP_PROFILING_TIMING
+#endif
+
  /*---------------------------------------------------------------------------*/
  /*
  ** Configuration parameters whose values are determined by the settings
@@ -988,86 +1077,6 @@
  /*---------------------------------------------------------------------------*/

  /*
-** Win32 API specific.
-*/
-
-/*
-** MR_WIN32 -- The Win32 API is available.
-**
-** MR_WIN32_GETSYSTEMINFO -- Is GetSystemInfo() available?
-**
-** MR_WIN32_VIRTUAL_ALLOC -- Is VirtualAlloc() available?
-**
-** MR_BROKEN_ST_INO - Is the st_ino field of `struct stat' junk.
-**	Windows doesn't fill in this field correctly.
-*/
-#ifdef _WIN32
-  #define MR_WIN32
-  #define MR_WIN32_GETSYSTEMINFO
-  #define MR_WIN32_VIRTUAL_ALLOC
-  #define MR_WIN32_GETPROCESSTIMES
-  #define MR_BROKEN_ST_INO
-#endif
-
-/*---------------------------------------------------------------------------*/
-
-/*
-** Mac OS X specific.
-*/
-
-#if defined(__APPLE__) && defined(__MACH__)
-   #define MR_MAC_OSX
-#endif
-
-/*---------------------------------------------------------------------------*/
-
-/*
-** MinGW specific.
-*/
-
-#if defined(__MINGW32__)
-   #define MR_MINGW
-#endif
-
-/*---------------------------------------------------------------------------*/
-
-/*
-** Cygwin specific.
-*/
-
-#if defined(__CYGWIN__)
-   #define MR_CYGWIN
-#endif
-
-/*---------------------------------------------------------------------------*/
-
-/*
-** C compilers.
-*/
-
-/*
-** MR_CLANG -- The C compiler is clang.
-**
-** MR_GNUC -- The C compiler is GCC. 
-**            The value of this macro gives the major version number.
-**            We use this macro instead of __GNUC__ since clang also
-**            defines __GNUC__.
-**
-** MR_MSVC -- The C compiler is Visual C.
-**            The value of this macro gives the version number.
-*/
-
-#if defined(__clang__)
-    #define MR_CLANG __clang__
-#elif defined(__GNUC__)
-    #define MR_GNUC __GNUC__
-#elif defined(_MSC_VER)
-    #define MR_MSVC _MSC_VER
-#endif
-
-/*---------------------------------------------------------------------------*/
-
-/*
  ** MR_HAVE_THREAD_PINNING is defined if we can pin threads, either with
  ** sched_setaffinity or hwloc.
  */
Index: runtime/mercury_prof_time.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_prof_time.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_prof_time.c
--- runtime/mercury_prof_time.c	14 Nov 2006 00:15:40 -0000	1.7
+++ runtime/mercury_prof_time.c	4 Nov 2011 04:51:03 -0000
@@ -31,7 +31,7 @@
    #include  <sys/time.h>
  #endif

-#if defined(MR_MPROF_PROFILE_TIME) || defined(MR_DEEP_PROFILING)
+#if defined(MR_MPROF_PROFILE_TIME) || defined(MR_DEEP_PROFILING_TIMING)

  #if !defined(MR_CLOCK_TICKS_PER_SECOND) || !defined(MR_HAVE_SETITIMER)
    #error "Time profiling not supported on this system"
@@ -144,4 +144,4 @@
      }
  }

-#endif /* MR_MPROF_PROFILE_TIME || MR_DEEP_PROFILING */
+#endif /* MR_MPROF_PROFILE_TIME || MR_DEEP_PROFILING_TIMING */
Index: runtime/mercury_prof_time.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_prof_time.h,v
retrieving revision 1.2
diff -u -r1.2 mercury_prof_time.h
--- runtime/mercury_prof_time.h	31 May 2001 06:00:15 -0000	1.2
+++ runtime/mercury_prof_time.h	4 Nov 2011 04:51:03 -0000
@@ -12,7 +12,7 @@

  extern	const char	*MR_time_method;

-#if defined(MR_MPROF_PROFILE_TIME) || defined(MR_DEEP_PROFILING)
+#if defined(MR_MPROF_PROFILE_TIME) || defined(MR_DEEP_PROFILING_TIMING)

  typedef	void	MR_time_signal_handler(int signum);

@@ -21,6 +21,6 @@

  extern	void	MR_init_time_profile_method(void);

-#endif	/* MR_MPROF_PROFILE_TIMING || MR_DEEP_PROFILING */
+#endif	/* MR_MPROF_PROFILE_TIMING || MR_DEEP_PROFILING_TIMING */

  #endif	/* MERCURY_PROF_TIME_H */

--------------------------------------------------------------------------
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