[m-rev.] for review: dependent parallel conjunctions (1/2)

Peter Wang wangp at students.cs.mu.OZ.AU
Mon Jun 26 16:34:35 AEST 2006


On 2006-06-26, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> 
> > > > +    % References to shared variables need to be renamed apart so that the
> > > > +    % conjuncts only share promises.
> > > > +    %
> > > > +:- pred transform_conjunction(module_info::in, set(prog_var)::in,
> > > > +    hlds_goals::in, hlds_goal_info::in, hlds_goal::out, instmap::in,
> > > > +    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
> > > > +
> > > > +transform_conjunction(ModuleInfo, SharedVars, Goals, GoalInfo, NewGoal,
> > > > +        InstMap, !VarSet, !VarTypes) :-
> > > > +    allocate_promises(ModuleInfo, SharedVars, !VarTypes, !VarSet,
> > > > +        AllocatePromises, PromiseMap),
> > > > +    list.map_foldl3(transform_conjunct(ModuleInfo, SharedVars, PromiseMap),
> > > > +        Goals, NewGoals, InstMap, _, !VarSet, !VarTypes),
> > > > +    % XXX not sure about GoalInfo
> > >
> > > What are you not sure about the GoalInfo?
> >
> > Looking at it again it does seem ok, but I'm never sure about GoalInfos.
> 
> Won't the addition of the signal goals have changed the purity of some of the
> conjuncts? In which case the goal_features will need updating?

Ok, I've made it wrap a purity scope around transformed parallel
conjunctions and then run repuritycheck_proc on procedures to propagate
the impurities.

Peter


diff -u compiler/dep_par_conj.m compiler/dep_par_conj.m
--- compiler/dep_par_conj.m	25 Jun 2006 03:53:06 -0000
+++ compiler/dep_par_conj.m	26 Jun 2006 04:15:36 -0000
@@ -138,6 +138,10 @@
         map.det_update(ProcTable0, ProcId, !.ProcInfo, ProcTable),
         pred_info_set_procedures(ProcTable, !PredInfo),
 
+        % The transformation doesn't pay attention to the purity
+        % of compound goals, so recompute the purity here.
+        repuritycheck_proc(!.ModuleInfo, proc(PredId, ProcId), !PredInfo),
+
         map.det_update(PredTable0, PredId, !.PredInfo, PredTable),
         module_info_set_preds(PredTable, !ModuleInfo)
     ).
@@ -305,6 +309,25 @@
     % References to shared variables need to be renamed apart so that the
     % conjuncts only share futures.
     %
+    % Example:
+    %
+    %    p(A, B, ABA) :-
+    %        ( append(A, B, AB)
+    %        & append(AB, A, ABA)
+    %        ).
+    %
+    % becomes:
+    %
+    %   p(A, B, ABA) :-
+    %       new_future(FutureAB),
+    %       (
+    %           append(A, B, AB_7),
+    %           impure signal(FutureAB, AB_7)
+    %       &
+    %           wait(FutureAB, AB_10),
+    %           append(AB_10, A, ABA)
+    %       ).
+    %
 :- pred transform_conjunction(module_info::in, set(prog_var)::in,
     hlds_goals::in, hlds_goal_info::in, hlds_goal::out, instmap::in,
     prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
@@ -316,7 +339,16 @@
     list.map_foldl3(transform_conjunct(ModuleInfo, SharedVars, FutureMap),
         Goals, NewGoals, InstMap, _, !VarSet, !VarTypes),
     Conj = AllocateFutures ++ [conj(parallel_conj, NewGoals) - GoalInfo],
-    conj_list_to_goal(Conj, GoalInfo, NewGoal).
+    conj_list_to_goal(Conj, GoalInfo, NewGoal0),
+    % Wrap a purity scope around the goal if purity would have been lessened 
+    % by the addition of signal goals.
+    infer_goal_info_purity(GoalInfo, Purity),
+    (if Purity = purity_impure then
+        NewGoal = NewGoal0
+    else
+        Reason = promise_purity(dont_make_implicit_promises, Purity),
+        NewGoal = scope(Reason, NewGoal0) - GoalInfo
+    ).
 
 :- pred transform_conjunct(module_info::in, set(prog_var)::in,
     future_map::in, hlds_goal::in, hlds_goal::out,
--------------------------------------------------------------------------
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