[m-rev.] diff: optionally allow inlining and deep profiling

Julien Fischer juliensf at cs.mu.OZ.AU
Mon May 29 13:45:36 AEST 2006


This feature was requested by Mark on Friday.

Estimated hours taken: 1
Branches: main

Add a new option `--profile-optimized' that enables inlining with deep
profiling.  Inlining is usually disabled in deep profiling grades because it
distorts the profile by not gathering counts for inlined procedures.

In other circumstances the lack of inlining can also distort the profile.
This is happening with the G12 finite domain solver.  There are a number
of small procedures implemented in foreign code that are not being inlined
and the profiler ends up measuring the cost of crossing the foreign language
interface rather than telling us anything useful.

compiler/options.m:
compiler/handle_options.m:
	Add a new option `--profile-optimized' that enables inlining with
	deep profiling.

doc/user_guide.texi:
	Document the new option.

Julien.

Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.266
diff -u -r1.266 handle_options.m
--- compiler/handle_options.m	10 May 2006 10:56:49 -0000	1.266
+++ compiler/handle_options.m	29 May 2006 02:13:05 -0000
@@ -15,6 +15,7 @@
 % It also contains code for handling the --grade option.
 %
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

 :- module libs.handle_options.
 :- interface.
@@ -956,8 +957,17 @@

         % Inlining happens before the deep profiling transformation, so if
         % we allowed inlining to happen, then we would lose all profiling
-        % information about the inlined calls.
-        option_implies(profile_deep, allow_inlining, bool(no), !Globals),
+        % information about the inlined calls - this is not usually what we
+        % want so we disable inlining with deep profiling by default.  The
+        % user can re-enable it with the `--profile-optimized' option.
+        %
+        globals.lookup_bool_option(!.Globals, prof_optimized, ProfOptimized),
+        (
+            ProfOptimized = yes
+        ;
+            ProfOptimized = no,
+            option_implies(profile_deep, allow_inlining, bool(no), !Globals)
+        ),

         globals.lookup_string_option(!.Globals, experimental_complexity,
             ExpComp),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.513
diff -u -r1.513 options.m
--- compiler/options.m	10 May 2006 10:56:54 -0000	1.513
+++ compiler/options.m	29 May 2006 02:19:38 -0000
@@ -5,17 +5,18 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: options.m.
 % Main author: fjh.
-
+%
 % This defines the stuff necessary so that getopt_io.m can parse the
 % command-line options.
-
+%
 % IMPORTANT NOTE: any changes to the options should be reflected in both the
 % help message produced below, and in the Mercury User's Guide
 % (../doc/user_guide.texi).
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module libs.options.
@@ -184,6 +185,7 @@
     ;       trace_table_io_states
     ;       trace_table_io_require
     ;       trace_table_io_all
+    ;       prof_optimized
     ;       delay_death
     ;       suppress_trace
     ;       force_disable_tracing
@@ -930,6 +932,7 @@
     trace_table_io_states               -   bool(no),
     trace_table_io_require              -   bool(no),
     trace_table_io_all                  -   bool(no),
+    prof_optimized                      -   bool(no),
     suppress_trace                      -   string(""),
     force_disable_tracing               -   bool(no),
     delay_death                         -   bool(yes),
@@ -1645,6 +1648,8 @@
 long_option("trace-table-io-states",    trace_table_io_states).
 long_option("trace-table-io-require",   trace_table_io_require).
 long_option("trace-table-io-all",   trace_table_io_all).
+long_option("profile-optimised",    prof_optimized).
+long_option("profile-optimized",    prof_optimized).
 long_option("suppress-trace",       suppress_trace).
 long_option("force-disable-tracing",    force_disable_tracing).
 long_option("delay-death",          delay_death).
@@ -3076,6 +3081,8 @@
 %       "\tIf a primitive has no annotation specifying the type of",
 %       "\ttabling required, deduce it from the values of the other",
 %       "\tannotations.",
+        "--profile-optimized",
+        "\tDo not disable optimizations that can distort deep profiles.",
         "--no-delay-death",
         "\tWhen the trace level is `deep', the compiler normally",
         "\tpreserves the values of variables as long as possible, even",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.476
diff -u -r1.476 user_guide.texi
--- doc/user_guide.texi	2 May 2006 09:09:04 -0000	1.476
+++ doc/user_guide.texi	29 May 2006 02:18:39 -0000
@@ -5715,6 +5715,10 @@
 @c Its main use is to turn off tracing in the browser directory
 @c even for .debug and .decldebug grades.

+ at item --profile-optimized
+ at findex --profile-optimized
+Do not disable optimizations that can distort deep profiles.
+
 @item --no-delay-death
 @findex --no-delay-death
 @findex --delay-death

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list