[m-rev.] diff: Flatten conjuncts while comparing them with feedback data for auto-parallelism.

Paul Bone pbone at csse.unimelb.edu.au
Mon Jan 24 00:56:13 AEDT 2011


When comparing the HLDS to the feedback code the HLDS may already contain
parallel conjunctions for parallelisation we've already applied to the current
procedure.  In these cases flatten the conjunctions in the HLDS when
converting it to the goal_rep format for comparison with the feedback data.

compiler/introduce_parallelism.m:
compiler/prog_rep.m:
    As above.

Index: compiler/introduce_parallelism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/introduce_parallelism.m,v
retrieving revision 1.2
diff -u -p -b -r1.2 introduce_parallelism.m
--- compiler/introduce_parallelism.m	13 Jan 2011 00:36:52 -0000	1.2
+++ compiler/introduce_parallelism.m	23 Jan 2011 13:53:16 -0000
@@ -295,7 +295,7 @@ parallelise_proc(CPCProc, PredInfo, !Pro
     proc_info_get_varset(!.ProcInfo, VarSet),
     compute_var_number_map(HeadVars, VarSet, [], Goal0, VarNumMap),
     ProgRepInfo = prog_rep_info(FileName, VarTypes, VarNumMap,
-        VarNumRep, !.ModuleInfo),
+        VarNumRep, !.ModuleInfo, flatten_par_conjs),
     proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, Instmap),
 
     % Sort the candidate parallelisations so that we introduce
Index: compiler/prog_rep.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.73
diff -u -p -b -r1.73 prog_rep.m
--- compiler/prog_rep.m	13 Jan 2011 00:36:53 -0000	1.73
+++ compiler/prog_rep.m	23 Jan 2011 13:53:16 -0000
@@ -68,9 +68,14 @@
                 pri_vartypes    :: vartypes,
                 pri_var_num_map :: var_num_map,
                 pri_var_num_rep :: var_num_rep,
-                pri_module_info :: module_info
+                pri_module_info         :: module_info,
+                pri_flatten_par_conjs   :: flatten_par_conjs
             ).
 
+:- type flatten_par_conjs
+    --->    flatten_par_conjs
+    ;       expect_no_par_conjs.
+
 :- pred goal_to_goal_rep(prog_rep_info::in, instmap::in, hlds_goal::in, 
     goal_rep::out) is det.
 
@@ -83,6 +88,7 @@
 :- import_module check_hlds.inst_match.
 :- import_module check_hlds.mode_util.
 :- import_module hlds.code_model.
+:- import_module hlds.goal_util.
 :- import_module hlds.hlds_pred.
 :- import_module mdbcomp.
 :- import_module mdbcomp.goal_path.
@@ -107,7 +113,8 @@ represent_proc_as_bytecodes(HeadVars, Go
     term.context_file(Context, FileName),
     represent_var_table_as_bytecode(IncludeVarTable, VarNumMap, VarNumRep,
         VarTableBytes, !StringTable),
-    Info = prog_rep_info(FileName, VarTypes, VarNumMap, VarNumRep, ModuleInfo),
+    Info = prog_rep_info(FileName, VarTypes, VarNumMap, VarNumRep, ModuleInfo,
+        expect_no_par_conjs),
     InstmapDelta = goal_info_get_instmap_delta(GoalInfo),
 
     string_to_byte_list(FileName, FileNameBytes, !StringTable),
@@ -226,9 +233,19 @@ goal_to_goal_rep(Info, Instmap0, hlds_go
     detism_to_detism_rep(Detism, DetismRep),
     GoalRep = goal_rep(GoalExprRep, DetismRep, unit),
     (
-        GoalExpr = conj(ConjType, Goals),
+        GoalExpr = conj(ConjType, Goals0),
+        FlattenParConjs = Info ^ pri_flatten_par_conjs,
+        (
+            FlattenParConjs = flatten_par_conjs,
+            % Flatten all conjunction types, the current conjunction may be a
+            % plain conjunction with par conjunctions in it, or vice-versa.
+            flatten_conj(Goals0, Goals)
+        ;
+            FlattenParConjs = expect_no_par_conjs,
+            Goals = Goals0,
         expect(unify(ConjType, plain_conj), this_file,
-            "non-plain conjunction and declarative debugging"),
+                "non-plain conjunction and declarative debugging")
+        ),
         conj_to_conj_rep(Info, Instmap0, Goals, GoalReps),
         GoalExprRep = conj_rep(GoalReps)
     ;
-------------- 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/20110124/10f27d58/attachment.sig>


More information about the reviews mailing list