[m-rev.] For post-commit review: Introduce --profile-for-implicit-parallelism option.

Paul Bone pbone at csse.unimelb.edu.au
Fri Sep 5 23:13:30 AEST 2008


For post-commit review by Zoltan.

Estimated hours taken: 1 
Branches: main

Introduce the --profile-for-implicit-parallelism option used to configure deep
profiling and coverage profiling options suitable for profiler directed
implicit parallelism.

--coverage-profiling no-longer implies the --deep-profiling grade flag.
Making it safe for use in MCFLAGS variables.

Fixed a bug in the coverage profiling transformation when the first pass is
disabled.

compiler/options.m:
	Create the new --profile-for-implicit-parallelism option.

compiler/handle_options.m:
	Handle the --profile-for-implicit-parallelism option.
	Remove the implication between --coverage-profiling and --deep-profiling.

compiler/deep_profiling.m:
	Fix a bug caused by disabling the first traversal using in coverage
	profiling.

compiler/hlds_goal.m:
	Remove the unused goal_info_get_dp_info function.

doc/user_guide.texi:
	Update documentation.
	Uncomment the documentation for --coverage-profiling.

Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.79
diff -u -p -r1.79 deep_profiling.m
--- compiler/deep_profiling.m	5 Sep 2008 03:32:55 -0000	1.79
+++ compiler/deep_profiling.m	5 Sep 2008 13:06:13 -0000
@@ -2013,18 +2013,18 @@ coverage_prof_second_pass_goal(Goal0, Go
 
     % Depending on command line arguments first pass information may or may not
     % be available, if it is not avalible sensible defaults are assumed.
-
-    Use2Pass = !.Info ^ ci_coverage_profiling_opts ^ cpo_use_2pass,
+    MaybeDPInfo = goal_info_get_maybe_dp_info(GoalInfo0),
     (
-        Use2Pass = yes,
-        dp_goal_info(GoalTrivial, GoalHasPortCounts) =
-            goal_info_get_dp_info(GoalInfo0)
+        MaybeDPInfo = yes( dp_goal_info(GoalTrivial, GoalHasPortCounts))
     ;
-        Use2Pass = no,
+        MaybeDPInfo = no,
 
         % XXX: Zoltan says;
         % Is this the best default you can get? You should be able to do
         % better for goals like unifications.
+        %
+        % pbone: I agree.  Idealy we should get more accurate information for
+        % atomic goals and fall back to these defaults for any other goal.
 
         GoalTrivial = goal_is_nontrivial,
         GoalHasPortCounts = goal_does_not_have_port_counts
@@ -2449,16 +2449,12 @@ coverage_prof_second_pass_ite(ITEExistVa
                 ; ElseDetism = detism_cc_multi
                 ),
 
-                % Now which should have coverage known.
-                % XXX What does that comment mean?
-                Use2Pass = !.Info ^ ci_coverage_profiling_opts ^
-                    cpo_use_2pass,
+                ThenMaybeDPInfo = 
+                    goal_info_get_maybe_dp_info(Then0 ^ hlds_goal_info),
                 (
-                    Use2Pass = yes,
-                    dp_goal_info(_, ThenHasPortCounts) =
-                        goal_info_get_dp_info(Then0 ^ hlds_goal_info)
+                    ThenMaybeDPInfo = yes(dp_goal_info(_, ThenHasPortCounts)) 
                 ;
-                    Use2Pass = no,
+                    ThenMaybeDPInfo = no,
                     ThenHasPortCounts = goal_does_not_have_port_counts
                 ),
 
@@ -2526,8 +2522,13 @@ coverage_prof_second_pass_ite(ITEExistVa
     % beginning of each branch,
 
     CPOBranchIf = !.Info ^ ci_coverage_profiling_opts ^ cpo_branch_ite,
-    dp_goal_info(_, CondHasPortCounts) =
-        Cond0 ^ hlds_goal_info ^ goal_info_get_dp_info,
+    CondMaybeDPInfo = goal_info_get_maybe_dp_info(Cond0 ^ hlds_goal_info),
+    (
+        CondMaybeDPInfo = yes(dp_goal_info(_, CondHasPortCounts))
+    ;
+        CondMaybeDPInfo = no,
+        CondHasPortCounts = goal_does_not_have_port_counts
+    ),
     (
         CPOBranchIf = yes,
         CondHasPortCounts = goal_does_not_have_port_counts,
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.323
diff -u -p -r1.323 handle_options.m
--- compiler/handle_options.m	5 Sep 2008 11:19:32 -0000	1.323
+++ compiler/handle_options.m	5 Sep 2008 12:39:57 -0000
@@ -1159,23 +1159,57 @@ postprocess_options_2(OptionTable0, Targ
 
         option_implies(target_debug, strip, bool(no), !Globals),
 
+        % Profile for implicit parallelism implies a particular coverage
+        % profiling configuration, since that's what is supported.
+        globals.lookup_bool_option(!.Globals, profile_for_implicit_parallelism,
+            ProfForImplicitParallelism),
+        (
+            ProfForImplicitParallelism = yes,
+            globals.set_option(coverage_profiling, bool(yes), !Globals),
+            globals.set_option(profile_deep_coverage_may_fail, bool(yes),
+                !Globals), 
+            globals.set_option(profile_deep_coverage_multi, bool(yes),
+                !Globals), 
+            globals.set_option(profile_deep_coverage_any, bool(yes), !Globals), 
+            globals.set_option(profile_deep_coverage_branch_ite, bool(yes),
+                !Globals), 
+            globals.set_option(profile_deep_coverage_branch_switch, bool(yes),
+                !Globals), 
+            globals.set_option(profile_deep_coverage_branch_disj, bool(yes),
+                !Globals),
+
+            % Disabling these two options causes the coverage profiling
+            % transformation to make a single backwards traversal.  This makes
+            % coverage information propagation easier at the expense of
+            % inserting more coverage points.
+            globals.set_option(profile_deep_coverage_use_portcounts, bool(no),
+                !Globals), 
+            globals.set_option(profile_deep_coverage_use_trivial, bool(no),
+                !Globals)
+        ;
+            ProfForImplicitParallelism = no
+        ),
+
+        % At the moment coverage profiling is not compatible with the tail
+        % recursion preservation optimization used by the deep profiler.
+        option_implies(coverage_profiling, deep_profile_tail_recursion,
+            bool(no), !Globals),
 
-        % Coverage profiling requires deep profiling.
-        option_implies(coverage_profiling, profile_deep, bool(yes),
-            !Globals),
-        
         % 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 - 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.
+        % user can re-enable it with the `--profile-optimized' option.  Leave
+        % inlineing enabled when profiling for implicit parallelism.
         % 
         globals.lookup_bool_option(!.Globals, prof_optimized, ProfOptimized),
         (
-            ProfOptimized = yes
-        ;
             ProfOptimized = no,
+            ProfForImplicitParallelism = no
+        ->
             option_implies(profile_deep, allow_inlining, bool(no), !Globals)
+        ;
+            true
         ),
 
         globals.lookup_string_option(!.Globals, experimental_complexity,
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.195
diff -u -p -r1.195 hlds_goal.m
--- compiler/hlds_goal.m	4 Sep 2008 11:41:00 -0000	1.195
+++ compiler/hlds_goal.m	5 Sep 2008 05:49:29 -0000
@@ -1169,7 +1169,6 @@
 :- func goal_info_get_lfu(hlds_goal_info) = set(prog_var).
 :- func goal_info_get_lbu(hlds_goal_info) = set(prog_var).
 :- func goal_info_get_reuse(hlds_goal_info) = reuse_description.
-:- func goal_info_get_dp_info(hlds_goal_info) = dp_goal_info.
 
 :- pred goal_info_get_occurring_vars(hlds_goal_info::in, set(prog_var)::out)
     is det.
@@ -2122,17 +2121,6 @@ goal_info_get_reuse(GoalInfo) = Reuse :-
             "Requesting reuse information while CTGC field not set.")
     ).
 
-goal_info_get_dp_info(GoalInfo) = DPInfo :-
-    MaybeDPInfo = goal_info_get_maybe_dp_info(GoalInfo),
-    (
-        MaybeDPInfo = yes(DPInfo)
-    ;
-        MaybeDPInfo = no,
-        unexpected(this_file,
-            "Requesting dp_info while maybe_dp_info field not set.")
-    ).
-
-
 %-----------------------------------------------------------------------------%
 
 goal_get_purity(hlds_goal(_GoalExpr, GoalInfo)) =
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.626
diff -u -p -r1.626 options.m
--- compiler/options.m	5 Sep 2008 11:19:32 -0000	1.626
+++ compiler/options.m	5 Sep 2008 12:39:58 -0000
@@ -309,11 +309,17 @@
     ;       profile_deep_coverage_use_portcounts
     ;       profile_deep_coverage_use_trivial
 
+            % Turn on flags ralevent for profiler directed implicit
+            % parallelism.
+    ;       profile_for_implicit_parallelism
+
     ;       use_zeroing_for_ho_cycles
     ;       use_lots_of_ho_specialization
-            % We should always handle tail recursion specially in deep
-            % profiling; the option is only for benchmarks for the paper.
 
+            % We should always handle tail recursion specially in deep
+            % profiling; the option is only for benchmarks for the paper,
+            % except that this is currently broken, and not supported with
+            % coverage profiling.
     ;       deep_profile_tail_recursion
     ;       record_term_sizes_as_words
     ;       record_term_sizes_as_cells
@@ -1166,6 +1172,7 @@ option_defaults_2(compilation_model_opti
     profile_deep_coverage_branch_disj   -   bool(yes),
     profile_deep_coverage_use_portcounts -  bool(yes),
     profile_deep_coverage_use_trivial   -   bool(yes),
+    profile_for_implicit_parallelism    -   bool(no),
     use_zeroing_for_ho_cycles           -   bool(yes),
     use_lots_of_ho_specialization       -   bool(no),
     deep_profile_tail_recursion         -   bool(no),
@@ -2003,6 +2010,8 @@ long_option("profile-deep-coverage-use-p
                     profile_deep_coverage_use_portcounts).
 long_option("profile-deep-coverage-use-trivial",
                     profile_deep_coverage_use_trivial).
+long_option("profile-for-implicit-parallelism",
+                    profile_for_implicit_parallelism).
 long_option("use-zeroing-for-ho-cycles",
                     use_zeroing_for_ho_cycles).
 long_option("use-lots-of-ho-specialization",
@@ -3958,6 +3967,10 @@ options_help_compilation_model -->
 %       "--no-profile-deep-coverage-use-trivial",
 %       "\tTurn off usage of trivial goal information",
 
+        "--profile-for-implicit-parallelism",
+        "\tSelect deep profiling options suitable for profiler directed",
+        "\timplicit parallelism",
+
         "--record-term-sizes-as-words\t\t(grade modifier: `.tsw')",
         "\tAugment each heap cells with its size in words.",
         "--record-term-sizes-as-cells\t\t(grade modifier: `.tsc')",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.573
diff -u -p -r1.573 user_guide.texi
--- doc/user_guide.texi	2 Sep 2008 09:44:08 -0000	1.573
+++ doc/user_guide.texi	5 Sep 2008 12:55:18 -0000
@@ -7541,19 +7541,28 @@ This option is only supported by the C b
 Enable deep profiling by inserting the appropriate hooks in the generated code.
 This option is only supported by the low-level C back-end.
 
+ at sp 1
+ at item @code{--coverage-profiling}
+ at findex --coverage-profiling
+ at cindex Coverage Profiling
+Enable coverage profiling by inserting coverage points, these are used to
+measure how execution moves through a procedure.  This option only effects
+programs built  in deep profiling grades.
+
+ at sp 1
+ at item @code{--profile-for-implicit-parallelism}
+ at findex --profile-for-implicit-parallelism
+ at cindex Coverage Profiling
+ at cindex Implicit Parallelism
+Enable options in the deep profiler that generate suitable profiles for use
+with profile directed implicit parallelism.  This option only effects programs
+built in deep profiling grades.
+
 @ignore
     Coverage profiling is experimental, some options below tune coverage
     profiling however they are intended for developers.
 
 @sp 1
- at item @code{--coverage-profiling} (grades: any grade containing @samp{.profdeep})
- at findex --coverage-profiling
- at cindex Coverage Profiling
-Enable coverage profiling by inserting coverage points used to measure how
-execution moves through a procedure.  This option is only supported by the
-low-level C back-end.
-        
- at sp 1
 
 Switches to effect coverage profiling (part of deep profiling).  they enable
 different types of coverage points.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20080905/01729519/attachment.sig>


More information about the reviews mailing list