[m-rev.] diff: Attempt to automatically parallelise dependant conjunctions

Paul Bone pbone at csse.unimelb.edu.au
Wed Jan 27 15:45:08 AEDT 2010


Add an option to mdprof_feedback to control whether the automatic
parallelisation feedback will recommend parallelising dependant conjunctions or
not.  The compiler will now parallelise both independent and dependant
conjunctions.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Add a field to the candidate_parallel_conjunctions_opts structure to
    represent whether we should parallelise dependant conjunctions. 

    Use this flag to determine if a dependant conjunction should be recommended
    for parallelisation in innergoals_build_candidate_conjunction.

deep_profiler/mdprof_feedback.m:
    Add the actual command line argument.

    Update the --help message.

    Conform to changes in mdprof_fb.automatic_parallelism.m.

compiler/implicit_parallelism.m:
    Previously the compiler would not automatically parallelise dependant
    conjunctions, this restriction has been removed as the control is now
    available in the mdprof_feedback tool. 

Index: compiler/implicit_parallelism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/implicit_parallelism.m,v
retrieving revision 1.13
diff -u -p -b -r1.13 implicit_parallelism.m
--- compiler/implicit_parallelism.m	9 Jan 2010 05:49:41 -0000	1.13
+++ compiler/implicit_parallelism.m	27 Jan 2010 04:06:04 -0000
@@ -301,9 +301,6 @@ maybe_parallelise_conj(ProcInfo, CPC, Go
     PartitionNum = CPC ^ cpc_partition_number,
     FeedbackParConjuncts = CPC ^ cpc_conjs, 
     (
-        % XXX: Temporarily avoid parallelising dependant conjunctions,  This
-        % appears to trigger bugs in later stages of the compiler.
-        CPC ^ cpc_is_dependant = conjuncts_are_independent, 
         GoalExpr0 = conj(plain_conj, Conjs0),
         flatten_conj(Conjs0, Conjs1),
         find_partition(PartitionNum, Conjs1, GoalsBeforePartition,
Index: deep_profiler/mdprof_fb.automatic_parallelism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_fb.automatic_parallelism.m,v
retrieving revision 1.4
diff -u -p -b -r1.4 mdprof_fb.automatic_parallelism.m
--- deep_profiler/mdprof_fb.automatic_parallelism.m	9 Jan 2010 05:49:41 -0000	1.4
+++ deep_profiler/mdprof_fb.automatic_parallelism.m	27 Jan 2010 01:50:53 -0000
@@ -23,6 +23,7 @@
 :- import_module mdbcomp.
 :- import_module mdbcomp.feedback.
 
+:- import_module bool.
 :- import_module cord.
 :- import_module int.
 :- import_module float.
@@ -42,7 +43,8 @@
                 cpc_sparking_cost           :: int,
                 cpc_locking_cost            :: int,
                 cpc_clique_threshold        :: int,
-                cpc_call_site_threshold     :: int
+                cpc_call_site_threshold     :: int,
+                cpc_parallelise_dep_conjs   :: bool
             ).
     
 %-----------------------------------------------------------------------------%
@@ -99,7 +101,8 @@
 
 candidate_parallel_conjunctions(Opts, Deep, Messages, !Feedback) :-
     Opts = candidate_parallel_conjunctions_opts(DesiredParallelism,
-        SparkingCost, LockingCost, _CliqueThreshold, _CallSiteThreshold),
+        SparkingCost, LockingCost, _CliqueThreshold, _CallSiteThreshold, 
+        _ParalleliseDepConjs),
 
     % Find opertunities for parallelism by walking the clique tree.  Don't
     % Descened into cliques cheaper than the threshold.
@@ -1355,8 +1358,10 @@ partition_inner_goals(Location, [ IG | I
     inner_goals_partition::in, maybe(candidate_par_conjunction_internal)::out)
     is det.
 
-innergoals_build_candidate_conjunction(_Info, DependencyMaps, Location, GoalPath,
+innergoals_build_candidate_conjunction(Info, DependencyMaps, Location, GoalPath,
         InnerGoalsPartition, MaybeCandidate) :-
+    ParalleliseDependantConjs = Info ^ ipi_opts ^ cpc_parallelise_dep_conjs,
+
     % Setting up the first parallel conjunct is a different algorithm to the
     % latter ones, at this point we have the option of moving goals from before
     % the first costly call to either before or during the parallel
@@ -1414,7 +1419,13 @@ innergoals_build_candidate_conjunction(_
     Speedup = (SequentialCost - ParallelCost) * float(NumCalls), 
     ( 
         length(ParConjsCord) > 1, 
-        Speedup > 0.0
+        Speedup > 0.0,
+        (
+            ParalleliseDependantConjs = no,
+            IsDependant = conjuncts_are_independent
+        ;
+            ParalleliseDependantConjs = yes
+        )
     ->
         ParConjs = list(ParConjsCord),
         MaybeCandidate = yes(candidate_par_conjunction_internal(
Index: deep_profiler/mdprof_feedback.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_feedback.m,v
retrieving revision 1.19
diff -u -p -b -r1.19 mdprof_feedback.m
--- deep_profiler/mdprof_feedback.m	9 Jan 2010 05:49:41 -0000	1.19
+++ deep_profiler/mdprof_feedback.m	27 Jan 2010 01:50:53 -0000
@@ -183,6 +183,10 @@ help_message =
     --implicit-parallelism-call-site-cost-threshold <value>
                 The cost of a call site to be considered for parallelism
                 against another call site.
+    --implicit-parallelism-dependant-conjunctions
+                Advise the compiler to parallelism dependant conjunctions.
+                This will become the default once the implementation is
+                complete. 
 
     The following options select specific types of feedback information
     and parameterise them:
@@ -270,7 +274,8 @@ read_deep_file(Input, Debug, MaybeDeep, 
     ;       implicit_parallelism_sparking_cost
     ;       implicit_parallelism_locking_cost
     ;       implicit_parallelism_clique_cost_threshold
-    ;       implicit_parallelism_call_site_cost_threshold.
+    ;       implicit_parallelism_call_site_cost_threshold
+    ;       implicit_parallelism_dependant_conjunctions.
 
 % TODO: Introduce an option to disable parallelisation of dependant
 % conjunctions, or switch to the simple calculations for independent
@@ -304,6 +309,8 @@ long("implicit-parallelism-clique-cost-t
     implicit_parallelism_clique_cost_threshold).
 long("implicit-parallelism-call-site-cost-threshold",
     implicit_parallelism_call_site_cost_threshold).
+long("implicit-parallelism-dependant-conjunctions",
+    implicit_parallelism_dependant_conjunctions).
 
 :- pred defaults(option::out, option_data::out) is multi.
 
@@ -325,6 +332,7 @@ defaults(implicit_parallelism_sparking_c
 defaults(implicit_parallelism_locking_cost,                 int(100)).
 defaults(implicit_parallelism_clique_cost_threshold,        int(100000)).
 defaults(implicit_parallelism_call_site_cost_threshold,     int(50000)).
+defaults(implicit_parallelism_dependant_conjunctions,       bool(no)).
 
 :- pred construct_measure(string::in, stat_measure::out) is semidet.
 
@@ -423,12 +431,16 @@ check_options(Options0, RequestedFeedbac
         lookup_int_option(Options, 
             implicit_parallelism_call_site_cost_threshold,
             CPCCallSiteThreshold),
+        lookup_bool_option(Options,
+            implicit_parallelism_dependant_conjunctions,
+            ParalleliseDepConjs),
         CandidateParallelConjunctionsOpts =
             candidate_parallel_conjunctions_opts(DesiredParallelism, 
                 SparkingCost,
                 LockingCost,
                 CPCProcThreshold,
-                CPCCallSiteThreshold),
+                CPCCallSiteThreshold,
+                ParalleliseDepConjs),
         MaybeCandidateParallelConjunctionsOpts =
             yes(CandidateParallelConjunctionsOpts)
     ;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20100127/be8cb97f/attachment.sig>


More information about the reviews mailing list